Skip to content

Commit

Permalink
fix: back buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
JGAntunes committed Oct 11, 2024
1 parent 4f7d5d6 commit b424381
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 7 deletions.
46 changes: 40 additions & 6 deletions web/src/components/upgrade_service/ConfirmAndDeploy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ interface PreflightResultResponse {
const ConfirmAndDeploy = ({
setCurrentStep,
hasPreflight,
isConfigurable,
}: {
isConfigurable: boolean;
hasPreflight: boolean;
setCurrentStep: (step: number) => void;
}) => {
Expand Down Expand Up @@ -272,12 +274,11 @@ const ConfirmAndDeploy = ({
)}
</div>
<div className="tw-flex tw-justify-between tw-mt-4">
<button
className="btn secondary blue"
onClick={() => navigate(`/upgrade-service/app/${slug}/preflight`)}
>
Back: Preflight checks
</button>
<BackButton

Check failure on line 277 in web/src/components/upgrade_service/ConfirmAndDeploy.tsx

View workflow job for this annotation

GitHub Actions / lint-web

'BackButton' was used before it was defined
slug={slug}
isConfigurable={isConfigurable}
hasPreflight={hasPreflight}
/>
<button
className="btn primary blue"
disabled={preflightCheck?.showDeploymentBlocked || isLoading}
Expand Down Expand Up @@ -351,4 +352,37 @@ const ConfirmAndDeploy = ({
);
};

const BackButton = ({
slug,
hasPreflight,
isConfigurable,
}: {
slug: string;
hasPreflight: boolean;
isConfigurable: boolean;
}) => {
const navigate = useNavigate();

if (hasPreflight) {
return (
<button
className="btn secondary blue"
onClick={() => navigate(`/upgrade-service/app/${slug}/preflight`)}
>
Back: Preflight checks
</button>
);
}

return (
<button
className="btn secondary blue"
onClick={() => navigate(`/upgrade-service/app/${slug}/config`)}
disabled={!isConfigurable}
>
Back: Config
</button>
);
};

export default ConfirmAndDeploy;
3 changes: 3 additions & 0 deletions web/src/components/upgrade_service/PreflightChecks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ import { isEqual } from "lodash";

const PreflightCheck = ({
setCurrentStep,
isConfigurable,
}: {
setCurrentStep: (step: number) => void;
isConfigurable: boolean;
}) => {
const navigate = useNavigate();

Expand Down Expand Up @@ -164,6 +166,7 @@ const PreflightCheck = ({
<button
className="btn secondary blue"
onClick={() => navigate(`/upgrade-service/app/${slug}/config`)}
disabled={!isConfigurable}
>
Back: Config
</button>
Expand Down
6 changes: 5 additions & 1 deletion web/src/components/upgrade_service/UpgradeService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ const UpgradeServiceBody = () => {
path="preflight"
element={
upgradeInfo?.hasPreflight ? (
<PreflightChecks setCurrentStep={setCurrentStep} />
<PreflightChecks
setCurrentStep={setCurrentStep}
isConfigurable={upgradeInfo?.isConfigurable}
/>
) : (
<Navigate to="../deploy" />
)
Expand All @@ -106,6 +109,7 @@ const UpgradeServiceBody = () => {
path="deploy"
element={
<ConfirmAndDeploy
isConfigurable={upgradeInfo?.isConfigurable}
hasPreflight={upgradeInfo?.hasPreflight}
setCurrentStep={setCurrentStep}
/>
Expand Down

0 comments on commit b424381

Please sign in to comment.