Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// *********************************************************************
import * as Actions from './flowActions';
import * as Models from './flowModels';
import { QueryModels, QueryActions } from 'datax-query';
const INITIAL_FLOW_STATE = {
// Flow Config
name: '',
flowId: '',
displayName: Models.getDefaultName(),
owner: '',
databricksToken: '',
input: Models.defaultInput,
referenceData: [],
functions: [],
query: QueryModels.defaultQuery,
scale: {
jobNumExecutors: '4',
jobExecutorMemory: '1000',
jobDatabricksAutoScale: true,
jobDatabricksMinWorkers: '1',
jobDatabricksMaxWorkers: '8'
},
outputs: [Models.getMetricSinker()],
outputTemplates: [],
rules: [],
batchInputs: [Models.getDefaultBatchInputSettings()],
batchList: [],
// State
isNew: false,
outputs: Selectors.getFlowOutputs(state),
outputTemplates: Selectors.getFlowOutputTemplates(state),
rules: Selectors.getFlowRules(state),
// State
selectedBatchIndex: Selectors.getSelectedBatchIndex(state),
selectedReferenceDataIndex: Selectors.getSelectedReferenceDataIndex(state),
selectedFunctionIndex: Selectors.getSelectedFunctionIndex(state),
selectedSinkerIndex: Selectors.getSelectedSinkerIndex(state),
selectedOutputTemplateIndex: Selectors.getSelectedOutputTemplateIndex(state),
selectedRuleIndex: Selectors.getSelectedRuleIndex(state),
isTestQueryOutputPanelVisible: LayoutSelectors.getTestQueryOutputPanelVisibility(state),
kernelId: KernelSelectors.getKernelId(state),
kernelVersion: KernelSelectors.getKernelVersion(state),
fetchingKernel: KernelSelectors.getFetchingKernel(state),
errorMessage: Selectors.getErrorMessage(state),
warningMessage: Selectors.getWarningMessage(state),
enableLocalOneBox: Selectors.getEnableLocalOneBox(state),
// Validation
infoValidated: Selectors.validateFlowInfo(state),
inputValidated: Selectors.validateFlowInput(state),
referenceDataValidated: Selectors.validateFlowReferenceData(state),
functionsValidated: Selectors.validateFlowFunctions(state),
scaleValidated: Selectors.validateFlowScale(state),
outputsValidated: Selectors.validateFlowOutputs(state),
rulesValidated: Selectors.validateFlowRules(state),
flowValidated: Selectors.validateFlow(state),
queryValidated: QuerySelectors.validateQueryTab(state),
scheduleValidated: Selectors.validateFlowSchedule(state)
});
isQueryDirty: QuerySelectors.getQueryDirty(state),
scale: Selectors.getFlowScale(state),
outputs: Selectors.getFlowOutputs(state),
outputTemplates: Selectors.getFlowOutputTemplates(state),
rules: Selectors.getFlowRules(state),
// State
selectedBatchIndex: Selectors.getSelectedBatchIndex(state),
selectedReferenceDataIndex: Selectors.getSelectedReferenceDataIndex(state),
selectedFunctionIndex: Selectors.getSelectedFunctionIndex(state),
selectedSinkerIndex: Selectors.getSelectedSinkerIndex(state),
selectedOutputTemplateIndex: Selectors.getSelectedOutputTemplateIndex(state),
selectedRuleIndex: Selectors.getSelectedRuleIndex(state),
isTestQueryOutputPanelVisible: LayoutSelectors.getTestQueryOutputPanelVisibility(state),
kernelId: KernelSelectors.getKernelId(state),
kernelVersion: KernelSelectors.getKernelVersion(state),
fetchingKernel: KernelSelectors.getFetchingKernel(state),
errorMessage: Selectors.getErrorMessage(state),
warningMessage: Selectors.getWarningMessage(state),
enableLocalOneBox: Selectors.getEnableLocalOneBox(state),
// Validation
infoValidated: Selectors.validateFlowInfo(state),
inputValidated: Selectors.validateFlowInput(state),
referenceDataValidated: Selectors.validateFlowReferenceData(state),
functionsValidated: Selectors.validateFlowFunctions(state),
scaleValidated: Selectors.validateFlowScale(state),
outputsValidated: Selectors.validateFlowOutputs(state),
rulesValidated: Selectors.validateFlowRules(state),
flowValidated: Selectors.validateFlow(state),
queryValidated: QuerySelectors.validateQueryTab(state),
scale: Selectors.getFlowScale(state),
outputs: Selectors.getFlowOutputs(state),
outputTemplates: Selectors.getFlowOutputTemplates(state),
rules: Selectors.getFlowRules(state),
// State
selectedBatchIndex: Selectors.getSelectedBatchIndex(state),
selectedReferenceDataIndex: Selectors.getSelectedReferenceDataIndex(state),
selectedFunctionIndex: Selectors.getSelectedFunctionIndex(state),
selectedSinkerIndex: Selectors.getSelectedSinkerIndex(state),
selectedOutputTemplateIndex: Selectors.getSelectedOutputTemplateIndex(state),
selectedRuleIndex: Selectors.getSelectedRuleIndex(state),
isTestQueryOutputPanelVisible: LayoutSelectors.getTestQueryOutputPanelVisibility(state),
kernelId: KernelSelectors.getKernelId(state),
kernelVersion: KernelSelectors.getKernelVersion(state),
fetchingKernel: KernelSelectors.getFetchingKernel(state),
errorMessage: Selectors.getErrorMessage(state),
warningMessage: Selectors.getWarningMessage(state),
enableLocalOneBox: Selectors.getEnableLocalOneBox(state),
// Validation
infoValidated: Selectors.validateFlowInfo(state),
inputValidated: Selectors.validateFlowInput(state),
referenceDataValidated: Selectors.validateFlowReferenceData(state),
functionsValidated: Selectors.validateFlowFunctions(state),
scaleValidated: Selectors.validateFlowScale(state),
outputsValidated: Selectors.validateFlowOutputs(state),
rulesValidated: Selectors.validateFlowRules(state),
flowValidated: Selectors.validateFlow(state),
queryValidated: QuerySelectors.validateQueryTab(state),
scheduleValidated: Selectors.validateFlowSchedule(state)
query: QuerySelectors.getQueryContent(state),
isQueryDirty: QuerySelectors.getQueryDirty(state),
scale: Selectors.getFlowScale(state),
outputs: Selectors.getFlowOutputs(state),
outputTemplates: Selectors.getFlowOutputTemplates(state),
rules: Selectors.getFlowRules(state),
// State
selectedBatchIndex: Selectors.getSelectedBatchIndex(state),
selectedReferenceDataIndex: Selectors.getSelectedReferenceDataIndex(state),
selectedFunctionIndex: Selectors.getSelectedFunctionIndex(state),
selectedSinkerIndex: Selectors.getSelectedSinkerIndex(state),
selectedOutputTemplateIndex: Selectors.getSelectedOutputTemplateIndex(state),
selectedRuleIndex: Selectors.getSelectedRuleIndex(state),
isTestQueryOutputPanelVisible: LayoutSelectors.getTestQueryOutputPanelVisibility(state),
kernelId: KernelSelectors.getKernelId(state),
kernelVersion: KernelSelectors.getKernelVersion(state),
fetchingKernel: KernelSelectors.getFetchingKernel(state),
errorMessage: Selectors.getErrorMessage(state),
warningMessage: Selectors.getWarningMessage(state),
enableLocalOneBox: Selectors.getEnableLocalOneBox(state),
// Validation
infoValidated: Selectors.validateFlowInfo(state),
inputValidated: Selectors.validateFlowInput(state),
referenceDataValidated: Selectors.validateFlowReferenceData(state),
functionsValidated: Selectors.validateFlowFunctions(state),
scaleValidated: Selectors.validateFlowScale(state),
outputsValidated: Selectors.validateFlowOutputs(state),
rulesValidated: Selectors.validateFlowRules(state),
flowValidated: Selectors.validateFlow(state),
.then(flow => {
dispatch(QueryActions.initQuery(flow.payload.query));
})
.catch(error => {
return dispatch({
type: FLOW_INIT,
payload: flow
});
})
.then(flow => {
dispatch(QueryActions.initQuery(flow.payload.query));
})
.catch(error => {
const message = getApiErrorMessage(error);
updateErrorMessage(dispatch, message);
return Q.reject({ error: true, message: message });
});
} else {
const owner = UserSelectors.getUserAlias(getState());
dispatch(QueryActions.initQuery(QueryModels.defaultQuery));
return dispatch({
type: FLOW_NEW,
payload: owner
});
}
};
getKernel() {
if (
this.props.input.properties.inputSchemaFile !== Models.defaultInput.properties.inputSchemaFile &&
this.props.input.properties.inputSchemaFile !== '{}'
) {
const version = this.props.kernelVersion + 1;
this.props.onUpdateKernelVersion(version);
this.props.onGetKernel(
Helpers.convertFlowToQueryMetadata(this.props.flow, this.props.query),
version,
QueryActions.updateErrorMessage
);
}
}
refreshKernel(kernelId) {
const version = this.props.kernelVersion + 1;
this.props.onUpdateKernelVersion(version);
this.props.onRefreshKernel(
Helpers.convertFlowToQueryMetadata(this.props.flow, this.props.query),
kernelId,
version,
QueryActions.updateErrorMessage
);
}
onDeleteAllKernels: updateErrorMessage => dispatch(KernelActions.deleteAllKernels(updateErrorMessage)),