@telamonjs/ui 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -0
- package/README.md +2 -2
- package/dist/components/charts/BarChart.js +5 -1
- package/dist/components/dialog/confirm-action-dialog.d.ts +47 -15
- package/dist/components/dialog/confirm-action-dialog.js +33 -21
- package/dist/components/forms/AdminForm.js +2 -1
- package/dist/data/InfiniteList.js +2 -4
- package/dist/data/MobileCard.js +4 -1
- package/dist/data/VirtualDataTable.js +4 -1
- package/dist/data/datatable/TableDesktopView.js +2 -5
- package/dist/data/row-click.d.ts +10 -0
- package/dist/data/row-click.js +11 -0
- package/dist/exports/types-constants.d.ts +1 -1
- package/dist/exports/types-constants.js +1 -1
- package/dist/i18n/messages/en/index.d.ts +1 -0
- package/dist/i18n/messages/en/list.d.ts +1 -0
- package/dist/i18n/messages/en/list.js +1 -0
- package/dist/i18n/messages/en/queue.js +1 -1
- package/dist/i18n/messages/es/index.d.ts +1 -0
- package/dist/i18n/messages/es/list.d.ts +1 -0
- package/dist/i18n/messages/es/list.js +1 -0
- package/dist/i18n/messages/pt-BR/index.d.ts +8 -7
- package/dist/i18n/messages/pt-BR/list.d.ts +1 -0
- package/dist/i18n/messages/pt-BR/list.js +1 -0
- package/dist/i18n/messages/pt-BR/queue.d.ts +7 -7
- package/dist/i18n/messages/pt-BR/queue.js +7 -7
- package/dist/i18n/use-t.d.ts +8 -7
- package/dist/pages/list-page/ListPageTable.d.ts +1 -1
- package/dist/pages/list-page/ListPageTable.js +1 -1
- package/dist/pages/list-page/useDialogUrlSync.d.ts +10 -4
- package/dist/pages/list-page/useDialogUrlSync.js +7 -11
- package/dist/queue/components/DispatchJobModal.js +5 -2
- package/dist/queue/components/JobDetailPage.d.ts +8 -0
- package/dist/queue/components/JobDetailPage.js +19 -11
- package/dist/queue/components/QueueDashboard.js +3 -1
- package/dist/queue/components/QueueTabbedDashboard.d.ts +2 -1
- package/dist/queue/components/QueueTabbedDashboard.js +2 -24
- package/dist/queue/components/QueuesTable.js +342 -275
- package/dist/queue/components/jobs-list-modal/job-row.js +1 -1
- package/dist/queue/components/labels-context.d.ts +9 -1
- package/dist/queue/components/labels-context.js +3 -2
- package/dist/queue/components/labels-provider.d.ts +11 -0
- package/dist/queue/components/labels-provider.js +35 -0
- package/dist/queue/components/tabs/ConfiguracaoTab.js +4 -4
- package/dist/queue/components/tabs/TempoRealTab.js +24 -6
- package/dist/queue/components/tabs/historico/history-job-row.js +1 -1
- package/dist/queue/lib/action-message.d.ts +3 -2
- package/dist/queue/lib/action-message.js +2 -2
- package/dist/queue/types.d.ts +3 -0
- package/dist/types/actions.d.ts +9 -1
- package/dist/types/crud.d.ts +6 -3
- package/package.json +2 -2
|
@@ -187,9 +187,9 @@ var queue = {
|
|
|
187
187
|
},
|
|
188
188
|
dispatch: {
|
|
189
189
|
invalidJson: "JSON inv\xE1lido",
|
|
190
|
-
notDispatchable: "Este job
|
|
191
|
-
requiredFields: "Campos
|
|
192
|
-
dispatched: "Job {name} adicionado
|
|
190
|
+
notDispatchable: "Este job n\xE3o pode ser disparado manualmente",
|
|
191
|
+
requiredFields: "Campos obrigat\xF3rios: {fields}",
|
|
192
|
+
dispatched: "Job {name} adicionado \xE0 fila",
|
|
193
193
|
dispatchedId: "ID: {id}",
|
|
194
194
|
dispatchError: "Erro ao disparar job",
|
|
195
195
|
unknownError: "Erro desconhecido",
|
|
@@ -197,16 +197,16 @@ var queue = {
|
|
|
197
197
|
subtitle: "Disparo manual",
|
|
198
198
|
close: "Fechar",
|
|
199
199
|
queueLabel: "Queue: {name}",
|
|
200
|
-
notDispatchableInfo: "Este job
|
|
200
|
+
notDispatchableInfo: "Este job n\xE3o pode ser disparado manualmente. Ele \xE9 executado automaticamente pelo sistema (cron, eventos, etc.).",
|
|
201
201
|
inputDataTitle: "Dados de Entrada",
|
|
202
|
-
formMode: "
|
|
202
|
+
formMode: "Formul\xE1rio",
|
|
203
203
|
jsonMode: "JSON",
|
|
204
|
-
noInputNeeded: 'Este job
|
|
204
|
+
noInputNeeded: 'Este job n\xE3o requer dados de entrada. Clique em "Executar Agora" para disparar.',
|
|
205
205
|
executeNow: "Executar Agora",
|
|
206
206
|
defaultFields: {
|
|
207
207
|
rotaId: "ID da rota a processar",
|
|
208
208
|
ids: "Array de IDs para processar",
|
|
209
|
-
relatorioId: "ID do
|
|
209
|
+
relatorioId: "ID do relat\xF3rio",
|
|
210
210
|
produtoId: "ID do produto",
|
|
211
211
|
tipo: "Tipo de consulta",
|
|
212
212
|
smsId: "ID do SMS agendado",
|
package/dist/i18n/use-t.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ export declare function useTelamonjsT(): import("next-intl")._Translator<import(
|
|
|
53
53
|
readonly empty: "Nenhum item encontrado";
|
|
54
54
|
readonly emptyDescription: "Tente ajustar os filtros ou adicione novos itens.";
|
|
55
55
|
readonly emptyDescriptionNewItem: "Comece adicionando um novo item.";
|
|
56
|
+
readonly emptyDescriptionNoCreate: "Ainda não há itens para exibir.";
|
|
56
57
|
readonly noResults: "Nenhum resultado encontrado";
|
|
57
58
|
readonly noResultsDescription: "Tente ajustar a busca ou os filtros.";
|
|
58
59
|
readonly selectAll: "Selecionar todos";
|
|
@@ -769,9 +770,9 @@ export declare function useTelamonjsT(): import("next-intl")._Translator<import(
|
|
|
769
770
|
};
|
|
770
771
|
readonly dispatch: {
|
|
771
772
|
readonly invalidJson: "JSON inválido";
|
|
772
|
-
readonly notDispatchable: "Este job
|
|
773
|
-
readonly requiredFields: "Campos
|
|
774
|
-
readonly dispatched: "Job {name} adicionado
|
|
773
|
+
readonly notDispatchable: "Este job não pode ser disparado manualmente";
|
|
774
|
+
readonly requiredFields: "Campos obrigatórios: {fields}";
|
|
775
|
+
readonly dispatched: "Job {name} adicionado à fila";
|
|
775
776
|
readonly dispatchedId: "ID: {id}";
|
|
776
777
|
readonly dispatchError: "Erro ao disparar job";
|
|
777
778
|
readonly unknownError: "Erro desconhecido";
|
|
@@ -779,16 +780,16 @@ export declare function useTelamonjsT(): import("next-intl")._Translator<import(
|
|
|
779
780
|
readonly subtitle: "Disparo manual";
|
|
780
781
|
readonly close: "Fechar";
|
|
781
782
|
readonly queueLabel: "Queue: {name}";
|
|
782
|
-
readonly notDispatchableInfo: "Este job
|
|
783
|
+
readonly notDispatchableInfo: "Este job não pode ser disparado manualmente. Ele é executado automaticamente pelo sistema (cron, eventos, etc.).";
|
|
783
784
|
readonly inputDataTitle: "Dados de Entrada";
|
|
784
|
-
readonly formMode: "
|
|
785
|
+
readonly formMode: "Formulário";
|
|
785
786
|
readonly jsonMode: "JSON";
|
|
786
|
-
readonly noInputNeeded: "Este job
|
|
787
|
+
readonly noInputNeeded: "Este job não requer dados de entrada. Clique em \"Executar Agora\" para disparar.";
|
|
787
788
|
readonly executeNow: "Executar Agora";
|
|
788
789
|
readonly defaultFields: {
|
|
789
790
|
readonly rotaId: "ID da rota a processar";
|
|
790
791
|
readonly ids: "Array de IDs para processar";
|
|
791
|
-
readonly relatorioId: "ID do
|
|
792
|
+
readonly relatorioId: "ID do relatório";
|
|
792
793
|
readonly produtoId: "ID do produto";
|
|
793
794
|
readonly tipo: "Tipo de consulta";
|
|
794
795
|
readonly smsId: "ID do SMS agendado";
|
|
@@ -30,7 +30,7 @@ interface ListPageTableProps<TData> {
|
|
|
30
30
|
/** True when embedded mode with list.infiniteScroll enabled */
|
|
31
31
|
isInfiniteScroll: boolean;
|
|
32
32
|
infiniteQuery: UseInfiniteListQueryReturn<TData>;
|
|
33
|
-
/** True when dialogs.create
|
|
33
|
+
/** True when dialogs.create survives permissions/form (enables the Add button and the "start by adding" empty copy) */
|
|
34
34
|
hasCreateDialog: boolean;
|
|
35
35
|
/** Already resolved: undefined when no view dialog is configured */
|
|
36
36
|
onRowClick: ((row: TData) => void) | undefined;
|
|
@@ -37,7 +37,7 @@ function ListPageTable({
|
|
|
37
37
|
const t = useTelamonjsT();
|
|
38
38
|
const text = useText();
|
|
39
39
|
const emptyTitle = hasActiveQuery ? t("list.noResults") : text(list.emptyTitle) ?? t("list.empty");
|
|
40
|
-
const emptyDescription = hasActiveQuery ? t("list.noResultsDescription") : text(list.emptyDescription) ?? t("list.emptyDescriptionNewItem");
|
|
40
|
+
const emptyDescription = hasActiveQuery ? t("list.noResultsDescription") : text(list.emptyDescription) ?? t(hasCreateDialog ? "list.emptyDescriptionNewItem" : "list.emptyDescriptionNoCreate");
|
|
41
41
|
const retry = () => void onRefresh();
|
|
42
42
|
const columns = useMemo(
|
|
43
43
|
() => resolveColumns(
|
|
@@ -46,10 +46,16 @@ interface UseDialogUrlSyncParams {
|
|
|
46
46
|
* via `router.replace` (no history spam), merging into existing params so
|
|
47
47
|
* `?tab`/`?page`/`?sort`/filters are never clobbered.
|
|
48
48
|
*
|
|
49
|
-
* Arbitration
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
49
|
+
* Arbitration compares what the URL *asks for* (the dialog state derived from
|
|
50
|
+
* it) with what it asked for at the last reconciliation: if that request changed
|
|
51
|
+
* the URL wins; otherwise the state changed and we write it out. The equality
|
|
52
|
+
* guard short-circuits every potential ping-pong. The mount/deep-link case falls
|
|
53
|
+
* out for free (the URL leads, state catches up) — no mount-only effect.
|
|
54
|
+
*
|
|
55
|
+
* The comparison is on the request, not on the spelling of the params: the set
|
|
56
|
+
* of configured params can change without any navigation (`permissions` adding
|
|
57
|
+
* `edit`/`create` once the session arrives), and that must not be read as "the
|
|
58
|
+
* URL moved" — it reopened a dialog the user had just closed.
|
|
53
59
|
*
|
|
54
60
|
* @internal Sibling of useListPageUrlSync (which owns page/sort/filter params).
|
|
55
61
|
*/
|
|
@@ -22,9 +22,6 @@ function deriveStateFromUrl(params, getParam) {
|
|
|
22
22
|
}
|
|
23
23
|
return { type: null, id: null };
|
|
24
24
|
}
|
|
25
|
-
function urlKeyFor(params, getParam) {
|
|
26
|
-
return [params.view, params.edit, params.create].filter((p) => Boolean(p)).map((p) => `${p}=${getParam(p) ?? ""}`).join("&");
|
|
27
|
-
}
|
|
28
25
|
function useDialogUrlSync({
|
|
29
26
|
params,
|
|
30
27
|
state,
|
|
@@ -33,24 +30,23 @@ function useDialogUrlSync({
|
|
|
33
30
|
}) {
|
|
34
31
|
const { getParam, setParams } = useUrlSync();
|
|
35
32
|
const hasAnyParam = Boolean(params.view || params.edit || params.create);
|
|
36
|
-
const
|
|
37
|
-
const
|
|
33
|
+
const desiredFromUrl = deriveStateFromUrl(params, getParam);
|
|
34
|
+
const prevFromUrl = useRef(void 0);
|
|
38
35
|
const setParamsRef = useRef(setParams);
|
|
39
36
|
useEffect(() => {
|
|
40
37
|
setParamsRef.current = setParams;
|
|
41
38
|
});
|
|
42
39
|
useEffect(() => {
|
|
43
40
|
if (!hasAnyParam) return void 0;
|
|
44
|
-
const desiredFromUrl = deriveStateFromUrl(params, getParam);
|
|
45
41
|
if (dialogStateEquals(desiredFromUrl, state)) {
|
|
46
|
-
|
|
42
|
+
prevFromUrl.current = desiredFromUrl;
|
|
47
43
|
return void 0;
|
|
48
44
|
}
|
|
49
|
-
const urlChanged =
|
|
45
|
+
const urlChanged = !prevFromUrl.current || !dialogStateEquals(desiredFromUrl, prevFromUrl.current);
|
|
50
46
|
if (urlChanged) {
|
|
51
47
|
const isOpening = desiredFromUrl.type !== null;
|
|
52
48
|
if (!isOpening && state.type !== null && !params[state.type]) {
|
|
53
|
-
|
|
49
|
+
prevFromUrl.current = desiredFromUrl;
|
|
54
50
|
return void 0;
|
|
55
51
|
}
|
|
56
52
|
const isVisible = !rootRef || !rootRef.current || rootRef.current.offsetParent !== null;
|
|
@@ -58,7 +54,7 @@ function useDialogUrlSync({
|
|
|
58
54
|
dispatch({ kind: "syncFromUrl", next: desiredFromUrl });
|
|
59
55
|
return void 0;
|
|
60
56
|
} else {
|
|
61
|
-
|
|
57
|
+
prevFromUrl.current = desiredFromUrl;
|
|
62
58
|
const updates = {};
|
|
63
59
|
if (params.view) {
|
|
64
60
|
updates[params.view] = state.type === "view" ? state.id : void 0;
|
|
@@ -80,7 +76,7 @@ function useDialogUrlSync({
|
|
|
80
76
|
);
|
|
81
77
|
return () => clearTimeout(timer);
|
|
82
78
|
}
|
|
83
|
-
}, [
|
|
79
|
+
}, [desiredFromUrl.type, desiredFromUrl.id, state, hasAnyParam]);
|
|
84
80
|
}
|
|
85
81
|
export {
|
|
86
82
|
DIALOG_CLOSE_URL_DELAY_MS,
|
|
@@ -8,6 +8,7 @@ import { logger } from "../../utils/logger.js";
|
|
|
8
8
|
import { toast } from "sonner";
|
|
9
9
|
import { useQueueApi } from "../api/provider.js";
|
|
10
10
|
import { useTelamonjsT } from "../../i18n/use-t.js";
|
|
11
|
+
import { useQueueLabels } from "./labels-context.js";
|
|
11
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
13
|
function getDefaultKnownSchemaFields(t) {
|
|
13
14
|
return {
|
|
@@ -77,6 +78,7 @@ function DispatchJobModal({
|
|
|
77
78
|
const defaultKnownSchemaFields = getDefaultKnownSchemaFields(t);
|
|
78
79
|
const resolvedSchemaFields = knownSchemaFields ?? defaultKnownSchemaFields;
|
|
79
80
|
const api = useQueueApi();
|
|
81
|
+
const { jobLabel } = useQueueLabels();
|
|
80
82
|
const [dispatching, setDispatching] = useState(false);
|
|
81
83
|
const [formData, setFormData] = useState({});
|
|
82
84
|
const [jsonMode, setJsonMode] = useState(false);
|
|
@@ -93,6 +95,7 @@ function DispatchJobModal({
|
|
|
93
95
|
setJsonMode(false);
|
|
94
96
|
}
|
|
95
97
|
if (!job) return null;
|
|
98
|
+
const title = jobLabel(job.name, job.displayName);
|
|
96
99
|
const validateJson = (text) => {
|
|
97
100
|
try {
|
|
98
101
|
JSON.parse(text);
|
|
@@ -126,7 +129,7 @@ function DispatchJobModal({
|
|
|
126
129
|
queueName: job.name,
|
|
127
130
|
data
|
|
128
131
|
});
|
|
129
|
-
toast.success(t("queue.dispatch.dispatched", { name:
|
|
132
|
+
toast.success(t("queue.dispatch.dispatched", { name: title }), {
|
|
130
133
|
description: t("queue.dispatch.dispatchedId", { id: result.jobId })
|
|
131
134
|
});
|
|
132
135
|
onSuccess?.();
|
|
@@ -191,7 +194,7 @@ function DispatchJobModal({
|
|
|
191
194
|
children: job.module.toUpperCase()
|
|
192
195
|
}
|
|
193
196
|
),
|
|
194
|
-
/* @__PURE__ */ jsx("span", { className: "font-medium", children:
|
|
197
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: title })
|
|
195
198
|
] }),
|
|
196
199
|
/* @__PURE__ */ jsxs("div", { className: "bg-muted/50 rounded-lg p-4 space-y-2", children: [
|
|
197
200
|
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* - Auto-fetch: when jobName is passed, fetches config+history via hooks
|
|
11
11
|
*/
|
|
12
12
|
import React from 'react';
|
|
13
|
+
import type { I18nText } from '../../i18n/msg';
|
|
13
14
|
import type { JobConfig, JobHistoryEntry } from '../types';
|
|
14
15
|
export interface JobDetailPageProps {
|
|
15
16
|
/** Job name — auto-fetches config+history via hooks */
|
|
@@ -31,6 +32,13 @@ export interface JobDetailPageProps {
|
|
|
31
32
|
onBack?: () => void;
|
|
32
33
|
/** Callback after successful update (e.g. router.refresh()) */
|
|
33
34
|
onRefresh?: () => void;
|
|
35
|
+
/** Module key → badge label — pass the same value as to `QueueTabbedDashboard`. */
|
|
36
|
+
moduleLabels?: Record<string, I18nText>;
|
|
37
|
+
/**
|
|
38
|
+
* Job label override, as on `QueueTabbedDashboard`: `undefined` falls back
|
|
39
|
+
* to the contract's `displayName`, then to the formatted job name.
|
|
40
|
+
*/
|
|
41
|
+
jobLabel?: (jobName: string) => I18nText | undefined;
|
|
34
42
|
}
|
|
35
43
|
/**
|
|
36
44
|
* Main export — auto-provider + auto-fetch
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
// src/queue/components/JobDetailPage.tsx
|
|
4
|
-
import { useState, useMemo } from "react";
|
|
4
|
+
import { useId, useState, useMemo } from "react";
|
|
5
5
|
import {
|
|
6
6
|
ArrowLeft,
|
|
7
7
|
Calendar,
|
|
@@ -47,6 +47,8 @@ import { useTelamonjsT } from "../../i18n/use-t.js";
|
|
|
47
47
|
import { useFormat } from "../../i18n/use-format.js";
|
|
48
48
|
import { useDateFnsLocale } from "../../i18n/use-date-fns-locale.js";
|
|
49
49
|
import { INACTIVE_BADGE } from "./job-shared.js";
|
|
50
|
+
import { useQueueLabels } from "./labels-context.js";
|
|
51
|
+
import { QueueLabelsProvider } from "./labels-provider.js";
|
|
50
52
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
51
53
|
function WithAutoProvider({
|
|
52
54
|
apiUrl,
|
|
@@ -131,6 +133,10 @@ function JobDetailPageUI({
|
|
|
131
133
|
const t = useTelamonjsT();
|
|
132
134
|
const format = useFormat();
|
|
133
135
|
const dateFnsLocale = useDateFnsLocale();
|
|
136
|
+
const { jobLabel, jobDescription, moduleLabel } = useQueueLabels();
|
|
137
|
+
const title = jobLabel(config.jobName);
|
|
138
|
+
const contractDescription = jobDescription(config.jobName);
|
|
139
|
+
const statusId = useId();
|
|
134
140
|
const toggleJobMutation = useToggleJobEnabled();
|
|
135
141
|
const updateJobMutation = useUpdateJobConfig();
|
|
136
142
|
const [isToggling, setIsToggling] = useState(false);
|
|
@@ -153,7 +159,7 @@ function JobDetailPageUI({
|
|
|
153
159
|
setEnabled(result.enabled);
|
|
154
160
|
toast.success(result.enabled ? t("queue.jobDetailPage.activated") : t("queue.jobDetailPage.deactivated"), {
|
|
155
161
|
description: t("queue.jobDetailPage.statusChangedSuccess", {
|
|
156
|
-
name:
|
|
162
|
+
name: title,
|
|
157
163
|
status: result.enabled ? t("queue.jobDetailPage.statusActivated") : t("queue.jobDetailPage.statusDeactivated")
|
|
158
164
|
})
|
|
159
165
|
});
|
|
@@ -227,9 +233,11 @@ function JobDetailPageUI({
|
|
|
227
233
|
}
|
|
228
234
|
),
|
|
229
235
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
230
|
-
/* @__PURE__ */ jsx("h1", { className: "text-3xl font-bold tracking-tight", children:
|
|
236
|
+
/* @__PURE__ */ jsx("h1", { className: "text-3xl font-bold tracking-tight", children: title }),
|
|
237
|
+
contractDescription && contractDescription !== title && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground mt-1 text-sm", children: contractDescription }),
|
|
231
238
|
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex items-center gap-2", children: [
|
|
232
|
-
/* @__PURE__ */ jsx(
|
|
239
|
+
/* @__PURE__ */ jsx("code", { className: "bg-muted rounded px-1.5 py-0.5 font-mono text-xs", children: config.jobName }),
|
|
240
|
+
/* @__PURE__ */ jsx(Badge, { variant: "outline", children: moduleLabel(config.module) ?? config.module }),
|
|
233
241
|
/* @__PURE__ */ jsx(
|
|
234
242
|
Badge,
|
|
235
243
|
{
|
|
@@ -256,10 +264,11 @@ function JobDetailPageUI({
|
|
|
256
264
|
{
|
|
257
265
|
checked: enabled,
|
|
258
266
|
onCheckedChange: handleToggle,
|
|
259
|
-
disabled: isToggling
|
|
267
|
+
disabled: isToggling,
|
|
268
|
+
"aria-labelledby": statusId
|
|
260
269
|
}
|
|
261
270
|
),
|
|
262
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: enabled ? t("queue.jobDetailPage.active") : t("queue.jobDetailPage.inactive") })
|
|
271
|
+
/* @__PURE__ */ jsx("span", { id: statusId, className: "text-sm font-medium", children: enabled ? t("queue.jobDetailPage.active") : t("queue.jobDetailPage.inactive") })
|
|
263
272
|
] })
|
|
264
273
|
] }),
|
|
265
274
|
/* @__PURE__ */ jsxs(Card, { children: [
|
|
@@ -427,12 +436,11 @@ function JobDetailPageUI({
|
|
|
427
436
|
] });
|
|
428
437
|
}
|
|
429
438
|
function JobDetailPage(props) {
|
|
430
|
-
const { apiUrl, ...rest } = props;
|
|
439
|
+
const { apiUrl, moduleLabels, jobLabel, ...rest } = props;
|
|
431
440
|
const existingAdapter = useQueueApiOptional();
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
}
|
|
435
|
-
return /* @__PURE__ */ jsx(WithAutoProvider, { apiUrl, children: /* @__PURE__ */ jsx(JobDetailPageInner, { ...rest }) });
|
|
441
|
+
const page = /* @__PURE__ */ jsx(QueueLabelsProvider, { moduleLabels, jobLabel, children: /* @__PURE__ */ jsx(JobDetailPageInner, { ...rest }) });
|
|
442
|
+
if (existingAdapter) return page;
|
|
443
|
+
return /* @__PURE__ */ jsx(WithAutoProvider, { apiUrl, children: page });
|
|
436
444
|
}
|
|
437
445
|
export {
|
|
438
446
|
JobDetailPage as default
|
|
@@ -14,6 +14,7 @@ import DashboardHeader from "./DashboardHeader.js";
|
|
|
14
14
|
import RedisMetrics from "./RedisMetrics.js";
|
|
15
15
|
import { useTelamonjsT } from "../../i18n/use-t.js";
|
|
16
16
|
import { actionDoneMessage } from "../lib/action-message.js";
|
|
17
|
+
import { useQueueLabels } from "./labels-context.js";
|
|
17
18
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
18
19
|
function QueueDashboard({
|
|
19
20
|
pollInterval = 1e4,
|
|
@@ -21,6 +22,7 @@ function QueueDashboard({
|
|
|
21
22
|
settingsHref
|
|
22
23
|
}) {
|
|
23
24
|
const t = useTelamonjsT();
|
|
25
|
+
const { jobLabel } = useQueueLabels();
|
|
24
26
|
const [historyModalOpen, setHistoryModalOpen] = useState(false);
|
|
25
27
|
const { data: stats, isLoading, refetch } = useQueueStats(pollInterval);
|
|
26
28
|
const queueActionMutation = useQueueAction();
|
|
@@ -28,7 +30,7 @@ function QueueDashboard({
|
|
|
28
30
|
try {
|
|
29
31
|
const result = await queueActionMutation.mutateAsync(action);
|
|
30
32
|
if (result.success) {
|
|
31
|
-
toast.success(actionDoneMessage(t, action, result));
|
|
33
|
+
toast.success(actionDoneMessage(t, action, result, jobLabel(action.queueName)));
|
|
32
34
|
} else {
|
|
33
35
|
toast.error(result.message || t("queue.dashboard.actionFailed"));
|
|
34
36
|
}
|
|
@@ -27,7 +27,8 @@ export interface QueueTabbedDashboardProps {
|
|
|
27
27
|
moduleLabels?: Record<string, I18nText>;
|
|
28
28
|
/**
|
|
29
29
|
* Job label override: job name → label, or `undefined` to fall back to the
|
|
30
|
-
* job contract's `displayName
|
|
30
|
+
* job contract's `displayName` (contract `label`, else its `description`),
|
|
31
|
+
* then to the name formatted by the dashboard.
|
|
31
32
|
* Used in queue rows, timeline and history rows, job details and modal titles.
|
|
32
33
|
*/
|
|
33
34
|
jobLabel?: (jobName: string) => I18nText | undefined;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
// src/queue/components/QueueTabbedDashboard.tsx
|
|
4
4
|
import { useState, useMemo, lazy, Suspense, useCallback } from "react";
|
|
5
|
-
import { useQuery } from "@tanstack/react-query";
|
|
6
5
|
import { useSearchParams, useRouter, usePathname } from "next/navigation";
|
|
7
6
|
import { getSession } from "next-auth/react";
|
|
8
7
|
import { Radio, Settings, Database, History } from "lucide-react";
|
|
@@ -11,11 +10,10 @@ import { AdminHeader } from "../../layouts/shell/AdminHeader.js";
|
|
|
11
10
|
import { AdminTabs } from "../../layouts/shell/AdminTabs.js";
|
|
12
11
|
import { PageSkeleton } from "../../components/skeletons/index.js";
|
|
13
12
|
import { useTelamonjsT } from "../../i18n/use-t.js";
|
|
14
|
-
import { QueueApiProvider,
|
|
13
|
+
import { QueueApiProvider, useQueueApiOptional } from "../api/provider.js";
|
|
15
14
|
import { createNestJSAdapter } from "../api/adapters/nestjs-adapter.js";
|
|
16
15
|
import { QueueReadOnlyContext } from "./read-only-context.js";
|
|
17
|
-
import {
|
|
18
|
-
import { QueueLabelsContext } from "./labels-context.js";
|
|
16
|
+
import { QueueLabelsProvider } from "./labels-provider.js";
|
|
19
17
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
20
18
|
var TempoRealTab = lazy(() => import("./tabs/TempoRealTab.js"));
|
|
21
19
|
var ConfiguracaoTab = lazy(() => import("./tabs/ConfiguracaoTab.js"));
|
|
@@ -135,26 +133,6 @@ function QueueTabbedDashboardWithUrlSync(props) {
|
|
|
135
133
|
}
|
|
136
134
|
);
|
|
137
135
|
}
|
|
138
|
-
var toDisplayNames = (stats) => Object.fromEntries(stats.queues.map((q) => [q.name, q.displayName]));
|
|
139
|
-
function QueueLabelsProvider({
|
|
140
|
-
moduleLabels,
|
|
141
|
-
jobLabel,
|
|
142
|
-
children
|
|
143
|
-
}) {
|
|
144
|
-
const api = useQueueApi();
|
|
145
|
-
const { data: displayNames } = useQuery({
|
|
146
|
-
meta: LIB_QUERY_META,
|
|
147
|
-
queryKey: ["queue", "stats"],
|
|
148
|
-
queryFn: () => api.getStats(),
|
|
149
|
-
select: toDisplayNames,
|
|
150
|
-
staleTime: Infinity
|
|
151
|
-
});
|
|
152
|
-
const value = useMemo(
|
|
153
|
-
() => ({ moduleLabels, jobLabel, displayNames }),
|
|
154
|
-
[moduleLabels, jobLabel, displayNames]
|
|
155
|
-
);
|
|
156
|
-
return /* @__PURE__ */ jsx(QueueLabelsContext.Provider, { value, children });
|
|
157
|
-
}
|
|
158
136
|
function WithAutoProvider({
|
|
159
137
|
apiUrl,
|
|
160
138
|
children
|