Update authz logic for MI

This commit is contained in:
Tuan Dang
2023-12-05 17:46:50 +07:00
parent c91f6521c1
commit 6787c0eaaa
13 changed files with 209 additions and 115 deletions
@@ -244,6 +244,7 @@ export const AddMachineIdentityModal = ({
reset();
} catch (err) {
console.error(err);
const error = err as any;
const text = error?.response?.data?.message
?? `Failed to ${popUp?.machineIdentity?.data ? "updated" : "created"} machine identity`;
@@ -81,8 +81,11 @@ export const MachineIdentityTable = ({
});
} catch (err) {
console.error(err);
const error = err as any;
const text = error?.response?.data?.message ?? "Failed to update machine identity role"
createNotification({
text: "Failed to update machine identity role",
text,
type: "error"
});
}
@@ -35,7 +35,7 @@ export const MachineIdentitySection = withProjectPermission(
"upgradePlan"
] as const);
const onRemoveServiceTokenDataSubmit = async (machineId: string) => {
const onRemoveMachineIdentitySubmit = async (machineId: string) => {
try {
await deleteMutateAsync({
@@ -44,17 +44,20 @@ export const MachineIdentitySection = withProjectPermission(
});
createNotification({
text: "Successfully removed service account from project",
text: "Successfully removed machine identity from project",
type: "success"
});
handlePopUpClose("deleteMachineIdentity");
} catch (err) {
console.error(err);
createNotification({
text: "Failed to delete service account from project",
type: "error"
});
console.error(err);
const error = err as any;
const text = error?.response?.data?.message ?? "Failed to remove machine identity from project"
createNotification({
text,
type: "error"
});
}
}
@@ -96,7 +99,7 @@ export const MachineIdentitySection = withProjectPermission(
onChange={(isOpen) => handlePopUpToggle("deleteMachineIdentity", isOpen)}
deleteKey="confirm"
onDeleteApproved={() =>
onRemoveServiceTokenDataSubmit(
onRemoveMachineIdentitySubmit(
(popUp?.deleteMachineIdentity?.data as { machineId: string })?.machineId
)
}
@@ -89,8 +89,11 @@ export const MachineIdentityTable = ({
});
} catch (err) {
console.error(err);
const error = err as any;
const text = error?.response?.data?.message ?? "Failed to update machine identity role"
createNotification({
text: "Failed to update machine identity role",
text,
type: "error"
});
}