@antelopejs/dms 0.7.17 → 0.7.18
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
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v0.7.18
|
|
4
|
+
|
|
5
|
+
[compare changes](https://github.com/AntelopeJS/dms/compare/v0.7.17...v0.7.18)
|
|
6
|
+
|
|
7
|
+
### 🚀 Enhancements
|
|
8
|
+
|
|
9
|
+
- **layout:** Let a header button's label read the page's query ([#247](https://github.com/AntelopeJS/dms/pull/247))
|
|
10
|
+
|
|
11
|
+
### ❤️ Contributors
|
|
12
|
+
|
|
13
|
+
- Antony Rizzitelli <rizzitelli.antony@pm.me>
|
|
14
|
+
|
|
3
15
|
## v0.7.17
|
|
4
16
|
|
|
5
17
|
[compare changes](https://github.com/AntelopeJS/dms/compare/v0.7.16...v0.7.17)
|
|
@@ -117,13 +117,20 @@ const defaultVariant = (
|
|
|
117
117
|
const orderOf = (action: LayoutHeaderAction): number =>
|
|
118
118
|
action.order ?? DEFAULT_PAGE_HEADER_ACTIONS_ORDER;
|
|
119
119
|
|
|
120
|
+
// A served label's translation reads the page query as its parameters:
|
|
121
|
+
// `"Download {locale}.json"` names the language of `?locale=`.
|
|
122
|
+
function labelParams(): Record<string, unknown> {
|
|
123
|
+
const { routeParams, routeQuery } = pageUrlValues.value;
|
|
124
|
+
return { ...routeParams, ...routeQuery };
|
|
125
|
+
}
|
|
126
|
+
|
|
120
127
|
function baseButton(action: LayoutHeaderAction): ButtonProps {
|
|
121
128
|
const color = action.color ?? "neutral";
|
|
122
129
|
return {
|
|
123
130
|
color,
|
|
124
131
|
variant: action.variant ?? defaultVariant(color),
|
|
125
132
|
icon: action.icon,
|
|
126
|
-
label: action.label ? processI18n(action.label) : undefined,
|
|
133
|
+
label: action.label ? processI18n(action.label, labelParams()) : undefined,
|
|
127
134
|
disabled: action.disabled,
|
|
128
135
|
};
|
|
129
136
|
}
|
|
@@ -73,7 +73,10 @@ beforeEach(() => {
|
|
|
73
73
|
vi.stubGlobal("useAuthFetch", () => ({ $authFetch: authFetch }));
|
|
74
74
|
vi.stubGlobal("computed", computed);
|
|
75
75
|
vi.stubGlobal("useTranslation", () => ({
|
|
76
|
-
processI18n: (value: string) =>
|
|
76
|
+
processI18n: (value: string, params?: Record<string, unknown>) =>
|
|
77
|
+
value.replace(/\{(\w+)\}/g, (_, name: string) =>
|
|
78
|
+
String(params?.[name] ?? `{${name}}`),
|
|
79
|
+
),
|
|
77
80
|
}));
|
|
78
81
|
vi.stubGlobal("useI18n", () => ({ t: (key: string) => key }));
|
|
79
82
|
vi.stubGlobal("useDmsRoute", () => route);
|
|
@@ -270,6 +273,24 @@ describe("a header button's target URL", () => {
|
|
|
270
273
|
});
|
|
271
274
|
});
|
|
272
275
|
|
|
276
|
+
describe("a header button's label", () => {
|
|
277
|
+
it("reads the page's query and params as its parameters, and follows them", async () => {
|
|
278
|
+
route.query = { workspace: "web", file: "fr" };
|
|
279
|
+
await mountBar([
|
|
280
|
+
{
|
|
281
|
+
id: "download",
|
|
282
|
+
label: "Download {file}.json for {locale}",
|
|
283
|
+
target: { type: "page", url: "/x" },
|
|
284
|
+
},
|
|
285
|
+
]);
|
|
286
|
+
expect(labels()).toEqual(["Download fr.json for de"]);
|
|
287
|
+
|
|
288
|
+
route.query = { workspace: "web", file: "it" };
|
|
289
|
+
await nextTick();
|
|
290
|
+
expect(labels()).toEqual(["Download it.json for de"]);
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
|
|
273
294
|
describe("a header button's availability", () => {
|
|
274
295
|
const download = (disabled: boolean) => ({
|
|
275
296
|
id: "download",
|
package/package.json
CHANGED
|
@@ -36,7 +36,8 @@ gets `navigation` (J / K, `index` / `total` in the order shown) —
|
|
|
36
36
|
`docs/04.components/06.tables/8.row-drawers.md`.
|
|
37
37
|
|
|
38
38
|
A page's `headerActions` follow its URL: a target URL takes `{{params.X}}` / `{{query.X}}`
|
|
39
|
-
(`?workspace={{query.workspace}}`, a pair the page has no value for is dropped),
|
|
39
|
+
(`?workspace={{query.workspace}}`, a pair the page has no value for is dropped), a label's
|
|
40
|
+
translation takes the page's route and query parameters (`"Download {locale}.json"`), and an
|
|
40
41
|
`availability` reads `context.query`, asked again when the query changes — no need to build
|
|
41
42
|
the header in Vue with `usePageHeaderActions` to carry the scope —
|
|
42
43
|
`docs/07.interfaces/3.base/6.layout.md#buttons-that-follow-the-page-url`. An `availability`
|