refactor(client): inline isEditMode instead of shadowing it with isWizard
This commit is contained in:
1 parent
8572065ef7
commit
7872b18108
1 file changed
+7
-10
@@ -234,9 +234,6 @@ const CreateMonitorPage = () => {
|
|||||||
}, [location.pathname]);
|
}, [location.pathname]);
|
||||||
|
|
||||||
const showTypeSelector = pageType === "uptime" && !isEditMode;
|
const showTypeSelector = pageType === "uptime" && !isEditMode;
|
||||||
// The multi-step wizard applies to every create flow; only the monitor-type
|
|
||||||
// radio is uptime-specific. Edit mode keeps the flat form.
|
|
||||||
const isWizard = !isEditMode;
|
|
||||||
const defaultType: MonitorType =
|
const defaultType: MonitorType =
|
||||||
pageType === "pagespeed"
|
pageType === "pagespeed"
|
||||||
? "pagespeed"
|
? "pagespeed"
|
||||||
@@ -267,10 +264,10 @@ const CreateMonitorPage = () => {
|
|||||||
reset(defaults);
|
reset(defaults);
|
||||||
}, [defaults, reset]);
|
}, [defaults, reset]);
|
||||||
|
|
||||||
// Multi-step wizard, uptime create only (showTypeSelector). Other flows
|
// Multi-step wizard on every create flow; edit mode keeps the flat form
|
||||||
// keep the flat form, where showStep() is always true.
|
// where showStep() is always true.
|
||||||
const [currentStep, setCurrentStep] = useState(0);
|
const [currentStep, setCurrentStep] = useState(0);
|
||||||
const showStep = (step: number) => !isWizard || currentStep === step;
|
const showStep = (step: number) => isEditMode || currentStep === step;
|
||||||
|
|
||||||
const watchedType = watch("type") as MonitorType;
|
const watchedType = watch("type") as MonitorType;
|
||||||
const watchedUseAdvancedMatching = watch("useAdvancedMatching") as boolean;
|
const watchedUseAdvancedMatching = watch("useAdvancedMatching") as boolean;
|
||||||
@@ -365,7 +362,7 @@ const CreateMonitorPage = () => {
|
|||||||
refetch={refetchMonitor}
|
refetch={refetchMonitor}
|
||||||
onDelete={handleDeleteClick}
|
onDelete={handleDeleteClick}
|
||||||
/>
|
/>
|
||||||
{isWizard && (
|
{!isEditMode && (
|
||||||
<StepProgress
|
<StepProgress
|
||||||
steps={totalSteps}
|
steps={totalSteps}
|
||||||
current={currentStep}
|
current={currentStep}
|
||||||
@@ -1338,9 +1335,9 @@ const CreateMonitorPage = () => {
|
|||||||
|
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
justifyContent={isWizard ? "space-between" : "flex-end"}
|
justifyContent={!isEditMode ? "space-between" : "flex-end"}
|
||||||
>
|
>
|
||||||
{isWizard && (
|
{!isEditMode && (
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
@@ -1351,7 +1348,7 @@ const CreateMonitorPage = () => {
|
|||||||
{t("common.buttons.back")}
|
{t("common.buttons.back")}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{isWizard && currentStep < totalSteps - 1 ? (
|
{!isEditMode && currentStep < totalSteps - 1 ? (
|
||||||
<Button
|
<Button
|
||||||
key="wizard-next"
|
key="wizard-next"
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
Reference in new issue
Block a user