Skip to content

Commit

Permalink
fix(2031): handle 403
Browse files Browse the repository at this point in the history
  • Loading branch information
milan-deepfence committed Nov 28, 2023
1 parent c27d162 commit bb872d9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,10 @@ const ActionDropdown = ({
};

const AIIntegrationTable = () => {
const { data } = useListAIIntegrations();
const {
data: { data, message },
} = useListAIIntegrations();

const [idToDelete, setIdToDelete] = useState<number | null>(null);
const [idToMakeDefault, setIdToMakeDefault] = useState<number | null>(null);

Expand Down Expand Up @@ -450,10 +453,14 @@ const AIIntegrationTable = () => {
return columns;
}, []);

if (message && message.length) {
return <p className="text-p7 dark:text-status-error">{message}</p>;
}

return (
<>
<Table
data={data.data}
data={data}
columns={columns}
enableColumnResizing
noDataElement={
Expand Down
19 changes: 15 additions & 4 deletions deepfence_frontend/apps/dashboard/src/queries/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ export const settingQueries = createQueryKeys('setting', {
logsCountPromise,
]);

if (!logsCount.ok) {
throw logsCount.error;
}

if (!userResponse.ok) {
if (userResponse.error.response.status === 400) {
const { message } = await getResponseErrors(userResponse.error);
Expand All @@ -79,6 +75,21 @@ export const settingQueries = createQueryKeys('setting', {
throw userResponse.error;
}

if (!logsCount.ok) {
if (logsCount.error.response.status === 400) {
const { message } = await getResponseErrors(logsCount.error);
return {
message,
};
} else if (logsCount.error.response.status === 403) {
const message = await get403Message(logsCount.error);
return {
message,
};
}
throw logsCount.error;
}

return {
data: userResponse.value,
pagination: {
Expand Down

0 comments on commit bb872d9

Please sign in to comment.