Skip to content

Commit d208d7e

Browse files
authored
Merge pull request #1660 from jumpserver/pr@dev@fix_acl_reject_toast
fix(chen): toast ACL command rejection
2 parents 09cbdc5 + 19283ca commit d208d7e

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

‎ui/chen/composables/useChenQueryConsole.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {
66
ChenQueryConsoleTab,
77
ChenQueryLikeWorkspaceTab,
88
ChenQueryResultTab,
9+
ChenSqlExecutionError,
910
ChenTableStructureWorkspaceTab,
1011
ChenWorkspaceTab
1112
} from "~/chen/types";
@@ -57,6 +58,7 @@ export function useChenQueryConsole(
5758
) => boolean | void,
5859
options: {
5960
onLog?: (tab: ChenWorkspaceTab, line: unknown, content: string) => void;
61+
onError?: (tab: ChenQueryLikeWorkspaceTab, error: ChenSqlExecutionError) => void;
6062
translate?: (key: string) => string;
6163
} = {}
6264
) {
@@ -270,16 +272,18 @@ export function useChenQueryConsole(
270272
case "sql_error":
271273
if ((tab.kind === "query" || tab.kind === "console") && packet.data && typeof packet.data === "object") {
272274
const message = String(packet.data.message || "SQL execution failed");
273-
tab.lastSqlError = {
275+
const sqlError: ChenSqlExecutionError = {
274276
...packet.data,
275277
message
276278
};
279+
tab.lastSqlError = sqlError;
277280
if (tab.kind === "console") {
278281
const entry = activeConsoleEntry(tab);
279282
if (entry) entry.status = "error";
280283
} else {
281284
appendLog(tab, { ...packet.data, level: 0, message });
282285
}
286+
if (packet.data.kind === "acl") options.onError?.(tab, sqlError);
283287
}
284288
break;
285289
case "update_state": {

‎ui/chen/workspaces/DatabaseSessionSurface.vue‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,16 @@ function clearLogConsole() {
340340
unreadLogErrorCount.value = 0;
341341
}
342342
343-
const queryConsole = useChenQueryConsole(sendConsoleAction, { onLog: appendLogConsoleEntry, translate: t });
343+
const queryConsole = useChenQueryConsole(sendConsoleAction, {
344+
onLog: appendLogConsoleEntry,
345+
onError: (_tab, error) => {
346+
addErrorToast({
347+
title: error.title || t("Chen.Message"),
348+
...(error.message && error.message !== error.title ? { description: error.message } : {})
349+
});
350+
},
351+
translate: t
352+
});
344353
const session = useChenSession({
345354
authenticate: auth.authenticate,
346355
translate: t,

0 commit comments

Comments
 (0)