
/**
 * Sets the current active toolbar group.
 * @method UI.setActiveToolMode
 * @param {string} groupDataElement The groups dataElement. Default values are: toolMenu-View, toolMenu-Annotation,
 * toolMenu-Form, toolMenu-Sign, toolMenu-Security, toolMenu-Compare, toolMenu-Editor
 * @example
WebViewer(...)
  .then(function(instance) {
    // Change the toolbar group to the `Forms` group
    instance.UI.setActiveToolMode('toolMenu-Form');
 */

export default (store) => (dataElement) => {
  const tool = store.tools.find(tool => tool.dataElement === dataElement);
  if (tool) {
    if (tool.hidden) {
      tool.hidden = false;
    }
    store.setActiveToolMode(tool.element);
  } else {
    console.warn('DataElement not found.');
  }
};