Skip to content

Commit ce331b3

Browse files
committed
feat: add loading state to deletion dialogs and set global API timeout
1 parent 1aa2351 commit ce331b3

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

src/App.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
BreadcrumbStore,
2424
DevtronProgressing,
2525
ErrorScreenManager,
26+
setGlobalAPITimeout,
2627
showError,
2728
URLS as CommonURLS,
2829
useUserEmail,
@@ -147,6 +148,8 @@ const App = () => {
147148
setValidating(false)
148149
defaultRedirection()
149150
}
151+
152+
setGlobalAPITimeout(window._env_.GLOBAL_API_TIMEOUT)
150153
}, [])
151154

152155
const renderRoutesWithErrorBoundary = () =>

src/components/common/ClusterNotReachableDialog/ClusterNotReachableDialog.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ import { ForceDeleteConfirmationModal } from '@devtron-labs/devtron-fe-common-li
1919
import { NON_CASCADE_DELETE_DIALOG_INTERNAL_MESSAGE } from '../../../config/constantMessaging'
2020
import { ClusterNotReachableDialogType } from './ClusterNotReachableDialog.type'
2121

22-
const ClusterNotReachableDialog = ({ clusterName, onClickCancel, onClickDelete }: ClusterNotReachableDialogType) => {
22+
const ClusterNotReachableDialog = ({
23+
clusterName,
24+
onClickCancel,
25+
onClickDelete,
26+
isDeleting,
27+
}: ClusterNotReachableDialogType) => {
2328
if (!clusterName) {
2429
return null
2530
}
@@ -34,6 +39,7 @@ const ClusterNotReachableDialog = ({ clusterName, onClickCancel, onClickDelete }
3439
</p>
3540
}
3641
onDelete={onClickDelete}
42+
isDeleting={isDeleting}
3743
closeConfirmationModal={onClickCancel}
3844
/>
3945
)

src/components/common/ClusterNotReachableDialog/ClusterNotReachableDialog.type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ export interface ClusterNotReachableDialogType {
1818
clusterName: string
1919
onClickCancel: () => void
2020
onClickDelete: () => void
21+
isDeleting?: boolean
2122
}

src/components/v2/appDetails/sourceInfo/EnvironmentSelector.component.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ const EnvironmentSelectorComponent = ({
7676
const [forceDeleteDialogMessage, setForceDeleteDialogMessage] = useState<string>('')
7777
const [nonCascadeDeleteDialog, showNonCascadeDeleteDialog] = useState<boolean>(false)
7878
const [clusterName, setClusterName] = useState<string>('')
79+
const [isDeleteLoading, setIsDeleteLoading] = useState<boolean>(false)
80+
7981
const isGitops = appDetails?.deploymentAppType === DeploymentAppTypes.ARGO
8082
const isExternalArgo = appDetails.appType === AppType.EXTERNAL_ARGO_APP
8183
const isExternalFlux = appDetails.appType === AppType.EXTERNAL_FLUX_APP
@@ -150,6 +152,7 @@ const EnvironmentSelectorComponent = ({
150152

151153
async function deleteResourceAction(deleteAction: DELETE_ACTION) {
152154
try {
155+
setIsDeleteLoading(true)
153156
const response = await getDeleteApplicationApi(deleteAction)
154157
if (response.result.deleteResponse?.deleteInitiated || (isExternalApp && response.result?.success)) {
155158
setShowDeleteConfirmation(false)
@@ -179,6 +182,8 @@ const EnvironmentSelectorComponent = ({
179182
showForceDeleteDialog(true)
180183
}
181184
showError(error)
185+
} finally {
186+
setIsDeleteLoading(false)
182187
}
183188
}
184189

@@ -376,6 +381,7 @@ const EnvironmentSelectorComponent = ({
376381
handleDelete={handleDelete}
377382
toggleConfirmation={setShowDeleteConfirmation}
378383
isCreateValueView={false}
384+
disableButton={isDeleteLoading}
379385
/>
380386
)}
381387
</div>
@@ -387,6 +393,7 @@ const EnvironmentSelectorComponent = ({
387393
subtitle={forceDeleteDialogMessage}
388394
onDelete={handleForceDelete}
389395
closeConfirmationModal={closeForceConfirmationModal}
396+
isDeleting={isDeleteLoading}
390397
/>
391398
)}
392399

@@ -395,6 +402,7 @@ const EnvironmentSelectorComponent = ({
395402
clusterName={clusterName}
396403
onClickCancel={onClickHideNonCascadeDeletePopup}
397404
onClickDelete={onClickNonCascadeDelete}
405+
isDeleting={isDeleteLoading}
398406
/>
399407
)}
400408
</div>

0 commit comments

Comments
 (0)