Skip to content

Commit 5128eb2

Browse files
committed
feat: disabled buttons on redeploy, fixed file path import
1 parent 95a6722 commit 5128eb2

File tree

2 files changed

+42
-25
lines changed

2 files changed

+42
-25
lines changed

src/features/instance/applications/components/ApplicationsSidebar/FileTreeExplorer/FileMenuActionButtons.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { useQueryClient, useSuspenseQuery } from '@tanstack/react-query';
1111
import { Minus, Plus, RefreshCwIcon } from 'lucide-react';
1212
import { useCallback, useState } from 'react';
1313
import { toast } from 'sonner';
14-
import { RedeployApplicationModal } from '../../../modals/RedeployApplication';
14+
import { RedeployApplicationModal } from '@/features/instance/applications/modals/RedeployApplicationModal';
1515

1616
export function FileMenuActionButtons() {
1717
const queryClient = useQueryClient();
@@ -187,6 +187,7 @@ export function FileMenuActionButtons() {
187187
isModalOpen={isRedeployApplicationClicked}
188188
setIsModalOpen={setIsRedeployApplicationClicked}
189189
redeployPackage={redeployPackage}
190+
isRedeployPackagePending={isDeployComponentPending}
190191
packageUrl={selectedFolderFile.pkg}
191192
/>
192193
</div>

src/features/instance/applications/modals/RedeployApplication.tsx renamed to src/features/instance/applications/modals/RedeployApplicationModal.tsx

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,41 @@ export function RedeployApplicationModal({
1515
isModalOpen = false,
1616
setIsModalOpen,
1717
redeployPackage,
18-
packageUrl,
18+
isRedeployPackagePending,
19+
packageUrl,
1920
}: {
2021
readonly isModalOpen: boolean;
2122
readonly setIsModalOpen: (value: boolean) => void;
2223
readonly redeployPackage: (applicationUrl: string) => void;
23-
readonly packageUrl?: string;
24+
readonly isRedeployPackagePending?: boolean;
25+
readonly packageUrl?: string;
2426
}) {
2527
const methods = useForm({
26-
defaultValues: {
27-
applicationUrl: packageUrl
28-
},
29-
});
28+
defaultValues: {
29+
applicationUrl: packageUrl,
30+
},
31+
});
3032

31-
const { setFocus, control, handleSubmit } = methods;
33+
const { setFocus, control, handleSubmit } = methods;
3234

33-
const submitForm = ({ applicationUrl }: { applicationUrl: string | undefined }) => {
34-
if (applicationUrl) {
35-
redeployPackage(applicationUrl);
36-
}
37-
}
35+
const submitForm = ({ applicationUrl }: { applicationUrl: string | undefined }) => {
36+
if (applicationUrl) {
37+
redeployPackage(applicationUrl);
38+
}
39+
};
3840

39-
useEffect(() => {
40-
setFocus('applicationUrl');
41-
}, [setFocus]);
41+
useEffect(() => {
42+
setFocus('applicationUrl');
43+
}, [setFocus]);
4244

4345
return (
44-
<Dialog onOpenChange={() => {
45-
setIsModalOpen(!isModalOpen);
46-
methods.reset({ applicationUrl: packageUrl });
47-
}} open={isModalOpen}>
46+
<Dialog
47+
onOpenChange={() => {
48+
setIsModalOpen(!isModalOpen);
49+
methods.reset({ applicationUrl: packageUrl });
50+
}}
51+
open={isModalOpen}
52+
>
4853
<DialogContent aria-describedby={undefined} className="text-white">
4954
<DialogHeader>
5055
<DialogTitle>Redeploy Package</DialogTitle>
@@ -75,13 +80,24 @@ export function RedeployApplicationModal({
7580
</FormItem>
7681
)}
7782
/>
78-
<Button variant="positiveOutline" type="submit" className="w-full rounded-full">
83+
<Button
84+
variant="positiveOutline"
85+
type="submit"
86+
className="w-full rounded-full"
87+
disabled={isRedeployPackagePending}
88+
>
7989
<RefreshCwIcon /> Redeploy Application
8090
</Button>
81-
<Button type="button" variant="default" className="w-full rounded-full" onClick={() => {
82-
setIsModalOpen(false)
83-
methods.reset({ applicationUrl: packageUrl });
84-
}}>
91+
<Button
92+
type="button"
93+
variant="default"
94+
className="w-full rounded-full"
95+
onClick={() => {
96+
setIsModalOpen(false);
97+
methods.reset({ applicationUrl: packageUrl });
98+
}}
99+
disabled={isRedeployPackagePending}
100+
>
85101
<Ban /> Cancel
86102
</Button>
87103
</form>

0 commit comments

Comments
 (0)