From 16a123c44d0bb75acbf41c47466ec1086db76aeb Mon Sep 17 00:00:00 2001 From: Amit Yathirajadasan Date: Wed, 16 Aug 2023 16:15:05 -0700 Subject: [PATCH] fix: rename step groups to level --- src/components/add-step/index.js | 41 +++++++------- src/components/edit-step-modal/index.js | 6 +-- src/components/index.js | 2 +- src/components/{step-group => level}/index.js | 14 ++--- .../{step-group => level}/styles.scss | 2 +- src/components/stage/index.js | 54 +++++++++---------- src/components/stages/index.js | 11 ++-- src/components/step/index.js | 6 +-- src/components/styles.scss | 2 +- src/utils/stage.js | 36 +++++++------ 10 files changed, 83 insertions(+), 91 deletions(-) rename src/components/{step-group => level}/index.js (95%) rename src/components/{step-group => level}/styles.scss (98%) diff --git a/src/components/add-step/index.js b/src/components/add-step/index.js index d422082e..c974fd3b 100644 --- a/src/components/add-step/index.js +++ b/src/components/add-step/index.js @@ -3,50 +3,45 @@ import PropTypes from 'prop-types'; import { Button } from 'nr1'; -const AddStep = ({ stepGroups = [], onUpdate }) => { +const AddStep = ({ levels = [], onUpdate }) => { const [displayStepOptions, setDisplayStepOptions] = useState(false); - const [selectedStepGroup, setSelectedStepGroup] = useState( - stepGroups.length + 1 - ); + const [selectedLevel, setSelectedLevel] = useState(levels.length + 1); const [stepTitle, setStepTitle] = useState(''); const addStepHandler = () => { - const updatedStepGroups = - selectedStepGroup > stepGroups.length - ? [...stepGroups, { steps: [{ signals: [], title: stepTitle }] }] - : stepGroups.map((stepGroup, index) => - index === selectedStepGroup - 1 + const updatedLevels = + selectedLevel > levels.length + ? [...levels, { steps: [{ signals: [], title: stepTitle }] }] + : levels.map((level, index) => + index === selectedLevel - 1 ? { - ...stepGroup, - steps: [ - ...stepGroup.steps, - { signals: [], title: stepTitle }, - ], + ...level, + steps: [...level.steps, { signals: [], title: stepTitle }], } - : stepGroup + : level ); - if (onUpdate) onUpdate({ stepGroups: updatedStepGroups }); + if (onUpdate) onUpdate({ levels: updatedLevels }); cancelAddStepHandler(); }; const cancelAddStepHandler = useCallback(() => { - setSelectedStepGroup(stepGroups.length + 1); + setSelectedLevel(levels.length + 1); setStepTitle(''); setDisplayStepOptions(false); - }, [stepGroups]); + }, [levels]); return displayStepOptions ? (
{ }; AddStep.propTypes = { - stepGroups: PropTypes.array, + levels: PropTypes.array, onUpdate: PropTypes.func, }; diff --git a/src/components/edit-step-modal/index.js b/src/components/edit-step-modal/index.js index 64359e38..115d25ca 100644 --- a/src/components/edit-step-modal/index.js +++ b/src/components/edit-step-modal/index.js @@ -17,7 +17,7 @@ import { isMatchPattern } from '../../utils/regex'; const EditStepModal = ({ stageName = 'Stage', - stepGroup = 0, + level = 0, stepTitle = 'Step', existingSignals = [], hidden = true, @@ -69,7 +69,7 @@ const EditStepModal = ({ type={HeadingText.TYPE.HEADING_5} className="step-group" > - {stepGroup} + {level} {stepTitle} @@ -189,7 +189,7 @@ const EditStepModal = ({ EditStepModal.propTypes = { stageName: PropTypes.string, - stepGroup: PropTypes.number, + level: PropTypes.number, stepTitle: PropTypes.string, existingSignals: PropTypes.arrayOf(PropTypes.string), hidden: PropTypes.bool, diff --git a/src/components/index.js b/src/components/index.js index 7c1722d7..7bd21a19 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -4,7 +4,7 @@ export { default as EditStepModal } from './edit-step-modal'; export { default as Signal } from './signal'; export { default as SignalsList } from './signals-list'; export { default as Step } from './step'; -export { default as StepGroup } from './step-group'; +export { default as Level } from './level'; export { default as Stages } from './stages'; export { default as Stage } from './stage'; export { default as KpiModal } from './kpi-modal'; diff --git a/src/components/step-group/index.js b/src/components/level/index.js similarity index 95% rename from src/components/step-group/index.js rename to src/components/level/index.js index a61fbafd..54e624af 100644 --- a/src/components/step-group/index.js +++ b/src/components/level/index.js @@ -8,7 +8,7 @@ import IconsLib from '../icons-lib'; import DeleteConfirmModal from '../delete-confirm-modal'; import { MODES, STATUSES } from '../../constants'; -const StepGroup = ({ +const Level = ({ order = 0, steps = [], stageName, @@ -98,7 +98,7 @@ const StepGroup = ({ return (