all files / src/workflows/visualizer/components/steps/Visualization/ View.js

38.6% Statements 22/57
26.92% Branches 7/26
25% Functions 2/8
40.43% Lines 19/47
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109                                                                                                                                                                                   
'use strict';
 
Object.defineProperty(exports, "__esModule", {
  value: true
});
 
var _reactRedux = require('react-redux');
 
var _queryString = require('query-string');
 
var _queryString2 = _interopRequireDefault(_queryString);
 
var _JobMonitoring = require('../../../../generic/components/steps/JobMonitoring');
 
var _JobMonitoring2 = _interopRequireDefault(_JobMonitoring);
 
var _getNetworkError = require('../../../../../utils/getNetworkError');
 
var _getNetworkError2 = _interopRequireDefault(_getNetworkError);
 
var _getDisabledButtons = require('../../../../../utils/getDisabledButtons');
 
var _get = require('../../../../../utils/get');
 
var _get2 = _interopRequireDefault(_get);
 
var _redux = require('../../../../../redux');
 
var _projects = require('../../../../../redux/actions/projects');
 
var SimActions = _interopRequireWildcard(_projects);
 
function _interopRequireWildcard(obj) { Eif (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
 
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 
// ----------------------------------------------------------------------------
 
function getActions(props) {
  var taskflow = props.taskflow;
 
  var jobs = Object.keys(taskflow.jobMapById).map(function (id) {
    return taskflow.jobMapById[id];
  });
  var actions = [];
 
  taskflow.actions.forEach(function (action) {
    actions.push(action);
  });
 
  // name is paraview and status is running -> visualize
  if (jobs.some(function (job) {
    return job.name === props.primaryJob && job.status === 'running';
  })) {
    actions.push('visualize');
  } else if (taskflow.allComplete) {
    actions.push('rerun');
  }
 
  return actions;
}
 
// ----------------------------------------------------------------------------
 
function onVisualize(props) {
  var location = {
    pathname: props.location.pathname,
    search: _queryString2.default.stringify(Object.assign({}, _queryString2.default.parse(props.location.search), {
      view: 'visualizer'
    })),
    state: props.location.state
  };
  (0, _redux.dispatch)(SimActions.saveSimulation(props.simulation, null, location));
}
 
// ----------------------------------------------------------------------------
 
exports.default = (0, _reactRedux.connect)(function (state, props) {
  var taskflowId = null;
  var activeProject = state.projects.active;
  var activeSimulation = activeProject ? state.projects.simulations[activeProject].active : null;
 
  if (activeSimulation) {
    var simulation = state.simulations.mapById[activeSimulation];
    taskflowId = simulation.steps.Visualization.metadata.taskflowId;
  }
 
  var taskflow = null;
  if (taskflowId) {
    taskflow = state.taskflows.mapById[taskflowId];
  }
 
  var cluster = null;
  if ((0, _get2.default)(taskflow, 'flow.meta.cluster._id')) {
    var clusterId = taskflow.flow.meta.cluster._id;
    cluster = state.preferences.clusters.mapById[clusterId];
  }
 
  return {
    getActions: getActions,
    taskflow: taskflow,
    taskflowId: taskflowId,
    cluster: cluster,
    disabledButtons: (0, _getDisabledButtons.getDisabledButtons)(state.network, taskflow),
    error: (0, _getNetworkError2.default)(state, ['terminate_taskflow', 'delete_taskflow']),
    actionFunctions: { onVisualize: onVisualize }
  };
})(_JobMonitoring2.default);