Skip to content

Commit 68609b0

Browse files
PR comments
1 parent df0a145 commit 68609b0

File tree

4 files changed

+29
-8
lines changed

4 files changed

+29
-8
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.deletingRow {
2+
opacity: 0.5;
3+
pointer-events: none;
4+
}

src/components/ControlPlane/ManagedResources.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { Resource } from '../../utils/removeManagedFieldsAndFilterData.ts';
1919
import { ManagedResourceItem } from '../../lib/shared/types.ts';
2020
import { ManagedResourceDeleteDialog } from '../Dialogs/ManagedResourceDeleteDialog.tsx';
2121
import { RowActionsMenu } from './ManagedResourcesActionMenu.tsx';
22+
import styles from './ManagedResources.module.css';
2223

2324
const getItemKey = (item: ManagedResourceItem): string => `${item.kind}-${item.metadata.name}`;
2425

@@ -173,7 +174,7 @@ export function ManagedResources() {
173174
item: item,
174175
conditionSyncedMessage: conditionSynced?.message ?? conditionSynced?.reason ?? '',
175176
conditionReadyMessage: conditionReady?.message ?? conditionReady?.reason ?? '',
176-
style: isDeleting ? { opacity: 0.5, pointerEvents: 'none' } : undefined,
177+
className: isDeleting ? styles.deletingRow : undefined,
177178
};
178179
}),
179180
) ?? [];

src/components/Dialogs/ManagedResourceDeleteDialog.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ export const ManagedResourceDeleteDialog: FC<Props> = ({ kindMapping, open, onCl
4444
}
4545
}, [open]);
4646

47-
const { apiVersion, resourceName, pluralKind } = useMemo(
47+
const { apiVersion, resourceName, pluralKind, namespace } = useMemo(
4848
() => ({
49+
namespace: item?.metadata?.namespace ?? '',
4950
apiVersion: item?.apiVersion ?? '',
5051
resourceName: item?.metadata?.name ?? '',
5152
pluralKind: item ? getPluralKind(item, kindMapping) : '',
@@ -60,11 +61,11 @@ export const ManagedResourceDeleteDialog: FC<Props> = ({ kindMapping, open, onCl
6061
const isConfirmed = confirmationText === resourceName;
6162

6263
const { trigger: deleteTrigger } = useApiResourceMutation<DeleteManagedResourceType>(
63-
DeleteMCPManagedResource(apiVersion, pluralKind, resourceName),
64+
DeleteMCPManagedResource(apiVersion, pluralKind, resourceName, namespace),
6465
);
6566

6667
const { trigger: patchTrigger } = useApiResourceMutation<undefined>(
67-
PatchResourceForForceDeletion(apiVersion, pluralKind, resourceName),
68+
PatchResourceForForceDeletion(apiVersion, pluralKind, resourceName, namespace),
6869
);
6970

7071
const handleForceDeletionChange = () => {

src/lib/api/types/crate/deleteResource.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,19 @@ export const PatchResourceForForceDeletionBody = {
1313

1414
export const PatchResourceForForceDeletion = (
1515
apiVersion: string,
16-
kind: string,
16+
pluralKind: string,
1717
resourceName: string,
18+
namespace?: string,
1819
): Resource<undefined> => {
20+
// If namespace is provided, use namespaced path; otherwise, use cluster-scoped path
21+
const basePath = `/apis/${apiVersion}`;
22+
23+
const path = namespace
24+
? `${basePath}/namespaces/${namespace}/${pluralKind}/${resourceName}`
25+
: `${basePath}/${pluralKind}/${resourceName}`;
26+
1927
return {
20-
path: `/apis/${apiVersion}/${kind}/${resourceName}/`,
28+
path: path,
2129
method: 'PATCH',
2230
jq: undefined,
2331
body: JSON.stringify(PatchResourceForForceDeletionBody),
@@ -26,11 +34,18 @@ export const PatchResourceForForceDeletion = (
2634

2735
export const DeleteMCPManagedResource = (
2836
apiVersion: string,
29-
kind: string,
37+
pluralKind: string,
3038
resourceName: string,
39+
namespace?: string,
3140
): Resource<undefined> => {
41+
// If namespace is provided, use namespaced path; otherwise, use cluster-scoped path
42+
const basePath = `/apis/${apiVersion}`;
43+
44+
const path = namespace
45+
? `${basePath}/namespaces/${namespace}/${pluralKind}/${resourceName}`
46+
: `${basePath}/${pluralKind}/${resourceName}`;
3247
return {
33-
path: `/apis/${apiVersion}/${kind}/${resourceName}/`,
48+
path: path,
3449
method: 'DELETE',
3550
jq: undefined,
3651
body: undefined,

0 commit comments

Comments
 (0)