@maap-jupyterlab/dps-jupyter-extension
Version:
A JupyterLab extension for submitting and viewing jobs.
44 lines (43 loc) • 1.25 kB
JavaScript
import { createSlice } from '@reduxjs/toolkit';
const initialState = {
selectedAlgorithm: null,
selectedResource: null,
selectedAlgorithmMetadata: null,
selectedCMRCollection: null
};
export const algorithmsSlice = createSlice({
name: 'Algorithms',
initialState,
reducers: {
resetValue: () => initialState,
/**
* Algorithm user has selected
*/
setAlgorithm: (state, action) => {
state.selectedAlgorithm = action.payload;
},
/**
* Metadata for selected algorithm
*/
setAlgorithmMetadata: (state, action) => {
state.selectedAlgorithmMetadata = action.payload;
},
/**
* Resource user has selected
*/
setResource: (state, action) => {
state.selectedResource = action.payload;
},
/**
* CMR collection user has selected
*/
setCMRCollection: (state, action) => {
state.selectedCMRCollection = action.payload;
},
},
});
// Actions
export const algorithmsActions = algorithmsSlice.actions;
// Selector
export const selectAlgorithms = (state) => state.Algorithms;
export default algorithmsSlice.reducer;