function switchMode()

in src/components/application/details/controls/actions/action-view-mode.js [6:27]


function switchMode(event, workflow, history, callback, options) {
  event.preventDefault();
  event.stopPropagation();
  const {
    from,
    jobId,
    launching,
    mode,
  } = options || {};
  const newMode = /^graph$/i.test(mode) ? 'plain' : 'graph';
  const jobIdPath = jobId ? `/${jobId}` : '';
  const launchingMode = launching ? 'launching=true' : null;
  const fromParam = from ? `from=${from}` : null;
  const queryParams = [fromParam, launchingMode].filter(Boolean);
  const query = queryParams.length > 0 ? `?${queryParams.join('&')}` : '';
  if (history) {
    history.push(`/run/${workflow?.id}/${newMode}${jobIdPath}${query}`);
  }
  if (callback) {
    callback(ACTION_VIEW_MODE_KEY, {mode: newMode, navigated: !!history, id: workflow.id});
  }
}