@plumile/backoffice-react 0.1.153 → 0.1.156
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/lib/esm/auth/login/loginPage.css.js +2 -0
- package/lib/esm/components/backoffice/columns/buildDataTableColumns.js +1 -0
- package/lib/esm/components/backoffice/columns/buildDataTableColumns.js.map +1 -1
- package/lib/esm/components/backoffice/detail/BackofficeRelationsSummaryGrid.js +1 -0
- package/lib/esm/components/backoffice/detail/BackofficeRelationsSummaryGrid.js.map +1 -1
- package/lib/esm/components/backoffice/detail/backofficeDetailRelationLink.css.js +0 -1
- package/lib/esm/components/backoffice/filters/BackofficeFilterAction.js +1 -0
- package/lib/esm/components/backoffice/filters/BackofficeFilterAction.js.map +1 -1
- package/lib/esm/components/backoffice/hub/BackofficeHubTemplate.js +1 -0
- package/lib/esm/components/backoffice/hub/BackofficeHubTemplate.js.map +1 -1
- package/lib/esm/components/backoffice/hub/backofficeHubTemplate.css.js +0 -2
- package/lib/esm/components/backoffice/layout/breadcrumb/BackofficeTopbarBreadcrumb.js +1 -0
- package/lib/esm/components/backoffice/layout/breadcrumb/BackofficeTopbarBreadcrumb.js.map +1 -1
- package/lib/esm/components/backoffice/links/BackofficeInlineLink.js +15 -14
- package/lib/esm/components/backoffice/links/BackofficeInlineLink.js.map +1 -1
- package/lib/esm/components/backoffice/links/BackofficeLink.js +9 -8
- package/lib/esm/components/backoffice/links/BackofficeLink.js.map +1 -1
- package/lib/esm/components/backoffice/refs/backofficeEntityIdRef.css.js +1 -0
- package/lib/esm/pages/BackofficeDashboardPage.helpers.js +2 -2
- package/lib/esm/pages/BackofficeDashboardPage.helpers.js.map +1 -1
- package/lib/esm/pages/BackofficeDashboardPage.js +38 -51
- package/lib/esm/pages/BackofficeDashboardPage.js.map +1 -1
- package/lib/esm/pages/BackofficeDashboardWidgetContent.js +97 -100
- package/lib/esm/pages/BackofficeDashboardWidgetContent.js.map +1 -1
- package/lib/esm/pages/BackofficeEntityDetailLayoutPage.js +110 -10
- package/lib/esm/pages/BackofficeEntityDetailLayoutPage.js.map +1 -1
- package/lib/esm/pages/BackofficeEntityDetailPage.js +206 -255
- package/lib/esm/pages/BackofficeEntityDetailPage.js.map +1 -1
- package/lib/esm/pages/BackofficeEntityListPage.js +4 -0
- package/lib/esm/pages/BackofficeEntityListPage.js.map +1 -1
- package/lib/esm/pages/detail/BackofficeEntityDetailLayoutContext.js.map +1 -1
- package/lib/esm/pages/detail/buildTabsItems.js +1 -0
- package/lib/esm/pages/detail/buildTabsItems.js.map +1 -1
- package/lib/types/components/backoffice/columns/buildDataTableColumns.d.ts.map +1 -1
- package/lib/types/components/backoffice/detail/BackofficeRelationsSummaryGrid.d.ts.map +1 -1
- package/lib/types/components/backoffice/filters/BackofficeFilterAction.d.ts.map +1 -1
- package/lib/types/components/backoffice/hub/BackofficeHubTemplate.d.ts.map +1 -1
- package/lib/types/components/backoffice/layout/breadcrumb/BackofficeTopbarBreadcrumb.d.ts.map +1 -1
- package/lib/types/components/backoffice/links/BackofficeInlineLink.d.ts +2 -1
- package/lib/types/components/backoffice/links/BackofficeInlineLink.d.ts.map +1 -1
- package/lib/types/components/backoffice/links/BackofficeLink.d.ts +2 -1
- package/lib/types/components/backoffice/links/BackofficeLink.d.ts.map +1 -1
- package/lib/types/pages/BackofficeDashboardPage.d.ts.map +1 -1
- package/lib/types/pages/BackofficeDashboardPage.helpers.d.ts +0 -4
- package/lib/types/pages/BackofficeDashboardPage.helpers.d.ts.map +1 -1
- package/lib/types/pages/BackofficeDashboardWidgetContent.d.ts +1 -2
- package/lib/types/pages/BackofficeDashboardWidgetContent.d.ts.map +1 -1
- package/lib/types/pages/BackofficeEntityDetailLayoutPage.d.ts.map +1 -1
- package/lib/types/pages/BackofficeEntityDetailPage.d.ts.map +1 -1
- package/lib/types/pages/BackofficeEntityListPage.d.ts.map +1 -1
- package/lib/types/pages/detail/BackofficeEntityDetailLayoutContext.d.ts +7 -0
- package/lib/types/pages/detail/BackofficeEntityDetailLayoutContext.d.ts.map +1 -1
- package/lib/types/pages/detail/buildTabsItems.d.ts.map +1 -1
- package/package.json +14 -14
|
@@ -2,70 +2,70 @@ import { useBackofficeReactTranslation as e } from "../i18n/useBackofficeReactTr
|
|
|
2
2
|
import { useBackofficeConfig as t } from "../provider/BackofficeConfigContext.js";
|
|
3
3
|
import { BackofficeBillingUsageChart as n } from "../components/backoffice/billing/BackofficeBillingUsageChart.js";
|
|
4
4
|
import { buildDataTableColumns as r } from "../components/backoffice/columns/buildDataTableColumns.js";
|
|
5
|
-
import {
|
|
6
|
-
import { tileBody as
|
|
7
|
-
import { jsx as
|
|
8
|
-
import { useTranslation as
|
|
9
|
-
import * as
|
|
10
|
-
import { BackofficeEmptyState as
|
|
11
|
-
import { DashboardPanel as
|
|
12
|
-
import { DashboardQuickActions as
|
|
13
|
-
import { DashboardMetricGroup as
|
|
14
|
-
import { DashboardStatusList as
|
|
15
|
-
import { DataTable as
|
|
5
|
+
import { resolveLabel as i } from "./BackofficeDashboardPage.helpers.js";
|
|
6
|
+
import { tileBody as a, tileCount as o } from "./backofficeDashboardPage.css.js";
|
|
7
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
8
|
+
import { useTranslation as l } from "react-i18next";
|
|
9
|
+
import * as u from "react-relay";
|
|
10
|
+
import { BackofficeEmptyState as d } from "@plumile/ui/backoffice/molecules/backoffice_empty_state/BackofficeEmptyState.js";
|
|
11
|
+
import { DashboardPanel as f } from "@plumile/ui/components/dashboard/dashboard_panel/DashboardPanel.js";
|
|
12
|
+
import { DashboardQuickActions as p } from "@plumile/ui/components/dashboard/dashboard_quick_actions/DashboardQuickActions.js";
|
|
13
|
+
import { DashboardMetricGroup as m } from "@plumile/ui/components/dashboard/dashboard_metric_group/DashboardMetricGroup.js";
|
|
14
|
+
import { DashboardStatusList as h } from "@plumile/ui/components/dashboard/dashboard_status_list/DashboardStatusList.js";
|
|
15
|
+
import { DataTable as g } from "@plumile/ui/components/data-table/DataTable.js";
|
|
16
16
|
//#region src/pages/BackofficeDashboardWidgetContent.tsx
|
|
17
|
-
var { useLazyLoadQuery:
|
|
17
|
+
var { useLazyLoadQuery: _ } = u, v = () => {
|
|
18
18
|
let { t } = e();
|
|
19
|
-
return /* @__PURE__ */
|
|
20
|
-
},
|
|
21
|
-
let { t:
|
|
22
|
-
if (
|
|
23
|
-
title:
|
|
19
|
+
return /* @__PURE__ */ s(d, { title: t("common.notAvailable") });
|
|
20
|
+
}, y = ({ widget: u, data: d }) => {
|
|
21
|
+
let { t: _ } = l(), { t: y } = e(), { entities: b } = t(), x = u.description == null ? void 0 : i(u.description, _), S = () => u.dataSource === "query" && d != null ? u.resolve(d) : null;
|
|
22
|
+
if (u.kind === "textBlock") return /* @__PURE__ */ s(f, {
|
|
23
|
+
title: i(u.title, _),
|
|
24
24
|
subtitle: x,
|
|
25
|
-
children: /* @__PURE__ */
|
|
26
|
-
className:
|
|
27
|
-
children:
|
|
25
|
+
children: /* @__PURE__ */ s("div", {
|
|
26
|
+
className: a,
|
|
27
|
+
children: i(u.body, _)
|
|
28
28
|
})
|
|
29
29
|
});
|
|
30
|
-
if (
|
|
31
|
-
let e = b[
|
|
32
|
-
return e == null ? /* @__PURE__ */
|
|
30
|
+
if (u.kind === "shortcut") {
|
|
31
|
+
let e = b[u.entityId], t = i(u.label, _);
|
|
32
|
+
return e == null ? /* @__PURE__ */ s(f, {
|
|
33
33
|
title: t,
|
|
34
34
|
subtitle: x,
|
|
35
|
-
children: /* @__PURE__ */
|
|
36
|
-
}) : e.kind === "tool" ? /* @__PURE__ */
|
|
35
|
+
children: /* @__PURE__ */ s(v, {})
|
|
36
|
+
}) : e.kind === "tool" ? /* @__PURE__ */ s(f, {
|
|
37
37
|
title: t,
|
|
38
38
|
subtitle: x,
|
|
39
|
-
children: /* @__PURE__ */
|
|
39
|
+
children: /* @__PURE__ */ s(p, { actions: [{
|
|
40
40
|
id: e.id,
|
|
41
41
|
href: e.routes.list,
|
|
42
|
-
label:
|
|
42
|
+
label: y("dashboard.actions.openTool")
|
|
43
43
|
}] })
|
|
44
|
-
}) : /* @__PURE__ */
|
|
44
|
+
}) : /* @__PURE__ */ s(f, {
|
|
45
45
|
title: t,
|
|
46
46
|
subtitle: x,
|
|
47
|
-
children: /* @__PURE__ */
|
|
47
|
+
children: /* @__PURE__ */ s(p, { actions: [{
|
|
48
48
|
id: e.id,
|
|
49
49
|
href: e.routes.list,
|
|
50
|
-
label:
|
|
50
|
+
label: y("dashboard.actions.openList")
|
|
51
51
|
}] })
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
if (
|
|
55
|
-
let e = S(
|
|
56
|
-
if (e == null) return /* @__PURE__ */
|
|
57
|
-
title:
|
|
54
|
+
if (u.kind === "tablePreview") {
|
|
55
|
+
let e = S();
|
|
56
|
+
if (e == null) return /* @__PURE__ */ s(f, {
|
|
57
|
+
title: i(u.title, _),
|
|
58
58
|
subtitle: x,
|
|
59
|
-
children: /* @__PURE__ */
|
|
59
|
+
children: /* @__PURE__ */ s(v, {})
|
|
60
60
|
});
|
|
61
61
|
let t = r(e.columns, {
|
|
62
|
-
tApp:
|
|
63
|
-
t:
|
|
62
|
+
tApp: _,
|
|
63
|
+
t: y
|
|
64
64
|
});
|
|
65
|
-
return /* @__PURE__ */
|
|
66
|
-
title:
|
|
65
|
+
return /* @__PURE__ */ s(f, {
|
|
66
|
+
title: i(u.title, _),
|
|
67
67
|
subtitle: x,
|
|
68
|
-
children: /* @__PURE__ */
|
|
68
|
+
children: /* @__PURE__ */ s(g, {
|
|
69
69
|
columns: t,
|
|
70
70
|
rows: e.rows,
|
|
71
71
|
getRowId: (e, t) => {
|
|
@@ -78,116 +78,113 @@ var { useLazyLoadQuery: v } = d, y = () => {
|
|
|
78
78
|
})
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
|
-
if (
|
|
82
|
-
let e = S(
|
|
83
|
-
return e == null ? /* @__PURE__ */
|
|
84
|
-
emptyState: /* @__PURE__ */
|
|
81
|
+
if (u.kind === "metricGroup") {
|
|
82
|
+
let e = S();
|
|
83
|
+
return e == null ? /* @__PURE__ */ s(v, {}) : /* @__PURE__ */ s(m, {
|
|
84
|
+
emptyState: /* @__PURE__ */ s(v, {}),
|
|
85
85
|
metrics: e.map((e) => ({
|
|
86
86
|
id: e.id,
|
|
87
87
|
href: e.href,
|
|
88
|
-
label:
|
|
89
|
-
value: e.value ??
|
|
90
|
-
hint: e.meta == null ? void 0 :
|
|
88
|
+
label: i(e.label, _),
|
|
89
|
+
value: e.value ?? y("common.notAvailable"),
|
|
90
|
+
hint: e.meta == null ? void 0 : i(e.meta, _)
|
|
91
91
|
}))
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
|
-
if (
|
|
95
|
-
let e = S(
|
|
96
|
-
return e == null ? /* @__PURE__ */
|
|
94
|
+
if (u.kind === "billingUsageChart") {
|
|
95
|
+
let e = S(), t = i(u.title, _);
|
|
96
|
+
return e == null ? /* @__PURE__ */ s(f, {
|
|
97
97
|
title: t,
|
|
98
98
|
subtitle: x,
|
|
99
|
-
children: /* @__PURE__ */
|
|
100
|
-
}) : /* @__PURE__ */
|
|
99
|
+
children: /* @__PURE__ */ s(v, {})
|
|
100
|
+
}) : /* @__PURE__ */ s(f, {
|
|
101
101
|
title: t,
|
|
102
102
|
subtitle: x,
|
|
103
|
-
children: /* @__PURE__ */
|
|
104
|
-
ariaLabel:
|
|
103
|
+
children: /* @__PURE__ */ s(n, {
|
|
104
|
+
ariaLabel: i(u.ariaLabel, _),
|
|
105
105
|
buckets: e.buckets,
|
|
106
|
-
categories:
|
|
106
|
+
categories: u.categories.map((e) => ({
|
|
107
107
|
id: e.id,
|
|
108
|
-
label:
|
|
108
|
+
label: i(e.label, _),
|
|
109
109
|
color: e.color
|
|
110
110
|
})),
|
|
111
111
|
currency: e.currency,
|
|
112
|
-
emptyLabel:
|
|
112
|
+
emptyLabel: i(u.emptyLabel, _),
|
|
113
113
|
from: e.from,
|
|
114
|
-
rangePrefix:
|
|
114
|
+
rangePrefix: i(u.rangePrefix, _),
|
|
115
115
|
to: e.to,
|
|
116
116
|
totalAmount: e.totalAmount
|
|
117
117
|
})
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
|
-
if (
|
|
121
|
-
title:
|
|
120
|
+
if (u.kind === "quickActions") return /* @__PURE__ */ s(f, {
|
|
121
|
+
title: u.title == null ? y("dashboard.actions.openTool") : i(u.title, _),
|
|
122
122
|
subtitle: x,
|
|
123
|
-
children: /* @__PURE__ */
|
|
124
|
-
layout:
|
|
125
|
-
emptyState: /* @__PURE__ */
|
|
126
|
-
actions:
|
|
123
|
+
children: /* @__PURE__ */ s(p, {
|
|
124
|
+
layout: u.layout?.zone === "aside" ? "stack" : "grid",
|
|
125
|
+
emptyState: /* @__PURE__ */ s(v, {}),
|
|
126
|
+
actions: u.actions.map((e) => ({
|
|
127
127
|
id: e.id,
|
|
128
128
|
href: e.href,
|
|
129
|
-
label:
|
|
129
|
+
label: i(e.label, _)
|
|
130
130
|
}))
|
|
131
131
|
})
|
|
132
132
|
});
|
|
133
|
-
if (
|
|
134
|
-
let e = S(
|
|
135
|
-
return e == null ? /* @__PURE__ */
|
|
136
|
-
title:
|
|
133
|
+
if (u.kind === "statusSummary") {
|
|
134
|
+
let e = S();
|
|
135
|
+
return e == null ? /* @__PURE__ */ s(f, {
|
|
136
|
+
title: u.title == null ? void 0 : i(u.title, _),
|
|
137
137
|
subtitle: x,
|
|
138
|
-
children: /* @__PURE__ */
|
|
139
|
-
}) : /* @__PURE__ */
|
|
140
|
-
title:
|
|
138
|
+
children: /* @__PURE__ */ s(v, {})
|
|
139
|
+
}) : /* @__PURE__ */ s(f, {
|
|
140
|
+
title: u.title == null ? void 0 : i(u.title, _),
|
|
141
141
|
subtitle: x,
|
|
142
|
-
children: /* @__PURE__ */
|
|
143
|
-
emptyState: /* @__PURE__ */
|
|
142
|
+
children: /* @__PURE__ */ s(h, {
|
|
143
|
+
emptyState: /* @__PURE__ */ s(v, {}),
|
|
144
144
|
items: e.map((e) => ({
|
|
145
145
|
id: e.id,
|
|
146
146
|
href: e.href,
|
|
147
|
-
label:
|
|
148
|
-
value: e.value ??
|
|
147
|
+
label: i(e.label, _),
|
|
148
|
+
value: e.value ?? y("common.notAvailable")
|
|
149
149
|
}))
|
|
150
150
|
})
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
|
-
if (
|
|
154
|
-
title:
|
|
153
|
+
if (u.kind === "recentItems") return /* @__PURE__ */ s(f, {
|
|
154
|
+
title: u.title == null ? y("dashboard.title") : i(u.title, _),
|
|
155
155
|
subtitle: x,
|
|
156
|
-
children: /* @__PURE__ */
|
|
156
|
+
children: /* @__PURE__ */ s(v, {})
|
|
157
157
|
});
|
|
158
|
-
let C = b[
|
|
159
|
-
if (C?.kind !== "list-detail") return /* @__PURE__ */
|
|
160
|
-
title:
|
|
158
|
+
let C = b[u.entityId];
|
|
159
|
+
if (C?.kind !== "list-detail") return /* @__PURE__ */ s(f, {
|
|
160
|
+
title: i(u.label, _),
|
|
161
161
|
subtitle: x,
|
|
162
|
-
children: /* @__PURE__ */
|
|
162
|
+
children: /* @__PURE__ */ s(v, {})
|
|
163
163
|
});
|
|
164
|
-
let w = S(
|
|
165
|
-
return typeof w?.count == "number" && (T = w.count), /* @__PURE__ */
|
|
166
|
-
title:
|
|
164
|
+
let w = S(), T = y("common.notAvailable");
|
|
165
|
+
return typeof w?.count == "number" && (T = w.count), /* @__PURE__ */ s(f, {
|
|
166
|
+
title: i(u.label, _),
|
|
167
167
|
subtitle: x,
|
|
168
|
-
children: /* @__PURE__ */
|
|
169
|
-
className:
|
|
170
|
-
children: [/* @__PURE__ */
|
|
171
|
-
className:
|
|
168
|
+
children: /* @__PURE__ */ c("div", {
|
|
169
|
+
className: a,
|
|
170
|
+
children: [/* @__PURE__ */ s("div", {
|
|
171
|
+
className: o,
|
|
172
172
|
children: T
|
|
173
|
-
}), /* @__PURE__ */
|
|
174
|
-
emptyState: /* @__PURE__ */
|
|
173
|
+
}), /* @__PURE__ */ s(p, {
|
|
174
|
+
emptyState: /* @__PURE__ */ s(v, {}),
|
|
175
175
|
actions: [{
|
|
176
176
|
id: C.id,
|
|
177
177
|
href: C.routes.list,
|
|
178
|
-
label:
|
|
178
|
+
label: y("dashboard.actions.openList")
|
|
179
179
|
}]
|
|
180
180
|
})]
|
|
181
181
|
})
|
|
182
182
|
});
|
|
183
|
-
},
|
|
184
|
-
widget: e,
|
|
185
|
-
globalData: v(e.query, {}, { fetchPolicy: "store-or-network" })
|
|
186
|
-
}), S = ({ widget: e, globalData: t }) => i(e) ? /* @__PURE__ */ c(x, { widget: e }) : /* @__PURE__ */ c(b, {
|
|
183
|
+
}, b = ({ widget: e }) => /* @__PURE__ */ s(y, {
|
|
187
184
|
widget: e,
|
|
188
|
-
|
|
189
|
-
});
|
|
185
|
+
data: _(e.query, e.variables, { fetchPolicy: "store-or-network" })
|
|
186
|
+
}), x = ({ widget: e }) => e.dataSource === "query" ? /* @__PURE__ */ s(b, { widget: e }) : /* @__PURE__ */ s(y, { widget: e });
|
|
190
187
|
//#endregion
|
|
191
|
-
export {
|
|
188
|
+
export { x as BackofficeDashboardWidgetContent, x as default };
|
|
192
189
|
|
|
193
190
|
//# sourceMappingURL=BackofficeDashboardWidgetContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackofficeDashboardWidgetContent.js","names":[],"sources":["../../../src/pages/BackofficeDashboardWidgetContent.tsx"],"sourcesContent":["/* eslint-disable no-ternary */\nimport { type JSX } from 'react';\nimport type {\n BackofficeDashboardWidget,\n I18nLabel,\n} from '@plumile/backoffice-core/types.js';\nimport { BackofficeEmptyState } from '@plumile/ui/backoffice/molecules/backoffice_empty_state/BackofficeEmptyState.js';\nimport { DashboardMetricGroup } from '@plumile/ui/components/dashboard/dashboard_metric_group/DashboardMetricGroup.js';\nimport { DashboardPanel } from '@plumile/ui/components/dashboard/dashboard_panel/DashboardPanel.js';\nimport { DashboardQuickActions } from '@plumile/ui/components/dashboard/dashboard_quick_actions/DashboardQuickActions.js';\nimport { DashboardStatusList } from '@plumile/ui/components/dashboard/dashboard_status_list/DashboardStatusList.js';\nimport { DataTable } from '@plumile/ui/components/data-table/DataTable.js';\nimport { useTranslation } from 'react-i18next';\nimport * as ReactRelay from 'react-relay';\nimport type { GraphQLTaggedNode, OperationType } from 'relay-runtime';\n\nimport { BackofficeBillingUsageChart } from '../components/backoffice/billing/BackofficeBillingUsageChart.js';\nimport { buildDataTableColumns } from '../components/backoffice/columns/buildDataTableColumns.js';\nimport { useBackofficeReactTranslation } from '../i18n/useBackofficeReactTranslation.js';\nimport { useBackofficeConfig } from '../provider/BackofficeConfigContext.js';\nimport {\n hasWidgetQuery,\n resolveLabel,\n} from './BackofficeDashboardPage.helpers.js';\n\nimport * as styles from './backofficeDashboardPage.css.js';\n\nconst { useLazyLoadQuery } = ReactRelay;\n\nexport type BackofficeDashboardWidgetContentProps = {\n widget: BackofficeDashboardWidget;\n globalData: unknown;\n};\n\nconst DashboardUnavailableState = (): JSX.Element => {\n const { t } = useBackofficeReactTranslation();\n\n return <BackofficeEmptyState title={t('common.notAvailable')} />;\n};\n\nconst WidgetContentBody = ({\n widget,\n globalData,\n}: BackofficeDashboardWidgetContentProps): JSX.Element | null => {\n const { t: tApp } = useTranslation();\n const { t } = useBackofficeReactTranslation();\n const { entities } = useBackofficeConfig();\n const description =\n widget.description != null\n ? resolveLabel(widget.description, tApp)\n : undefined;\n\n const resolveData = (data: unknown): unknown => {\n if ('resolve' in widget && widget.resolve != null) {\n return widget.resolve(data);\n }\n return null;\n };\n\n if (widget.kind === 'textBlock') {\n const title = resolveLabel(widget.title, tApp);\n const body = resolveLabel(widget.body, tApp);\n return (\n <DashboardPanel title={title} subtitle={description}>\n <div className={styles.tileBody}>{body}</div>\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'shortcut') {\n const entity = entities[widget.entityId];\n const title = resolveLabel(widget.label, tApp);\n if (entity == null) {\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n if (entity.kind === 'tool') {\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardQuickActions\n actions={[\n {\n id: entity.id,\n href: entity.routes.list,\n label: t('dashboard.actions.openTool'),\n },\n ]}\n />\n </DashboardPanel>\n );\n }\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardQuickActions\n actions={[\n {\n id: entity.id,\n href: entity.routes.list,\n label: t('dashboard.actions.openList'),\n },\n ]}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'tablePreview') {\n const resolved = resolveData(globalData) as {\n columns: readonly unknown[];\n rows: readonly unknown[];\n } | null;\n if (resolved == null) {\n return (\n <DashboardPanel\n title={resolveLabel(widget.title, tApp)}\n subtitle={description}\n >\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n const columns = buildDataTableColumns(resolved.columns as never, {\n tApp,\n t,\n });\n const title = resolveLabel(widget.title, tApp);\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DataTable\n columns={columns}\n rows={resolved.rows}\n getRowId={(row, index) => {\n if (row != null && typeof row === 'object') {\n const record = row as Record<string, unknown>;\n const { id } = record;\n if (typeof id === 'string' && id.trim() !== '') {\n return id;\n }\n }\n return String(index);\n }}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'metricGroup') {\n const resolved = resolveData(globalData) as\n | readonly {\n id: string;\n label: I18nLabel;\n value: string | number | null;\n meta?: I18nLabel;\n href?: string;\n }[]\n | null;\n if (resolved == null) {\n return <DashboardUnavailableState />;\n }\n return (\n <DashboardMetricGroup\n emptyState={<DashboardUnavailableState />}\n metrics={resolved.map((metric) => {\n return {\n id: metric.id,\n href: metric.href,\n label: resolveLabel(metric.label, tApp),\n value: metric.value ?? t('common.notAvailable'),\n hint:\n metric.meta != null ? resolveLabel(metric.meta, tApp) : undefined,\n };\n })}\n />\n );\n }\n\n if (widget.kind === 'billingUsageChart') {\n const resolved = resolveData(globalData) as {\n currency: string;\n totalAmount: number;\n from: string | null;\n to: string | null;\n buckets: readonly {\n day: string;\n category: string;\n value: number;\n }[];\n } | null;\n const title = resolveLabel(widget.title, tApp);\n if (resolved == null) {\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n\n return (\n <DashboardPanel title={title} subtitle={description}>\n <BackofficeBillingUsageChart\n ariaLabel={resolveLabel(widget.ariaLabel, tApp)}\n buckets={resolved.buckets}\n categories={widget.categories.map((category) => {\n return {\n id: category.id,\n label: resolveLabel(category.label, tApp),\n color: category.color,\n };\n })}\n currency={resolved.currency}\n emptyLabel={resolveLabel(widget.emptyLabel, tApp)}\n from={resolved.from}\n rangePrefix={resolveLabel(widget.rangePrefix, tApp)}\n to={resolved.to}\n totalAmount={resolved.totalAmount}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'quickActions') {\n const title =\n widget.title != null\n ? resolveLabel(widget.title, tApp)\n : t('dashboard.actions.openTool');\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardQuickActions\n layout={widget.layout?.zone === 'aside' ? 'stack' : 'grid'}\n emptyState={<DashboardUnavailableState />}\n actions={widget.actions.map((action) => {\n return {\n id: action.id,\n href: action.href,\n label: resolveLabel(action.label, tApp),\n };\n })}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'statusSummary') {\n const resolved = resolveData(globalData) as\n | readonly {\n id: string;\n label: I18nLabel;\n value: string | number | null;\n href?: string;\n }[]\n | null;\n if (resolved == null) {\n const title =\n widget.title != null ? resolveLabel(widget.title, tApp) : undefined;\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n const title =\n widget.title != null ? resolveLabel(widget.title, tApp) : undefined;\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardStatusList\n emptyState={<DashboardUnavailableState />}\n items={resolved.map((item) => {\n return {\n id: item.id,\n href: item.href,\n label: resolveLabel(item.label, tApp),\n value: item.value ?? t('common.notAvailable'),\n };\n })}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'recentItems') {\n const title =\n widget.title != null\n ? resolveLabel(widget.title, tApp)\n : t('dashboard.title');\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n\n const entityManifest = entities[widget.entityId];\n if (entityManifest?.kind !== 'list-detail') {\n return (\n <DashboardPanel\n title={resolveLabel(widget.label, tApp)}\n subtitle={description}\n >\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n const resolved = resolveData(globalData) as { count: number | null } | null;\n let countLabel: number | string = t('common.notAvailable');\n if (typeof resolved?.count === 'number') {\n countLabel = resolved.count;\n }\n const title = resolveLabel(widget.label, tApp);\n return (\n <DashboardPanel title={title} subtitle={description}>\n <div className={styles.tileBody}>\n <div className={styles.tileCount}>{countLabel}</div>\n <DashboardQuickActions\n emptyState={<DashboardUnavailableState />}\n actions={[\n {\n id: entityManifest.id,\n href: entityManifest.routes.list,\n label: t('dashboard.actions.openList'),\n },\n ]}\n />\n </div>\n </DashboardPanel>\n );\n};\n\nconst WidgetWithQuery = ({\n widget,\n}: {\n widget: BackofficeDashboardWidget & { query: GraphQLTaggedNode };\n}): JSX.Element => {\n const data = useLazyLoadQuery<OperationType>(\n widget.query,\n {},\n {\n fetchPolicy: 'store-or-network',\n },\n );\n\n return <WidgetContentBody widget={widget} globalData={data} />;\n};\n\nexport const BackofficeDashboardWidgetContent = ({\n widget,\n globalData,\n}: BackofficeDashboardWidgetContentProps): JSX.Element | null => {\n if (hasWidgetQuery(widget)) {\n return <WidgetWithQuery widget={widget} />;\n }\n\n return <WidgetContentBody widget={widget} globalData={globalData} />;\n};\n\nexport default BackofficeDashboardWidgetContent;\n"],"mappings":";;;;;;;;;;;;;;;;AA2BA,IAAM,EAAE,kBAAA,MAAqB,GAOvB,UAA+C;CACnD,IAAM,EAAE,MAAM,E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uB,OAJvB,EAAO,SAAS,OAEZ,EAAE,iBAAiB,IADnB,EAAa,EAAO,OAAO,CAAI;EAGL,UAAU;YACtC,kBAAC,GAAD,CAA4B,CAAA;CACd,CAAA;CAIpB,IAAM,IAAiB,EAAS,EAAO;CACvC,IAAI,GAAgB,SAAS,eAC3B,OACE,kBAAC,GAAD;EACE,OAAO,EAAa,EAAO,OAAO,CAAI;EACtC,UAAU;YAEV,kBAAC,GAAD,CAA4B,CAAA;CACd,CAAA;CAGpB,IAAM,IAAW,EAAY,CAAU,GACnC,IAA8B,EAAE,qBAAqB;CAKzD,OAJI,OAAO,GAAU,SAAU,aAC7B,IAAa,EAAS,QAItB,kBAAC,GAAD;EAAuB,OAFX,EAAa,EAAO,OAAO,CAEhB;EAAO,UAAU;YACtC,kBAAC,OAAD;GAAK,WAAW;aAAhB,CACE,kBAAC,OAAD;IAAK,WAAW;cAAmB;GAAgB,CAAA,GACnD,kBAAC,GAAD;IACE,YAAY,kBAAC,GAAD,CAA4B,CAAA;IACxC,SAAS,CACP;KACE,IAAI,EAAe;KACnB,MAAM,EAAe,OAAO;KAC5B,OAAO,EAAE,4BAA4B;IACvC,CACF;GACD,CAAA,CACE;;CACS,CAAA;AAEpB,GAEM,KAAmB,EACvB,gBAYO,kBAAC,GAAD;CAA2B;CAAQ,YAR7B,EACX,EAAO,OACP,CAAC,GACD,EACE,aAAa,mBACf,CAGoD;AAAO,CAAA,GAGlD,KAAoC,EAC/C,WACA,oBAEI,EAAe,CAAM,IAChB,kBAAC,GAAD,EAAyB,UAAS,CAAA,IAGpC,kBAAC,GAAD;CAA2B;CAAoB;AAAa,CAAA"}
|
|
1
|
+
{"version":3,"file":"BackofficeDashboardWidgetContent.js","names":[],"sources":["../../../src/pages/BackofficeDashboardWidgetContent.tsx"],"sourcesContent":["/* eslint-disable no-ternary */\nimport { type JSX } from 'react';\nimport type {\n BackofficeDashboardWidget,\n I18nLabel,\n} from '@plumile/backoffice-core/types.js';\nimport { BackofficeEmptyState } from '@plumile/ui/backoffice/molecules/backoffice_empty_state/BackofficeEmptyState.js';\nimport { DashboardMetricGroup } from '@plumile/ui/components/dashboard/dashboard_metric_group/DashboardMetricGroup.js';\nimport { DashboardPanel } from '@plumile/ui/components/dashboard/dashboard_panel/DashboardPanel.js';\nimport { DashboardQuickActions } from '@plumile/ui/components/dashboard/dashboard_quick_actions/DashboardQuickActions.js';\nimport { DashboardStatusList } from '@plumile/ui/components/dashboard/dashboard_status_list/DashboardStatusList.js';\nimport { DataTable } from '@plumile/ui/components/data-table/DataTable.js';\nimport { useTranslation } from 'react-i18next';\nimport * as ReactRelay from 'react-relay';\nimport type { OperationType } from 'relay-runtime';\n\nimport { BackofficeBillingUsageChart } from '../components/backoffice/billing/BackofficeBillingUsageChart.js';\nimport { buildDataTableColumns } from '../components/backoffice/columns/buildDataTableColumns.js';\nimport { useBackofficeReactTranslation } from '../i18n/useBackofficeReactTranslation.js';\nimport { useBackofficeConfig } from '../provider/BackofficeConfigContext.js';\nimport { resolveLabel } from './BackofficeDashboardPage.helpers.js';\n\nimport * as styles from './backofficeDashboardPage.css.js';\n\nconst { useLazyLoadQuery } = ReactRelay;\n\nexport type BackofficeDashboardWidgetContentProps = {\n widget: BackofficeDashboardWidget;\n};\n\ntype WidgetContentBodyProps = BackofficeDashboardWidgetContentProps & {\n data?: OperationType['response'];\n};\n\nconst DashboardUnavailableState = (): JSX.Element => {\n const { t } = useBackofficeReactTranslation();\n\n return <BackofficeEmptyState title={t('common.notAvailable')} />;\n};\n\nconst WidgetContentBody = ({\n widget,\n data,\n}: WidgetContentBodyProps): JSX.Element | null => {\n const { t: tApp } = useTranslation();\n const { t } = useBackofficeReactTranslation();\n const { entities } = useBackofficeConfig();\n const description =\n widget.description != null\n ? resolveLabel(widget.description, tApp)\n : undefined;\n\n const resolveData = (): unknown => {\n if (widget.dataSource === 'query' && data != null) {\n return widget.resolve(data);\n }\n return null;\n };\n\n if (widget.kind === 'textBlock') {\n const title = resolveLabel(widget.title, tApp);\n const body = resolveLabel(widget.body, tApp);\n return (\n <DashboardPanel title={title} subtitle={description}>\n <div className={styles.tileBody}>{body}</div>\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'shortcut') {\n const entity = entities[widget.entityId];\n const title = resolveLabel(widget.label, tApp);\n if (entity == null) {\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n if (entity.kind === 'tool') {\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardQuickActions\n actions={[\n {\n id: entity.id,\n href: entity.routes.list,\n label: t('dashboard.actions.openTool'),\n },\n ]}\n />\n </DashboardPanel>\n );\n }\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardQuickActions\n actions={[\n {\n id: entity.id,\n href: entity.routes.list,\n label: t('dashboard.actions.openList'),\n },\n ]}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'tablePreview') {\n const resolved = resolveData() as {\n columns: readonly unknown[];\n rows: readonly unknown[];\n } | null;\n if (resolved == null) {\n return (\n <DashboardPanel\n title={resolveLabel(widget.title, tApp)}\n subtitle={description}\n >\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n const columns = buildDataTableColumns(resolved.columns as never, {\n tApp,\n t,\n });\n const title = resolveLabel(widget.title, tApp);\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DataTable\n columns={columns}\n rows={resolved.rows}\n getRowId={(row, index) => {\n if (row != null && typeof row === 'object') {\n const record = row as Record<string, unknown>;\n const { id } = record;\n if (typeof id === 'string' && id.trim() !== '') {\n return id;\n }\n }\n return String(index);\n }}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'metricGroup') {\n const resolved = resolveData() as\n | readonly {\n id: string;\n label: I18nLabel;\n value: string | number | null;\n meta?: I18nLabel;\n href?: string;\n }[]\n | null;\n if (resolved == null) {\n return <DashboardUnavailableState />;\n }\n return (\n <DashboardMetricGroup\n emptyState={<DashboardUnavailableState />}\n metrics={resolved.map((metric) => {\n return {\n id: metric.id,\n href: metric.href,\n label: resolveLabel(metric.label, tApp),\n value: metric.value ?? t('common.notAvailable'),\n hint:\n metric.meta != null ? resolveLabel(metric.meta, tApp) : undefined,\n };\n })}\n />\n );\n }\n\n if (widget.kind === 'billingUsageChart') {\n const resolved = resolveData() as {\n currency: string;\n totalAmount: number;\n from: string | null;\n to: string | null;\n buckets: readonly {\n day: string;\n category: string;\n value: number;\n }[];\n } | null;\n const title = resolveLabel(widget.title, tApp);\n if (resolved == null) {\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n\n return (\n <DashboardPanel title={title} subtitle={description}>\n <BackofficeBillingUsageChart\n ariaLabel={resolveLabel(widget.ariaLabel, tApp)}\n buckets={resolved.buckets}\n categories={widget.categories.map((category) => {\n return {\n id: category.id,\n label: resolveLabel(category.label, tApp),\n color: category.color,\n };\n })}\n currency={resolved.currency}\n emptyLabel={resolveLabel(widget.emptyLabel, tApp)}\n from={resolved.from}\n rangePrefix={resolveLabel(widget.rangePrefix, tApp)}\n to={resolved.to}\n totalAmount={resolved.totalAmount}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'quickActions') {\n const title =\n widget.title != null\n ? resolveLabel(widget.title, tApp)\n : t('dashboard.actions.openTool');\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardQuickActions\n layout={widget.layout?.zone === 'aside' ? 'stack' : 'grid'}\n emptyState={<DashboardUnavailableState />}\n actions={widget.actions.map((action) => {\n return {\n id: action.id,\n href: action.href,\n label: resolveLabel(action.label, tApp),\n };\n })}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'statusSummary') {\n const resolved = resolveData() as\n | readonly {\n id: string;\n label: I18nLabel;\n value: string | number | null;\n href?: string;\n }[]\n | null;\n if (resolved == null) {\n const title =\n widget.title != null ? resolveLabel(widget.title, tApp) : undefined;\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n const title =\n widget.title != null ? resolveLabel(widget.title, tApp) : undefined;\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardStatusList\n emptyState={<DashboardUnavailableState />}\n items={resolved.map((item) => {\n return {\n id: item.id,\n href: item.href,\n label: resolveLabel(item.label, tApp),\n value: item.value ?? t('common.notAvailable'),\n };\n })}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'recentItems') {\n const title =\n widget.title != null\n ? resolveLabel(widget.title, tApp)\n : t('dashboard.title');\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n\n const entityManifest = entities[widget.entityId];\n if (entityManifest?.kind !== 'list-detail') {\n return (\n <DashboardPanel\n title={resolveLabel(widget.label, tApp)}\n subtitle={description}\n >\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n const resolved = resolveData() as { count: number | null } | null;\n let countLabel: number | string = t('common.notAvailable');\n if (typeof resolved?.count === 'number') {\n countLabel = resolved.count;\n }\n const title = resolveLabel(widget.label, tApp);\n return (\n <DashboardPanel title={title} subtitle={description}>\n <div className={styles.tileBody}>\n <div className={styles.tileCount}>{countLabel}</div>\n <DashboardQuickActions\n emptyState={<DashboardUnavailableState />}\n actions={[\n {\n id: entityManifest.id,\n href: entityManifest.routes.list,\n label: t('dashboard.actions.openList'),\n },\n ]}\n />\n </div>\n </DashboardPanel>\n );\n};\n\nconst WidgetWithQuery = ({\n widget,\n}: {\n widget: Extract<BackofficeDashboardWidget, { dataSource: 'query' }>;\n}): JSX.Element => {\n const data = useLazyLoadQuery<OperationType>(widget.query, widget.variables, {\n fetchPolicy: 'store-or-network',\n });\n\n return <WidgetContentBody widget={widget} data={data} />;\n};\n\nexport const BackofficeDashboardWidgetContent = ({\n widget,\n}: BackofficeDashboardWidgetContentProps): JSX.Element | null => {\n if (widget.dataSource === 'query') {\n return <WidgetWithQuery widget={widget} />;\n }\n\n return <WidgetContentBody widget={widget}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../i18n/useBackofficeReactTranslation.js";
|
|
2
|
+
import { useBackofficeConfig as t } from "../provider/BackofficeConfigContext.js";
|
|
3
|
+
import { BackofficeDetailBadgeRow as n } from "../components/backoffice/detail/BackofficeDetailBadgeRow.js";
|
|
4
|
+
import { BackofficeRightPageLayout as r } from "../components/backoffice/layout/breadcrumb/BackofficeRightPageLayout.js";
|
|
5
|
+
import { buildEntityDetailBreadcrumb as i } from "../components/backoffice/layout/breadcrumb/buildBreadcrumbs.js";
|
|
6
|
+
import { resolveVisibleDetailPages as a } from "./detail/pageResolution.js";
|
|
7
|
+
import { headerBlock as o, headerMeta as s, headerMetaList as c } from "./backofficeEntityDetailPage.css.js";
|
|
8
|
+
import { resolveHeaderItems as l } from "./BackofficeEntityDetailPage.view-helpers.js";
|
|
9
|
+
import { BackofficeEntityDetailLayoutContextProvider as u } from "./detail/BackofficeEntityDetailLayoutContext.js";
|
|
10
|
+
import { buildTabsItems as d } from "./detail/buildTabsItems.js";
|
|
11
|
+
import { BackofficeRedirect as f } from "./BackofficeRedirect.js";
|
|
12
|
+
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
13
|
+
import { useTranslation as g } from "react-i18next";
|
|
14
|
+
import * as _ from "react-relay";
|
|
15
|
+
import { FormattedDate as v } from "@plumile/ui/atomic/atoms/formatted-date/FormattedDate.js";
|
|
16
|
+
import { BACKOFFICE_DATE_TIME_OPTIONS as y } from "@plumile/backoffice-core/constants.js";
|
|
17
|
+
import b from "@plumile/router/routing/Link.js";
|
|
18
|
+
import { Tag as x } from "@plumile/ui/backoffice/atoms/tag/Tag.js";
|
|
19
|
+
import { BackofficePageHeader as S } from "@plumile/ui/backoffice/molecules/backoffice_page_header/BackofficePageHeader.js";
|
|
20
|
+
import { Tabs as C } from "@plumile/ui/atomic/molecules/tabs/Tabs.js";
|
|
21
|
+
import { DetailPageTemplate as w } from "@plumile/ui/backoffice/templates/detail_page_template/DetailPageTemplate.js";
|
|
22
|
+
import T from "@plumile/router/routing/useLocation.js";
|
|
23
|
+
import { BackofficeKeyValueList as E } from "@plumile/ui/backoffice/molecules/backoffice_key_value_list/BackofficeKeyValueList.js";
|
|
5
24
|
//#region src/pages/BackofficeEntityDetailLayoutPage.tsx
|
|
6
|
-
var { useFragment:
|
|
7
|
-
let
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
25
|
+
var { useFragment: D, usePreloadedQuery: O } = _, k = (e) => e.trim().replace(/^\/+|\/+$/g, ""), A = (e, t, n) => [n.pages.mainPage, ...n.pages.subPages ?? []].find((r) => e === n.routes.detailPage(t, r.id))?.path ?? "", j = ({ config: _, prepared: j, children: M }) => {
|
|
26
|
+
let { t: N } = g(), { t: P } = e(), { entities: F } = t(), { pathname: I } = T(), L = O(_.layoutPage.query, j.layoutQuery), R = _.layoutPage.resolveNode(L, { id: j.id }), z = D(_.layoutPage.fragment, R);
|
|
27
|
+
if (R == null) return /* @__PURE__ */ m(f, { to: _.routes.list });
|
|
28
|
+
let B = _.layoutPage.toView(z), V = A(I, j.id, _), H = a({
|
|
29
|
+
mainPage: _.pages.mainPage,
|
|
30
|
+
subPages: _.pages.subPages,
|
|
31
|
+
activePagePath: V,
|
|
32
|
+
node: B
|
|
33
|
+
});
|
|
34
|
+
if (!H.hasVisiblePages || H.activePage == null) return /* @__PURE__ */ m(f, { to: _.routes.list });
|
|
35
|
+
let { activePage: U } = H;
|
|
36
|
+
if (V !== "" && k(U.path) !== k(V)) return /* @__PURE__ */ m(f, { to: _.routes.detailPage(j.id, U.id) });
|
|
37
|
+
let W = d({
|
|
38
|
+
pages: H.pages,
|
|
39
|
+
id: j.id,
|
|
40
|
+
tApp: N,
|
|
41
|
+
detailPageHref: _.routes.detailPage
|
|
42
|
+
}), G = l(_.header, B, {
|
|
43
|
+
tApp: N,
|
|
44
|
+
t: P,
|
|
45
|
+
resolveEntityHref: (e, t) => {
|
|
46
|
+
let n = F[e];
|
|
47
|
+
return n == null ? null : n.routes.detail(t);
|
|
48
|
+
},
|
|
49
|
+
renderLink: (e, t) => /* @__PURE__ */ m(b, {
|
|
50
|
+
to: e,
|
|
51
|
+
preloadOnMouseEnter: !0,
|
|
52
|
+
children: t
|
|
53
|
+
}),
|
|
54
|
+
renderDate: (e, t) => /* @__PURE__ */ m(v, {
|
|
55
|
+
value: e,
|
|
56
|
+
options: y,
|
|
57
|
+
fallback: t
|
|
58
|
+
}),
|
|
59
|
+
renderTag: (e, t) => /* @__PURE__ */ m(x, {
|
|
60
|
+
tone: e,
|
|
61
|
+
children: t
|
|
62
|
+
}),
|
|
63
|
+
renderBadgeRow: (e) => /* @__PURE__ */ m(n, { items: e })
|
|
64
|
+
}), K = i({
|
|
65
|
+
config: _,
|
|
66
|
+
tApp: N,
|
|
67
|
+
entityId: j.id,
|
|
68
|
+
layoutView: B,
|
|
69
|
+
pageLabel: U.label(N),
|
|
70
|
+
pageId: U.id
|
|
71
|
+
}), q;
|
|
72
|
+
(G.status != null || G.badges != null) && (q = /* @__PURE__ */ h("div", {
|
|
73
|
+
className: s,
|
|
74
|
+
children: [G.status, G.badges]
|
|
75
|
+
}));
|
|
76
|
+
let J = null;
|
|
77
|
+
G.items != null && G.items.length > 0 && (J = /* @__PURE__ */ m("div", {
|
|
78
|
+
className: c,
|
|
79
|
+
children: /* @__PURE__ */ m(E, { items: G.items })
|
|
80
|
+
}));
|
|
81
|
+
let Y = /* @__PURE__ */ h("div", {
|
|
82
|
+
className: o,
|
|
83
|
+
children: [/* @__PURE__ */ m(S, {
|
|
84
|
+
title: G.title,
|
|
85
|
+
subtitle: G.subtitle,
|
|
86
|
+
meta: q
|
|
87
|
+
}), J]
|
|
88
|
+
}), X = null;
|
|
89
|
+
return H.pages.length > 1 && (X = /* @__PURE__ */ m(C, {
|
|
90
|
+
items: W,
|
|
91
|
+
activeId: U.id,
|
|
92
|
+
variant: "underline"
|
|
93
|
+
})), /* @__PURE__ */ m(u, {
|
|
94
|
+
value: {
|
|
95
|
+
activePage: U,
|
|
96
|
+
config: _,
|
|
97
|
+
entityId: j.id,
|
|
98
|
+
layoutView: B,
|
|
99
|
+
tabsItems: W,
|
|
100
|
+
visiblePages: H.pages
|
|
101
|
+
},
|
|
102
|
+
children: /* @__PURE__ */ m(r, {
|
|
103
|
+
breadcrumb: K,
|
|
104
|
+
children: /* @__PURE__ */ m(w, {
|
|
105
|
+
headerNode: Y,
|
|
106
|
+
tabsNode: X,
|
|
107
|
+
headerDensity: "compact",
|
|
108
|
+
children: /* @__PURE__ */ m(p, { children: M })
|
|
109
|
+
})
|
|
110
|
+
})
|
|
11
111
|
});
|
|
12
112
|
};
|
|
13
113
|
//#endregion
|
|
14
|
-
export {
|
|
114
|
+
export { j as BackofficeEntityDetailLayoutPage, j as default };
|
|
15
115
|
|
|
16
116
|
//# sourceMappingURL=BackofficeEntityDetailLayoutPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackofficeEntityDetailLayoutPage.js","names":[],"sources":["../../../src/pages/BackofficeEntityDetailLayoutPage.tsx"],"sourcesContent":["import { type JSX, type ReactNode } from 'react';\nimport * as ReactRelay from 'react-relay';\n\nimport type {\n BackofficeEntityManifestItem,\n BackofficePreparedDetailLayoutRoute,\n BackofficeResolvedDetailLayoutFacetConfig,\n} from '@plumile/backoffice-core/types.js';\nimport { BackofficeEntityDetailLayoutContextProvider } from './detail/BackofficeEntityDetailLayoutContext.js';\nimport { BackofficeRedirect } from './BackofficeRedirect.js';\n\nconst { useFragment, usePreloadedQuery } = ReactRelay;\n\nexport type BackofficeEntityDetailLayoutPageProps = {\n entityManifest: BackofficeEntityManifestItem;\n config: BackofficeResolvedDetailLayoutFacetConfig;\n prepared: BackofficePreparedDetailLayoutRoute;\n children?: ReactNode;\n};\n\nexport const BackofficeEntityDetailLayoutPage = ({\n config,\n prepared,\n children,\n}: BackofficeEntityDetailLayoutPageProps): JSX.Element => {\n const layoutQueryData = usePreloadedQuery(\n config.layoutPage.query,\n prepared.layoutQuery,\n );\n const layoutNodeRef = config.layoutPage.resolveNode(layoutQueryData, {\n id: prepared.id,\n });\n\n const layoutNode = useFragment(\n config.layoutPage.fragment,\n layoutNodeRef as never,\n );\n\n if (layoutNodeRef == null) {\n return <BackofficeRedirect to={config.routes.list} />;\n }\n\n const layoutView = config.layoutPage.toView(layoutNode);\n\n return (\n <BackofficeEntityDetailLayoutContextProvider\n value={{\n layoutView,\n }}\n >\n <>{children}</>\n </BackofficeEntityDetailLayoutContextProvider>\n );\n};\n\nexport default BackofficeEntityDetailLayoutPage;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"BackofficeEntityDetailLayoutPage.js","names":[],"sources":["../../../src/pages/BackofficeEntityDetailLayoutPage.tsx"],"sourcesContent":["import { type JSX, type ReactNode } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport * as ReactRelay from 'react-relay';\nimport Link from '@plumile/router/routing/Link.js';\nimport useLocation from '@plumile/router/routing/useLocation.js';\n\nimport { BACKOFFICE_DATE_TIME_OPTIONS } from '@plumile/backoffice-core/constants.js';\nimport type {\n BackofficeEntityManifestItem,\n BackofficePreparedDetailLayoutRoute,\n BackofficeResolvedDetailLayoutFacetConfig,\n} from '@plumile/backoffice-core/types.js';\nimport { FormattedDate } from '@plumile/ui/atomic/atoms/formatted-date/FormattedDate.js';\nimport { Tabs } from '@plumile/ui/atomic/molecules/tabs/Tabs.js';\nimport { Tag } from '@plumile/ui/backoffice/atoms/tag/Tag.js';\nimport { BackofficeKeyValueList } from '@plumile/ui/backoffice/molecules/backoffice_key_value_list/BackofficeKeyValueList.js';\nimport { BackofficePageHeader } from '@plumile/ui/backoffice/molecules/backoffice_page_header/BackofficePageHeader.js';\nimport { DetailPageTemplate } from '@plumile/ui/backoffice/templates/detail_page_template/DetailPageTemplate.js';\n\nimport { BackofficeDetailBadgeRow } from '../components/backoffice/detail/BackofficeDetailBadgeRow.js';\nimport { BackofficeRightPageLayout } from '../components/backoffice/layout/breadcrumb/BackofficeRightPageLayout.js';\nimport { buildEntityDetailBreadcrumb } from '../components/backoffice/layout/breadcrumb/buildBreadcrumbs.js';\nimport { useBackofficeReactTranslation } from '../i18n/useBackofficeReactTranslation.js';\nimport { useBackofficeConfig } from '../provider/BackofficeConfigContext.js';\nimport * as pageStyles from './backofficeEntityDetailPage.css.js';\nimport { resolveHeaderItems } from './BackofficeEntityDetailPage.view-helpers.js';\nimport { BackofficeEntityDetailLayoutContextProvider } from './detail/BackofficeEntityDetailLayoutContext.js';\nimport { buildTabsItems } from './detail/buildTabsItems.js';\nimport { resolveVisibleDetailPages } from './detail/pageResolution.js';\nimport { BackofficeRedirect } from './BackofficeRedirect.js';\n\nconst { useFragment, usePreloadedQuery } = ReactRelay;\n\nconst normalizePath = (value: string): string => {\n return value.trim().replace(/^\\/+|\\/+$/g, '');\n};\n\nconst resolveActivePagePath = (\n pathname: string,\n id: string,\n config: BackofficeResolvedDetailLayoutFacetConfig,\n): string => {\n const pages = [config.pages.mainPage, ...(config.pages.subPages ?? [])];\n const activePage = pages.find((page) => {\n return pathname === config.routes.detailPage(id, page.id);\n });\n return activePage?.path ?? '';\n};\n\nexport type BackofficeEntityDetailLayoutPageProps = {\n entityManifest: BackofficeEntityManifestItem;\n config: BackofficeResolvedDetailLayoutFacetConfig;\n prepared: BackofficePreparedDetailLayoutRoute;\n children?: ReactNode;\n};\n\nexport const BackofficeEntityDetailLayoutPage = ({\n config,\n prepared,\n children,\n}: BackofficeEntityDetailLayoutPageProps): JSX.Element => {\n const { t: tApp } = useTranslation();\n const { t } = useBackofficeReactTranslation();\n const { entities } = useBackofficeConfig();\n const { pathname } = useLocation();\n const layoutQueryData = usePreloadedQuery(\n config.layoutPage.query,\n prepared.layoutQuery,\n );\n const layoutNodeRef = config.layoutPage.resolveNode(layoutQueryData, {\n id: prepared.id,\n });\n\n const layoutNode = useFragment(\n config.layoutPage.fragment,\n layoutNodeRef as never,\n );\n\n if (layoutNodeRef == null) {\n return <BackofficeRedirect to={config.routes.list} />;\n }\n\n const layoutView = config.layoutPage.toView(layoutNode);\n const activePagePath = resolveActivePagePath(pathname, prepared.id, config);\n const resolvedPages = resolveVisibleDetailPages({\n mainPage: config.pages.mainPage,\n subPages: config.pages.subPages,\n activePagePath,\n node: layoutView as never,\n });\n\n if (!resolvedPages.hasVisiblePages || resolvedPages.activePage == null) {\n return <BackofficeRedirect to={config.routes.list} />;\n }\n\n const { activePage } = resolvedPages;\n if (\n activePagePath !== '' &&\n normalizePath(activePage.path) !== normalizePath(activePagePath)\n ) {\n return (\n <BackofficeRedirect\n to={config.routes.detailPage(prepared.id, activePage.id)}\n />\n );\n }\n\n const tabsItems = buildTabsItems({\n pages: resolvedPages.pages,\n id: prepared.id,\n tApp,\n detailPageHref: config.routes.detailPage,\n });\n const resolveEntityHref = (entityId: string, refId: string) => {\n const entityConfig = entities[entityId];\n if (entityConfig == null) {\n return null;\n }\n return entityConfig.routes.detail(refId);\n };\n const header = resolveHeaderItems(config.header, layoutView, {\n tApp,\n t,\n resolveEntityHref,\n renderLink: (href, label) => {\n return (\n <Link to={href} preloadOnMouseEnter>\n {label}\n </Link>\n );\n },\n renderDate: (value, fallback) => {\n return (\n <FormattedDate\n value={value}\n options={BACKOFFICE_DATE_TIME_OPTIONS}\n fallback={fallback}\n />\n );\n },\n renderTag: (tone, label) => {\n return <Tag tone={tone}>{label}</Tag>;\n },\n renderBadgeRow: (items) => {\n return <BackofficeDetailBadgeRow items={items} />;\n },\n });\n const breadcrumb = buildEntityDetailBreadcrumb({\n config,\n tApp,\n entityId: prepared.id,\n layoutView,\n pageLabel: activePage.label(tApp),\n pageId: activePage.id,\n });\n let headerMetaNode: JSX.Element | undefined;\n if (header.status != null || header.badges != null) {\n headerMetaNode = (\n <div className={pageStyles.headerMeta}>\n {header.status}\n {header.badges}\n </div>\n );\n }\n let headerItemsNode: JSX.Element | null = null;\n if (header.items != null && header.items.length > 0) {\n headerItemsNode = (\n <div className={pageStyles.headerMetaList}>\n <BackofficeKeyValueList items={header.items} />\n </div>\n );\n }\n const headerNode = (\n <div className={pageStyles.headerBlock}>\n <BackofficePageHeader\n title={header.title}\n subtitle={header.subtitle}\n meta={headerMetaNode}\n />\n {headerItemsNode}\n </div>\n );\n let tabsNode: JSX.Element | null = null;\n if (resolvedPages.pages.length > 1) {\n tabsNode = (\n <Tabs items={tabsItems} activeId={activePage.id} variant=\"underline\" />\n );\n }\n\n return (\n <BackofficeEntityDetailLayoutContextProvider\n value={{\n activePage,\n config,\n entityId: prepared.id,\n layoutView,\n tabsItems,\n visiblePages: resolvedPages.pages,\n }}\n >\n <BackofficeRightPageLayout breadcrumb={breadcrumb}>\n <DetailPageTemplate\n headerNode={headerNode}\n tabsNode={tabsNode}\n headerDensity=\"compact\"\n >\n <>{children}</>\n </DetailPageTemplate>\n </BackofficeRightPageLayout>\n </BackofficeEntityDetailLayoutContextProvider>\n );\n};\n\nexport default BackofficeEntityDetailLayoutPage;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA+BA,IAAM,EAAE,aAAA,GAAa,mBAAA,MAAsB,GAErC,KAAiB,MACd,EAAM,KAAK,EAAE,QAAQ,cAAc,EAAE,GAGxC,KACJ,GACA,GACA,MAGmB,CADJ,EAAO,MAAM,UAAU,GAAI,EAAO,MAAM,YAAY,CAAC,CACjD,EAAM,MAAM,MACtB,MAAa,EAAO,OAAO,WAAW,GAAI,EAAK,EAAE,CAEnD,GAAY,QAAQ,IAUhB,KAAoC,EAC/C,WACA,aACA,kBACwD;CACxD,IAAM,EAAE,GAAG,MAAS,EAAe,GAC7B,EAAE,SAAM,EAA8B,GACtC,EAAE,gBAAa,EAAoB,GACnC,EAAE,gBAAa,EAAY,GAC3B,IAAkB,EACtB,EAAO,WAAW,OAClB,EAAS,WACX,GACM,IAAgB,EAAO,WAAW,YAAY,GAAiB,EACnE,IAAI,EAAS,GACf,CAAC,GAEK,IAAa,EACjB,EAAO,WAAW,UAClB,CACF;CAEA,IAAI,KAAiB,MACnB,OAAO,kBAAC,GAAD,EAAoB,IAAI,EAAO,OA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