derive-dashboards 0.1.0 → 0.1.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/README.md +4 -3
- package/dist/adapter/sql-adapter.mjs +4 -4
- package/dist/body.mjs +11 -1
- package/dist/cache.d.mts +1 -1
- package/dist/cli/check.mjs +14 -1
- package/dist/cli/import/dbt-schema.mjs +2 -2
- package/dist/cli/import/index.mjs +2 -2
- package/dist/core/conformance/cases.d.mts +3 -0
- package/dist/core/conformance/cases.mjs +20 -4
- package/dist/core/conformance/check.mjs +6 -3
- package/dist/core/conformance/drill-cases.mjs +120 -0
- package/dist/core/document/view.d.mts +26 -7
- package/dist/core/document/view.mjs +42 -11
- package/dist/core/engine/index.d.mts +14 -2
- package/dist/core/engine/index.mjs +12 -1
- package/dist/core/engine/members.mjs +1 -1
- package/dist/core/engine/postgres.mjs +1 -1
- package/dist/core/engine/record-layout.d.mts +11 -0
- package/dist/core/engine/record-layout.mjs +7 -7
- package/dist/core/engine/records.d.mts +3 -2
- package/dist/core/engine/records.mjs +2 -1
- package/dist/core/engine/segmented.mjs +5 -2
- package/dist/core/engine/sql-records.mjs +2 -1
- package/dist/core/engine/statement.mjs +37 -3
- package/dist/core/engine/types.d.mts +3 -0
- package/dist/core/engine/version.d.mts +1 -1
- package/dist/core/engine/version.mjs +1 -1
- package/dist/core/error/codes.d.mts +31 -0
- package/dist/core/error/codes.mjs +28 -1
- package/dist/core/index.d.mts +9 -5
- package/dist/core/index.mjs +5 -3
- package/dist/core/model/catalog/check.mjs +1 -1
- package/dist/core/model/hints.d.mts +36 -0
- package/dist/core/model/member.d.mts +4 -2
- package/dist/core/model/member.mjs +16 -3
- package/dist/core/model/types.d.mts +8 -6
- package/dist/core/model/validate/drill.mjs +70 -0
- package/dist/core/model/validate/index.mjs +3 -0
- package/dist/core/model/validate/shape.mjs +150 -0
- package/dist/core/model/validate/source.mjs +5 -3
- package/dist/core/query/alias.mjs +7 -1
- package/dist/core/query/drill/compose.d.mts +22 -0
- package/dist/core/query/drill/compose.mjs +85 -0
- package/dist/core/query/drill/fields.d.mts +21 -0
- package/dist/core/query/drill/fields.mjs +91 -0
- package/dist/core/query/drill/internal.d.mts +11 -0
- package/dist/core/query/drill/items.d.mts +29 -0
- package/dist/core/query/drill/items.mjs +98 -0
- package/dist/core/query/drill/line.d.mts +31 -0
- package/dist/core/query/drill/line.mjs +183 -0
- package/dist/core/query/drill/links.d.mts +33 -0
- package/dist/core/query/drill/links.mjs +31 -0
- package/dist/core/query/drill/operand.mjs +7 -0
- package/dist/core/query/drill/scopes.d.mts +22 -0
- package/dist/core/query/drill/scopes.mjs +58 -0
- package/dist/core/query/drill/selection.d.mts +37 -0
- package/dist/core/query/drill/selection.mjs +144 -0
- package/dist/core/query/drill/steps.d.mts +14 -0
- package/dist/core/query/drill/steps.mjs +35 -0
- package/dist/core/query/drill/synthetic-expr.mjs +85 -0
- package/dist/core/query/drill/synthetic.d.mts +22 -0
- package/dist/core/query/drill/synthetic.mjs +165 -0
- package/dist/core/query/drill/time.d.mts +11 -0
- package/dist/core/query/drill/time.mjs +71 -0
- package/dist/core/query/drill/types.d.mts +155 -0
- package/dist/core/query/drill/types.mjs +4 -0
- package/dist/core/query/drill/views.d.mts +62 -0
- package/dist/core/query/drill/views.mjs +257 -0
- package/dist/core/query/segments.d.mts +12 -2
- package/dist/core/query/segments.mjs +3 -1
- package/dist/core/result/columns.mjs +17 -4
- package/dist/core/result/types.d.mts +5 -1
- package/dist/core/schema/answer-parts.mjs +117 -0
- package/dist/core/schema/answers.d.mts +2108 -128
- package/dist/core/schema/answers.mjs +10 -113
- package/dist/core/schema/commands.d.mts +2 -2
- package/dist/core/schema/document.d.mts +1 -1
- package/dist/core/schema/drill-answers.mjs +179 -0
- package/dist/core/schema/drill.d.mts +260 -0
- package/dist/core/schema/drill.mjs +107 -0
- package/dist/core/schema/index.d.mts +4 -2
- package/dist/core/schema/index.mjs +4 -2
- package/dist/core/schema/picks.d.mts +35 -0
- package/dist/core/schema/picks.mjs +23 -0
- package/dist/core/schema/query.d.mts +1 -1
- package/dist/core/schema/tools.mjs +1 -1
- package/dist/core/schema/view.d.mts +0 -35
- package/dist/core/schema/view.mjs +19 -24
- package/dist/core/store/schema.d.mts +5 -0
- package/dist/core/store/schema.mjs +10 -0
- package/dist/core/types/api.d.mts +15 -1
- package/dist/core/types/api.mjs +1 -1
- package/dist/core/types/drill-api.d.mts +210 -0
- package/dist/core/types/options.d.mts +21 -0
- package/dist/core/types/viewer.d.mts +5 -0
- package/dist/cursor-seal.d.mts +8 -0
- package/dist/cursor-seal.mjs +98 -0
- package/dist/dashboard-id.mjs +1 -1
- package/dist/drill-access.mjs +93 -0
- package/dist/drill-change.mjs +76 -0
- package/dist/drill-crumbs.mjs +113 -0
- package/dist/drill-distinct.mjs +130 -0
- package/dist/drill-explain.mjs +64 -0
- package/dist/drill-identity.mjs +35 -0
- package/dist/drill-item-id.mjs +35 -0
- package/dist/drill-items.mjs +132 -0
- package/dist/drill-open.mjs +169 -0
- package/dist/drill-seal.mjs +170 -0
- package/dist/drill-secret.mjs +14 -0
- package/dist/drill-share.mjs +53 -0
- package/dist/drill-summary.mjs +158 -0
- package/dist/drill-targets.mjs +53 -0
- package/dist/drill-totals.mjs +8 -0
- package/dist/drill-views.mjs +175 -0
- package/dist/drill.mjs +157 -0
- package/dist/editing.mjs +2 -2
- package/dist/endpoints/dashboards.mjs +11 -3
- package/dist/endpoints/drill.mjs +55 -0
- package/dist/endpoints/index.d.mts +233 -2
- package/dist/endpoints/index.mjs +5 -1
- package/dist/endpoints/query.mjs +26 -4
- package/dist/execute.d.mts +19 -1
- package/dist/execute.mjs +15 -17
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +29 -2
- package/dist/mcp/drill.mjs +61 -0
- package/dist/mcp/format.mjs +27 -3
- package/dist/mcp/index.d.mts +15 -4
- package/dist/mcp/index.mjs +13 -7
- package/dist/mcp/query.d.mts +7 -2
- package/dist/mcp/query.mjs +7 -3
- package/dist/node-postgres.d.mts +8 -4
- package/dist/node-postgres.mjs +29 -6
- package/dist/owner.mjs +3 -3
- package/dist/postgres-connection.d.mts +8 -2
- package/dist/postgres-connection.mjs +2 -1
- package/dist/react/Dashboard.d.mts +10 -5
- package/dist/react/Dashboard.mjs +51 -23
- package/dist/react/DashboardList.mjs +30 -2
- package/dist/react/Discard.mjs +7 -2
- package/dist/react/Grid.mjs +12 -5
- package/dist/react/Header.mjs +9 -0
- package/dist/react/Parts.mjs +6 -2
- package/dist/react/ReviewPanel.mjs +13 -2
- package/dist/react/RowBody.d.mts +19 -0
- package/dist/react/RowBody.mjs +55 -0
- package/dist/react/Tile.d.mts +1 -1
- package/dist/react/Tile.mjs +54 -30
- package/dist/react/builder/state.d.mts +1 -1
- package/dist/react/client.d.mts +2 -0
- package/dist/react/client.mjs +1 -0
- package/dist/react/context.d.mts +15 -1
- package/dist/react/context.mjs +19 -4
- package/dist/react/drill/Bars.mjs +179 -0
- package/dist/react/drill/Controls.mjs +173 -0
- package/dist/react/drill/DashboardTile.d.mts +18 -0
- package/dist/react/drill/DashboardTile.mjs +107 -0
- package/dist/react/drill/DrillPanel.d.mts +31 -0
- package/dist/react/drill/DrillPanel.mjs +104 -0
- package/dist/react/drill/DrillTabs.mjs +52 -0
- package/dist/react/drill/Header.mjs +131 -0
- package/dist/react/drill/Items.d.mts +22 -0
- package/dist/react/drill/Items.mjs +164 -0
- package/dist/react/drill/ItemsFoot.mjs +60 -0
- package/dist/react/drill/Notes.mjs +58 -0
- package/dist/react/drill/PanelBody.mjs +74 -0
- package/dist/react/drill/PanelStates.mjs +37 -0
- package/dist/react/drill/board.d.mts +18 -0
- package/dist/react/drill/board.mjs +91 -0
- package/dist/react/drill/counts.mjs +14 -0
- package/dist/react/drill/host.mjs +26 -0
- package/dist/react/drill/item-parts.d.mts +5 -0
- package/dist/react/drill/item-parts.mjs +76 -0
- package/dist/react/drill/item-type.d.mts +26 -0
- package/dist/react/drill/item-type.mjs +7 -0
- package/dist/react/drill/lazy.d.mts +6 -0
- package/dist/react/drill/lazy.mjs +17 -0
- package/dist/react/drill/pages.mjs +48 -0
- package/dist/react/drill/panel-focus.mjs +51 -0
- package/dist/react/drill/props.d.mts +25 -0
- package/dist/react/drill/props.mjs +72 -0
- package/dist/react/drill/state.d.mts +18 -0
- package/dist/react/drill/state.mjs +68 -0
- package/dist/react/drill/useDrill.d.mts +46 -0
- package/dist/react/drill/useDrill.mjs +194 -0
- package/dist/react/drill/words.d.mts +98 -0
- package/dist/react/drill/words.mjs +77 -0
- package/dist/react/english.mjs +9 -1
- package/dist/react/format.d.mts +3 -3
- package/dist/react/format.mjs +34 -12
- package/dist/react/index.d.mts +27 -4
- package/dist/react/index.mjs +10 -3
- package/dist/react/messages.d.mts +14 -1
- package/dist/react/renderers/index.d.mts +10 -2
- package/dist/react/renderers/index.mjs +54 -14
- package/dist/react/renderers/list.d.mts +22 -0
- package/dist/react/renderers/list.mjs +118 -0
- package/dist/react/review-words.mjs +1 -1
- package/dist/react/review.mjs +2 -2
- package/dist/react/scope.mjs +2 -7
- package/dist/react/series.d.mts +37 -0
- package/dist/react/series.mjs +95 -0
- package/dist/react/theme.css +1823 -1296
- package/dist/react/theme.css.d.ts +1 -0
- package/dist/react/tile-store.mjs +15 -3
- package/dist/react/useBoard.d.mts +5 -0
- package/dist/react/useBoard.mjs +4 -1
- package/dist/react/useDashboard.d.mts +1 -0
- package/dist/react/useDashboard.mjs +2 -1
- package/dist/react/useTiles.mjs +50 -15
- package/dist/react/view.d.mts +9 -0
- package/dist/react/view.mjs +22 -10
- package/dist/reading.d.mts +2 -0
- package/dist/reading.mjs +9 -1
- package/dist/recharts/charts.d.mts +0 -1
- package/dist/recharts/charts.mjs +128 -34
- package/dist/recharts/index.d.mts +2 -2
- package/dist/recharts/index.mjs +2 -2
- package/dist/recharts/marks.mjs +83 -0
- package/dist/recharts/series.d.mts +2 -22
- package/dist/recharts/series.mjs +1 -64
- package/dist/records-read.mjs +44 -0
- package/dist/store/apply.mjs +5 -5
- package/dist/store/commands.mjs +4 -4
- package/dist/store/discard.mjs +7 -7
- package/dist/store/drafts.mjs +5 -5
- package/dist/store/editor.mjs +1 -1
- package/dist/store/publish.mjs +12 -12
- package/dist/store/reader.mjs +41 -22
- package/dist/store/review.mjs +16 -16
- package/dist/store/rows.mjs +20 -20
- package/dist/store/undo.mjs +3 -3
- package/dist/store/unpublished.mjs +4 -4
- package/dist/store/versions.mjs +14 -14
- package/dist/testing/adapter-suite.mjs +4 -4
- package/dist/tiles.mjs +37 -3
- package/package.json +8 -10
- package/dist/react/Records.d.mts +0 -12
- package/dist/react/Records.mjs +0 -97
- package/src/adapter/sql-adapter.ts +0 -95
- package/src/adapter/statement.ts +0 -185
- package/src/authorize.ts +0 -73
- package/src/body.ts +0 -169
- package/src/bounded.ts +0 -43
- package/src/cache.ts +0 -192
- package/src/checks.ts +0 -170
- package/src/custom-source.ts +0 -59
- package/src/dashboard-id.ts +0 -36
- package/src/dashboards.ts +0 -132
- package/src/editing.ts +0 -148
- package/src/endpoints/access.ts +0 -41
- package/src/endpoints/dashboards.ts +0 -92
- package/src/endpoints/drafts.ts +0 -138
- package/src/endpoints/index.ts +0 -21
- package/src/endpoints/meta.ts +0 -137
- package/src/endpoints/query.ts +0 -86
- package/src/endpoints/read.ts +0 -92
- package/src/endpoints/review.ts +0 -89
- package/src/endpoints/values.ts +0 -62
- package/src/endpoints/versions.ts +0 -104
- package/src/execute.ts +0 -207
- package/src/handler.ts +0 -232
- package/src/http.ts +0 -66
- package/src/index.ts +0 -163
- package/src/introspect.ts +0 -205
- package/src/mcp/api.ts +0 -59
- package/src/mcp/format.ts +0 -67
- package/src/mcp/index.ts +0 -151
- package/src/mcp/query.ts +0 -153
- package/src/mcp/resolve.ts +0 -114
- package/src/node-postgres.ts +0 -81
- package/src/owner.ts +0 -36
- package/src/postgres-connection.ts +0 -143
- package/src/postgres-store.ts +0 -82
- package/src/principal.ts +0 -39
- package/src/reading.ts +0 -56
- package/src/request-rows.ts +0 -23
- package/src/request.ts +0 -22
- package/src/storage.ts +0 -63
- package/src/store/apply.ts +0 -129
- package/src/store/commands.ts +0 -75
- package/src/store/conflicts.ts +0 -98
- package/src/store/create-tables.ts +0 -104
- package/src/store/discard.ts +0 -42
- package/src/store/drafts.ts +0 -133
- package/src/store/editor.ts +0 -28
- package/src/store/log.ts +0 -28
- package/src/store/publish.ts +0 -199
- package/src/store/publisher.ts +0 -21
- package/src/store/reader.ts +0 -139
- package/src/store/review.ts +0 -239
- package/src/store/rows.ts +0 -250
- package/src/store/tenant.ts +0 -28
- package/src/store/undo.ts +0 -56
- package/src/store/unpublished.ts +0 -33
- package/src/store/versions.ts +0 -106
- package/src/store/writer.ts +0 -19
- package/src/testing/adapter-suite.ts +0 -239
- package/src/testing/index.ts +0 -2
- package/src/tile-doc.ts +0 -46
- package/src/tiles.ts +0 -120
package/dist/mcp/index.mjs
CHANGED
|
@@ -4,7 +4,11 @@ import { refused } from "./format.mjs";
|
|
|
4
4
|
import { queryInput, runQuery } from "./query.mjs";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
// src/mcp/index.ts
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* An agent acts for its person: it keeps the person's id, so tenancy, row rules and `can` judge
|
|
9
|
+
* it exactly as the person, and is marked an agent, so its edits are a draft of its own and
|
|
10
|
+
* history says an agent made them. A viewer already marked as an agent is kept as it is.
|
|
11
|
+
*/
|
|
8
12
|
const asAgent = (viewer) => viewer.agent === void 0 ? {
|
|
9
13
|
...viewer,
|
|
10
14
|
agent: { for: viewer.id }
|
|
@@ -15,14 +19,14 @@ const HINT = "Fix the input and call again; dashboards_query with op describe li
|
|
|
15
19
|
* then run as the agent acting for the viewer. A refusal becomes a result the model can act on;
|
|
16
20
|
* anything else is a bug and throws.
|
|
17
21
|
*/
|
|
18
|
-
function guarded(schema, run) {
|
|
22
|
+
function guarded(schema, run, onError) {
|
|
19
23
|
return async (raw, viewer) => {
|
|
20
24
|
const parsed = schema.safeParse(raw);
|
|
21
25
|
if (!parsed.success) return refused(new HttpError(400, "BODY_INVALID", z.prettifyError(parsed.error)), HINT);
|
|
22
26
|
try {
|
|
23
27
|
return await run(parsed.data, asAgent(viewer));
|
|
24
28
|
} catch (error) {
|
|
25
|
-
return refused(error, HINT);
|
|
29
|
+
return refused(error, HINT, onError);
|
|
26
30
|
}
|
|
27
31
|
};
|
|
28
32
|
}
|
|
@@ -41,8 +45,9 @@ function dashboardTools(dashboards, options = {}) {
|
|
|
41
45
|
run: guarded(queryInput, (input, viewer) => runQuery({
|
|
42
46
|
dashboards,
|
|
43
47
|
viewer,
|
|
44
|
-
linkFor: options.linkFor
|
|
45
|
-
|
|
48
|
+
linkFor: options.linkFor,
|
|
49
|
+
itemLinks: options.itemLinks ?? dashboards.options?.itemLinks
|
|
50
|
+
}, input), options.onError)
|
|
46
51
|
};
|
|
47
52
|
if (options.api === false) return [query];
|
|
48
53
|
const api = apiInput(dashboards.routes);
|
|
@@ -56,12 +61,13 @@ function dashboardTools(dashboards, options = {}) {
|
|
|
56
61
|
destructiveHint: true,
|
|
57
62
|
openWorldHint: false
|
|
58
63
|
},
|
|
59
|
-
run: guarded(api, (input, viewer) => runApi(dashboards, viewer, input))
|
|
64
|
+
run: guarded(api, (input, viewer) => runApi(dashboards, viewer, input), options.onError)
|
|
60
65
|
}];
|
|
61
66
|
}
|
|
62
67
|
/**
|
|
63
68
|
* Adds the two tools to an MCP server you already run. `viewer` reads the person from the
|
|
64
|
-
* call (`extra.authInfo` from your MCP auth); none refuses the call.
|
|
69
|
+
* call (`extra.authInfo` from your MCP auth); none refuses the call. It is typed from the
|
|
70
|
+
* server's model, as `deriveDashboards`'s own `viewer` is: with tenant keys, each is required.
|
|
65
71
|
*/
|
|
66
72
|
function addDashboardTools(server, dashboards, options) {
|
|
67
73
|
for (const tool of dashboardTools(dashboards, options)) {
|
package/dist/mcp/query.d.mts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { DashServer } from "../index.mjs";
|
|
2
2
|
import "./format.mjs";
|
|
3
|
-
import { DashOptions, Viewer } from "derive-dashboards/core";
|
|
3
|
+
import { DashOptions, ItemLinks, Viewer } from "derive-dashboards/core";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
/** What the tools need of `deriveDashboards(...)`: its calls, by name and by path. */
|
|
6
|
-
export type Callable = Pick<DashServer<DashOptions>, "api" | "call" | "routes"
|
|
6
|
+
export type Callable = Pick<DashServer<DashOptions>, "api" | "call" | "routes"> & {
|
|
7
|
+
options?: {
|
|
8
|
+
model: unknown;
|
|
9
|
+
itemLinks?: ItemLinks | undefined;
|
|
10
|
+
};
|
|
11
|
+
};
|
package/dist/mcp/query.mjs
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
import { HttpError } from "../http.mjs";
|
|
2
|
+
import { drillRows } from "./drill.mjs";
|
|
2
3
|
import { answerText, ok, table } from "./format.mjs";
|
|
3
4
|
import { dashboardOf, resolveQuery, sourceOf } from "./resolve.mjs";
|
|
4
|
-
import { picksSchema, wireQuerySchema } from "derive-dashboards/core/schema";
|
|
5
|
+
import { drillStateSchema, picksSchema, wireQuerySchema } from "derive-dashboards/core/schema";
|
|
5
6
|
import { z } from "zod";
|
|
6
7
|
// src/mcp/query.ts
|
|
7
8
|
/** A question, with `kind` optional since there is only one kind. */
|
|
8
9
|
const question = wireQuerySchema.extend({ kind: z.literal("aggregate").optional() });
|
|
9
|
-
const queryInput = z.
|
|
10
|
+
const queryInput = z.strictObject({
|
|
10
11
|
op: z.enum([
|
|
11
12
|
"describe",
|
|
12
13
|
"ask",
|
|
13
14
|
"rows",
|
|
14
15
|
"list",
|
|
15
16
|
"open"
|
|
16
|
-
]).describe("describe: what can be asked (sources, measures, fields). ask: answer a question. rows: the records behind a question. list: the dashboards. open: one dashboard, every tile answered."),
|
|
17
|
+
]).describe("describe: what can be asked (sources, measures, fields). ask: answer a question. rows: the records behind a question, or behind a mark (drill). list: the dashboards. open: one dashboard, every tile answered."),
|
|
17
18
|
query: question.optional().describe("For ask and rows. Sources, measures and fields may be named by id or label. Ids: measures m0, m1...; dimensions d0, d1..."),
|
|
18
19
|
source: z.string().optional().describe("For describe: one source only."),
|
|
19
20
|
dashboard: z.string().optional().describe("For open: the dashboard's title or id."),
|
|
20
21
|
filters: picksSchema.optional().describe("For open: values for the dashboard's filters, by control id."),
|
|
22
|
+
drill: drillStateSchema.optional().describe("For rows: the rows behind one mark. Take origin, execution and a selection from an answer's drill (ask or open), as { origin, execution, path: [selection], view: { by: 'items' } }."),
|
|
23
|
+
after: z.string().optional().describe("For rows of a drill: the next page, from the answer before."),
|
|
21
24
|
limit: z.number().int().min(1).max(200).optional().describe("For rows: how many (50 by default).")
|
|
22
25
|
});
|
|
23
26
|
const meta = (c) => c.dashboards.api.meta({ viewer: c.viewer });
|
|
@@ -50,6 +53,7 @@ async function ask(c, input) {
|
|
|
50
53
|
return ok(answerText(answer), answer);
|
|
51
54
|
}
|
|
52
55
|
async function rows(c, input) {
|
|
56
|
+
if (input.drill !== void 0) return drillRows(c, input.drill, input);
|
|
53
57
|
const body = {
|
|
54
58
|
query: await resolved(c, input),
|
|
55
59
|
limit: input.limit ?? 50
|
package/dist/node-postgres.d.mts
CHANGED
|
@@ -10,11 +10,14 @@ export type PgQueryable = {
|
|
|
10
10
|
rows: unknown[];
|
|
11
11
|
}>;
|
|
12
12
|
};
|
|
13
|
+
/** A pooled client: node-postgres gives its backend's `processID`, which a cancel names. */
|
|
14
|
+
type PgClient = PgQueryable & {
|
|
15
|
+
release(destroy?: boolean | Error): void;
|
|
16
|
+
processID?: number;
|
|
17
|
+
};
|
|
13
18
|
/** What `nodePostgres` uses of a node-postgres `Pool`: `query`, and `connect` for a transaction. */
|
|
14
19
|
export type PgPool = PgQueryable & {
|
|
15
|
-
connect(): Promise<
|
|
16
|
-
release(destroy?: boolean | Error): void;
|
|
17
|
-
}>;
|
|
20
|
+
connect(): Promise<PgClient>;
|
|
18
21
|
};
|
|
19
22
|
/**
|
|
20
23
|
* The query connection and the store for a node-postgres `Pool`, set up the safe way: each
|
|
@@ -30,4 +33,5 @@ export declare function nodePostgres(pool: PgPool, options?: {
|
|
|
30
33
|
}): {
|
|
31
34
|
connection: IntrospectingConnection;
|
|
32
35
|
store: ReturnType<typeof postgresStore>;
|
|
33
|
-
};
|
|
36
|
+
};
|
|
37
|
+
export {};
|
package/dist/node-postgres.mjs
CHANGED
|
@@ -1,12 +1,35 @@
|
|
|
1
1
|
import { postgresConnection } from "./postgres-connection.mjs";
|
|
2
2
|
import { postgresStore } from "./postgres-store.mjs";
|
|
3
3
|
// src/node-postgres.ts
|
|
4
|
+
/**
|
|
5
|
+
* Cancels the client's running statement from another connection when the request aborts, so
|
|
6
|
+
* a statement nobody waits for stops in the database and gives its connection back.
|
|
7
|
+
*/
|
|
8
|
+
async function cancelling(pool, client, signal, work) {
|
|
9
|
+
const pid = "processID" in client && typeof client.processID === "number" ? client.processID : void 0;
|
|
10
|
+
if (signal === void 0 || pid === void 0) return work;
|
|
11
|
+
const cancel = () => {
|
|
12
|
+
pool.query({
|
|
13
|
+
text: "SELECT pg_cancel_backend($1)",
|
|
14
|
+
values: [pid]
|
|
15
|
+
}).catch(() => null);
|
|
16
|
+
};
|
|
17
|
+
signal.addEventListener("abort", cancel, { once: true });
|
|
18
|
+
try {
|
|
19
|
+
return await work;
|
|
20
|
+
} finally {
|
|
21
|
+
signal.removeEventListener("abort", cancel);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
4
24
|
/** Rows as arrays in select order, for queries; as objects by column, for the store. */
|
|
5
|
-
const arrays = (client) => async (text, params) =>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
25
|
+
const arrays = (client, pool) => async (text, params, options) => {
|
|
26
|
+
const work = client.query({
|
|
27
|
+
text,
|
|
28
|
+
values: [...params],
|
|
29
|
+
rowMode: "array"
|
|
30
|
+
});
|
|
31
|
+
return (pool === void 0 ? await work : await cancelling(pool, client, options?.signal, work)).rows;
|
|
32
|
+
};
|
|
10
33
|
const objects = (client) => async (text, params) => (await client.query({
|
|
11
34
|
text,
|
|
12
35
|
values: [...params]
|
|
@@ -48,7 +71,7 @@ function nodePostgres(pool, options = {}) {
|
|
|
48
71
|
...options.id === void 0 ? {} : { id: options.id },
|
|
49
72
|
run: arrays(pool),
|
|
50
73
|
sendsBegin: true,
|
|
51
|
-
transaction: (fn, begin) => inTransaction(pool, begin, (client) => fn(arrays(client)))
|
|
74
|
+
transaction: (fn, begin) => inTransaction(pool, begin, (client) => fn(arrays(client, pool)))
|
|
52
75
|
}),
|
|
53
76
|
store: postgresStore({
|
|
54
77
|
run: objects(pool),
|
package/dist/owner.mjs
CHANGED
|
@@ -5,8 +5,8 @@ import { principalTenant } from "derive-dashboards/core";
|
|
|
5
5
|
// src/owner.ts
|
|
6
6
|
/** Who made a stored dashboard, as `can` receives it. */
|
|
7
7
|
const ownerOf = (row) => ({
|
|
8
|
-
id: String(row
|
|
9
|
-
kind: row
|
|
8
|
+
id: String(row.owner_id),
|
|
9
|
+
kind: row.owner_kind === "agent" ? "agent" : "user"
|
|
10
10
|
});
|
|
11
11
|
/**
|
|
12
12
|
* A dashboard as `can` sees it: its id, and who made it when it is stored, so a host's rule
|
|
@@ -21,7 +21,7 @@ async function dashboardResource(options, request, principal, id) {
|
|
|
21
21
|
};
|
|
22
22
|
const tenant = principalTenant(principal);
|
|
23
23
|
const row = await requestDashboardRow(request, adapter, tenant, parseDashboardId(id));
|
|
24
|
-
if (row === null || row
|
|
24
|
+
if (row === null || row.default_of !== null) return {
|
|
25
25
|
kind: "dashboard",
|
|
26
26
|
id
|
|
27
27
|
};
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { IntrospectingConnection } from "derive-dashboards/core";
|
|
2
|
-
/**
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Runs one statement with its parameters and returns its rows as arrays, in select order.
|
|
4
|
+
* `signal` aborts when the request no longer wants the answer (the person moved on): a driver
|
|
5
|
+
* that can should cancel the statement in the database then (`nodePostgres` does).
|
|
6
|
+
*/
|
|
7
|
+
export type RunSql = (text: string, params: readonly unknown[], options?: {
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
}) => Promise<readonly (readonly unknown[])[]>;
|
|
4
10
|
export type PostgresConnectionOptions = {
|
|
5
11
|
/** Defaults to "main". */
|
|
6
12
|
id?: string;
|
|
@@ -40,7 +40,8 @@ function sessionOf(run, options, concurrent) {
|
|
|
40
40
|
options.signal.throwIfAborted();
|
|
41
41
|
if (Date.now() >= options.deadline) throw pastDeadline();
|
|
42
42
|
try {
|
|
43
|
-
|
|
43
|
+
const rows = run(sql.text, sql.params, { signal: options.signal });
|
|
44
|
+
return { rows: arrayRows(await bounded(rows, options)) };
|
|
44
45
|
} catch (error) {
|
|
45
46
|
if (timedOut(error)) throw pastDeadline();
|
|
46
47
|
if (badValue(error)) throw new HttpError(400, "QUERY_INVALID", "A value does not fit its column's type in the database. Check the viewer's tenant values against the tenant columns, and the query's filter values.", { cause: error });
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ViewChange } from "./view.mjs";
|
|
2
|
+
import { DashboardDrillProps } from "./drill/board.mjs";
|
|
1
3
|
import { DashboardEvents } from "./useDashboard.mjs";
|
|
2
4
|
import { ViewState } from "derive-dashboards/core";
|
|
3
5
|
/**
|
|
@@ -7,10 +9,12 @@ import { ViewState } from "derive-dashboards/core";
|
|
|
7
9
|
* changed tiles are marked in place. Review and publish opens the review beside the canvas:
|
|
8
10
|
* every change, and over a newer version the merged result, then Publish. History opens the
|
|
9
11
|
* timeline in the same panel; any version can be looked at in place, restored or copied.
|
|
10
|
-
* Share copies a link with the tab and
|
|
12
|
+
* Share copies a link with the tab, filters and drill. A click on a bar, a point, a table row
|
|
13
|
+
* or a number opens what is behind it beside the dashboard (`drill={false}` turns it off).
|
|
11
14
|
*
|
|
12
|
-
* `view` and `onViewChange` let the host keep the tab and
|
|
13
|
-
* `decodeView`); `linkFor` makes the link Share copies. `editable={false}` shows
|
|
15
|
+
* `view` and `onViewChange` let the host keep the tab, filters and drill in its URL
|
|
16
|
+
* (`encodeView`, `decodeView`); `linkFor` makes the link Share copies. `editable={false}` shows
|
|
17
|
+
* it read-only.
|
|
14
18
|
*/
|
|
15
19
|
export type DashboardProps = {
|
|
16
20
|
id: string;
|
|
@@ -18,10 +22,11 @@ export type DashboardProps = {
|
|
|
18
22
|
editable?: boolean;
|
|
19
23
|
/** The tab and filters to show, when the host keeps them (from a link, say). */
|
|
20
24
|
view?: ViewState;
|
|
21
|
-
|
|
25
|
+
/** The view changed: `history` says whether Back should undo it (`push`, a drill step) or not. */
|
|
26
|
+
onViewChange?: (view: ViewState, change: ViewChange) => void;
|
|
22
27
|
/** What the host's `decodeView` could not read from a link, so the page says it was left out. */
|
|
23
28
|
linkDropped?: readonly string[];
|
|
24
29
|
/** The link Share copies for a view; by default, this page's address with the view in it. */
|
|
25
30
|
linkFor?: (view: ViewState) => string;
|
|
26
|
-
} & DashboardEvents;
|
|
31
|
+
} & DashboardEvents & DashboardDrillProps;
|
|
27
32
|
export declare function Dashboard(props: DashboardProps): import("react").JSX.Element;
|
package/dist/react/Dashboard.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Canvas } from "./Canvas.mjs";
|
|
2
2
|
import { useDashboards } from "./context.mjs";
|
|
3
|
+
import { DrillScope } from "./drill/board.mjs";
|
|
3
4
|
import { BuildPage } from "./Editing.mjs";
|
|
4
5
|
import { Bars, Side } from "./Parts.mjs";
|
|
5
6
|
import { ScopeContext } from "./scope.mjs";
|
|
@@ -13,21 +14,44 @@ function focusOpener(widgetId) {
|
|
|
13
14
|
((widgetId === void 0 ? null : document.querySelector(`.dd-cell[data-widget="${CSS.escape(widgetId)}"] .dd-tile-edit`)) ?? document.querySelector("[data-focus-after]"))?.focus();
|
|
14
15
|
});
|
|
15
16
|
}
|
|
17
|
+
/** The dashboard could not be read and there is nothing to show: say so, and offer to try again. */
|
|
18
|
+
function LoadFailed({ onRetry }) {
|
|
19
|
+
const { messages } = useDashboards();
|
|
20
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
21
|
+
className: "dd-tile-error",
|
|
22
|
+
role: "alert",
|
|
23
|
+
children: [
|
|
24
|
+
messages.dashboardFailed,
|
|
25
|
+
" ",
|
|
26
|
+
/* @__PURE__ */ jsx("button", {
|
|
27
|
+
type: "button",
|
|
28
|
+
className: "dd-button dd-quiet",
|
|
29
|
+
onClick: onRetry,
|
|
30
|
+
children: messages.drillRetry
|
|
31
|
+
})
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/** The dashboard stays while the server cannot be reached, and says so quietly. */
|
|
36
|
+
function Unreachable() {
|
|
37
|
+
const { messages } = useDashboards();
|
|
38
|
+
return /* @__PURE__ */ jsx("p", {
|
|
39
|
+
className: "dd-tile-note",
|
|
40
|
+
role: "status",
|
|
41
|
+
children: messages.dashboardUnreachable
|
|
42
|
+
});
|
|
43
|
+
}
|
|
16
44
|
function Dashboard(props) {
|
|
17
45
|
const { messages } = useDashboards();
|
|
18
46
|
const board = useBoard(props);
|
|
19
47
|
const [building, setBuilding] = useState();
|
|
20
48
|
const [fresh, setFresh] = useState();
|
|
21
|
-
const { error, edit, shown,
|
|
49
|
+
const { error, edit, shown, view } = board;
|
|
22
50
|
if (board.missing) return /* @__PURE__ */ jsx("div", {
|
|
23
51
|
className: "dd-tile-state",
|
|
24
52
|
children: messages.dashboardMissing
|
|
25
53
|
});
|
|
26
|
-
if (error) return /* @__PURE__ */ jsx(
|
|
27
|
-
className: "dd-tile-error",
|
|
28
|
-
role: "alert",
|
|
29
|
-
children: messages.dashboardFailed
|
|
30
|
-
});
|
|
54
|
+
if (error) return /* @__PURE__ */ jsx(LoadFailed, { onRetry: board.refresh });
|
|
31
55
|
if (shown?.tab === void 0) return /* @__PURE__ */ jsx("div", {
|
|
32
56
|
className: "dd-dashboard",
|
|
33
57
|
"aria-busy": "true"
|
|
@@ -51,25 +75,29 @@ function Dashboard(props) {
|
|
|
51
75
|
picks: view.picks,
|
|
52
76
|
...editing ? { draft: true } : {}
|
|
53
77
|
},
|
|
54
|
-
children: /* @__PURE__ */ jsxs(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
78
|
+
children: /* @__PURE__ */ jsxs(DrillScope, {
|
|
79
|
+
id: props.id,
|
|
80
|
+
board,
|
|
81
|
+
drill: props,
|
|
58
82
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
59
83
|
className: "dd-board",
|
|
60
|
-
children: [
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
84
|
+
children: [
|
|
85
|
+
/* @__PURE__ */ jsx(Bars, {
|
|
86
|
+
board,
|
|
87
|
+
props
|
|
88
|
+
}),
|
|
89
|
+
board.unreachable ? /* @__PURE__ */ jsx(Unreachable, {}) : null,
|
|
90
|
+
/* @__PURE__ */ jsx(Canvas, {
|
|
91
|
+
board,
|
|
92
|
+
shown: {
|
|
93
|
+
...shown,
|
|
94
|
+
tab
|
|
95
|
+
},
|
|
96
|
+
fresh,
|
|
97
|
+
onBuild: setBuilding,
|
|
98
|
+
dashboard: props
|
|
99
|
+
})
|
|
100
|
+
]
|
|
73
101
|
}), /* @__PURE__ */ jsx(Side, {
|
|
74
102
|
board,
|
|
75
103
|
props
|
|
@@ -101,6 +101,34 @@ function Items({ items, current, onOpen, linkFor }) {
|
|
|
101
101
|
})] }, d.id)) });
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
|
+
* The built-in dashboards (`default:` ids) first, under a heading, then the ones made here, when
|
|
105
|
+
* the list has both; otherwise one plain list.
|
|
106
|
+
*/
|
|
107
|
+
function Groups(props) {
|
|
108
|
+
const { messages } = useDashboards();
|
|
109
|
+
const builtIn = props.items.filter((d) => d.id.startsWith("default:"));
|
|
110
|
+
const made = props.items.filter((d) => !d.id.startsWith("default:"));
|
|
111
|
+
if (builtIn.length === 0 || made.length === 0) return /* @__PURE__ */ jsx(Items, { ...props });
|
|
112
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
113
|
+
/* @__PURE__ */ jsx("h3", {
|
|
114
|
+
className: "dd-list-group",
|
|
115
|
+
children: messages.builtIn
|
|
116
|
+
}),
|
|
117
|
+
/* @__PURE__ */ jsx(Items, {
|
|
118
|
+
...props,
|
|
119
|
+
items: builtIn
|
|
120
|
+
}),
|
|
121
|
+
/* @__PURE__ */ jsx("h3", {
|
|
122
|
+
className: "dd-list-group",
|
|
123
|
+
children: messages.madeHere
|
|
124
|
+
}),
|
|
125
|
+
/* @__PURE__ */ jsx(Items, {
|
|
126
|
+
...props,
|
|
127
|
+
items: made
|
|
128
|
+
})
|
|
129
|
+
] });
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
104
132
|
* Every dashboard the viewer can open, theirs not yet published marked as drafts, and
|
|
105
133
|
* "+ New dashboard" for those who may make one, which opens it straight into editing. A long
|
|
106
134
|
* list gets a search box. The host decides where a dashboard opens (`onOpen` gets its id) and,
|
|
@@ -132,7 +160,7 @@ function DashboardList({ current, onOpen, linkFor }) {
|
|
|
132
160
|
role: "alert",
|
|
133
161
|
children: error
|
|
134
162
|
}),
|
|
135
|
-
list.error === void 0 ? null : /* @__PURE__ */ jsx("p", {
|
|
163
|
+
list.error === void 0 || list.data !== void 0 ? null : /* @__PURE__ */ jsx("p", {
|
|
136
164
|
className: "dd-draft-error",
|
|
137
165
|
role: "alert",
|
|
138
166
|
children: messages.listFailed
|
|
@@ -143,7 +171,7 @@ function DashboardList({ current, onOpen, linkFor }) {
|
|
|
143
171
|
setSearch,
|
|
144
172
|
shown: shown.length
|
|
145
173
|
}),
|
|
146
|
-
/* @__PURE__ */ jsx(
|
|
174
|
+
/* @__PURE__ */ jsx(Groups, {
|
|
147
175
|
items: shown,
|
|
148
176
|
current,
|
|
149
177
|
onOpen,
|
package/dist/react/Discard.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useDashboards } from "./context.mjs";
|
|
2
2
|
import { isShifted } from "./marks.mjs";
|
|
3
|
-
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
// src/Discard.tsx
|
|
6
6
|
/**
|
|
@@ -69,14 +69,19 @@ function DiscardAsk(props) {
|
|
|
69
69
|
const { messages } = useDashboards();
|
|
70
70
|
const { edit, isNew, onKeep } = props;
|
|
71
71
|
useEscape(onKeep);
|
|
72
|
+
const question = useId();
|
|
72
73
|
return /* @__PURE__ */ jsxs("span", {
|
|
73
74
|
className: "dd-row",
|
|
74
75
|
children: [
|
|
75
|
-
/* @__PURE__ */ jsx("span", {
|
|
76
|
+
/* @__PURE__ */ jsx("span", {
|
|
77
|
+
id: question,
|
|
78
|
+
children: isNew ? messages.deleteNewAsk : messages.discardAsk(edit.draft?.changes.filter((c) => !isShifted(c)).length ?? 0)
|
|
79
|
+
}),
|
|
76
80
|
/* @__PURE__ */ jsx("button", {
|
|
77
81
|
ref: props.keep,
|
|
78
82
|
type: "button",
|
|
79
83
|
className: "dd-button dd-quiet",
|
|
84
|
+
"aria-describedby": question,
|
|
80
85
|
onClick: props.onKeep,
|
|
81
86
|
children: messages.keepEditing
|
|
82
87
|
}),
|
package/dist/react/Grid.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useArrange } from "./arrange.mjs";
|
|
2
|
-
import { Cell } from "./Cell.mjs";
|
|
2
|
+
import { Cell as Cell$1 } from "./Cell.mjs";
|
|
3
|
+
import { useDashboards } from "./context.mjs";
|
|
3
4
|
import { placeOf } from "./place.mjs";
|
|
4
5
|
import { Spaces } from "./Spaces.mjs";
|
|
5
6
|
import { useSameWidgets, useStable } from "./stable.mjs";
|
|
@@ -48,21 +49,27 @@ function useStep(edit, current) {
|
|
|
48
49
|
}
|
|
49
50
|
/** What a tile's own buttons call, each keeping one identity so tiles do not draw again. */
|
|
50
51
|
function useTileCalls(edit, props) {
|
|
52
|
+
const { messages } = useDashboards();
|
|
51
53
|
const onEdit = useStable(props.onEdit);
|
|
52
54
|
const tab = useRef(props.tab);
|
|
53
55
|
tab.current = props.tab;
|
|
56
|
+
const doc = useRef(props.doc);
|
|
57
|
+
doc.current = props.doc;
|
|
54
58
|
return {
|
|
55
59
|
onEdit,
|
|
56
60
|
onRemove: useStable((id) => {
|
|
57
61
|
const order = readingOrder(tab.current.layout).map((i) => i.widget);
|
|
58
62
|
const at = order.indexOf(id);
|
|
59
63
|
const next = order[at + 1] ?? order[at - 1];
|
|
64
|
+
const title = doc.current.widgets[id]?.title ?? "";
|
|
60
65
|
const remove = async () => {
|
|
61
|
-
await edit.apply([{
|
|
66
|
+
if (!await edit.apply([{
|
|
62
67
|
type: "widget.remove",
|
|
63
68
|
id
|
|
64
|
-
}]);
|
|
65
|
-
if (next !== void 0) focusIn(next, ".dd-tile-
|
|
69
|
+
}])) return;
|
|
70
|
+
if (next !== void 0) focusIn(next, ".dd-tile-edit");
|
|
71
|
+
const said = document.querySelector(".dd-placed");
|
|
72
|
+
if (said !== null) said.textContent = messages.removedTile(title);
|
|
66
73
|
};
|
|
67
74
|
remove();
|
|
68
75
|
}),
|
|
@@ -107,7 +114,7 @@ function Grid(props) {
|
|
|
107
114
|
/* @__PURE__ */ jsx(Drop, { at: arrange.drop }),
|
|
108
115
|
cells.map((item) => {
|
|
109
116
|
const widget = widgets[item.widget];
|
|
110
|
-
return widget === void 0 ? null : /* @__PURE__ */ jsx(Cell, {
|
|
117
|
+
return widget === void 0 ? null : /* @__PURE__ */ jsx(Cell$1, {
|
|
111
118
|
item,
|
|
112
119
|
widget,
|
|
113
120
|
result: props.results.get(item.widget),
|
package/dist/react/Header.mjs
CHANGED
|
@@ -47,6 +47,15 @@ function Title({ doc, edit, isNew }) {
|
|
|
47
47
|
function ShareButton({ link }) {
|
|
48
48
|
const { messages } = useDashboards();
|
|
49
49
|
const [said, setSaid] = useState();
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (said !== messages.linkCopied) return;
|
|
52
|
+
const wait = setTimeout(() => {
|
|
53
|
+
setSaid(void 0);
|
|
54
|
+
}, 4e3);
|
|
55
|
+
return () => {
|
|
56
|
+
clearTimeout(wait);
|
|
57
|
+
};
|
|
58
|
+
}, [said, messages.linkCopied]);
|
|
50
59
|
const share = async () => {
|
|
51
60
|
const url = link();
|
|
52
61
|
try {
|
package/dist/react/Parts.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useDashboards } from "./context.mjs";
|
|
2
|
+
import { DrillSide } from "./drill/board.mjs";
|
|
2
3
|
import { EditBar } from "./EditBar.mjs";
|
|
3
4
|
import { HistoryPanel, VersionBar } from "./History.mjs";
|
|
4
5
|
import { PublishedNotice } from "./Notice.mjs";
|
|
@@ -77,7 +78,7 @@ function Bars({ board, props }) {
|
|
|
77
78
|
})
|
|
78
79
|
] });
|
|
79
80
|
}
|
|
80
|
-
/** The side panel: the review, or the
|
|
81
|
+
/** The side panel: the review, the history timeline, or the drill open. */
|
|
81
82
|
function Side({ board, props }) {
|
|
82
83
|
const { panels, review, edit } = board;
|
|
83
84
|
if (panels.panel === "review") return /* @__PURE__ */ jsx(ReviewPanel, {
|
|
@@ -93,6 +94,9 @@ function Side({ board, props }) {
|
|
|
93
94
|
onSelect: board.canEdit ? panels.setPreviewing : void 0,
|
|
94
95
|
onClose: panels.close
|
|
95
96
|
});
|
|
96
|
-
return
|
|
97
|
+
return /* @__PURE__ */ jsx(DrillSide, {
|
|
98
|
+
board,
|
|
99
|
+
props
|
|
100
|
+
});
|
|
97
101
|
}
|
|
98
102
|
export { Bars, Side };
|
|
@@ -5,6 +5,12 @@ import { ChangeList, Panel } from "./Panel.mjs";
|
|
|
5
5
|
import { closeGapsCommands } from "derive-dashboards/core";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
// src/ReviewPanel.tsx
|
|
8
|
+
/** The refused changes in words, each once: "Moved “Tasks closed”; resized “Tasks closed”". */
|
|
9
|
+
function changesIn(refusals, words) {
|
|
10
|
+
const said = refusals.map((r) => words.undone(r.body.type, r.widget?.title));
|
|
11
|
+
const unique = [...new Set(said)].join("; ");
|
|
12
|
+
return unique.charAt(0).toUpperCase() + unique.slice(1);
|
|
13
|
+
}
|
|
8
14
|
/**
|
|
9
15
|
* The changes to one widget that no longer apply, for one reason: what they were, why, and the
|
|
10
16
|
* ways out. Drop drops them all, since dropping one alone leaves the others still refused. Put
|
|
@@ -18,7 +24,12 @@ function Refused(props) {
|
|
|
18
24
|
const { widget } = refusal;
|
|
19
25
|
return /* @__PURE__ */ jsxs("li", {
|
|
20
26
|
className: "dd-refused",
|
|
21
|
-
children: [/* @__PURE__ */ jsxs("p", { children: [
|
|
27
|
+
children: [/* @__PURE__ */ jsxs("p", { children: [
|
|
28
|
+
/* @__PURE__ */ jsx("strong", { children: changesIn(refusals, messages) }),
|
|
29
|
+
":",
|
|
30
|
+
" ",
|
|
31
|
+
refusal.issue.code === "WIDGET_UNKNOWN" ? messages.widgetGone : refusal.issue.message
|
|
32
|
+
] }), /* @__PURE__ */ jsxs("div", {
|
|
22
33
|
className: "dd-row",
|
|
23
34
|
children: [/* @__PURE__ */ jsx(ConfirmButton, {
|
|
24
35
|
label: messages.dropChange,
|
|
@@ -139,7 +150,7 @@ function PublishFoot({ review, busy }) {
|
|
|
139
150
|
"data-publish": "",
|
|
140
151
|
disabled: busy || nothing || waiting,
|
|
141
152
|
onClick: () => void review.publish(),
|
|
142
|
-
children: messages.publishVersion(
|
|
153
|
+
children: preview === void 0 ? messages.publish : messages.publishVersion(preview.head + 1)
|
|
143
154
|
})
|
|
144
155
|
]
|
|
145
156
|
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* What one row of a list shows, for a drill's Items and the list widget alike: a title, a meta
|
|
4
|
+
* line, an optional lead (an avatar), badge and trailing value, and a chevron when it opens.
|
|
5
|
+
*/
|
|
6
|
+
export type RowContent = {
|
|
7
|
+
title: string;
|
|
8
|
+
meta: readonly string[];
|
|
9
|
+
badge?: {
|
|
10
|
+
text: string;
|
|
11
|
+
tone?: string | undefined;
|
|
12
|
+
} | undefined;
|
|
13
|
+
/** Before the text: an avatar's initials. */
|
|
14
|
+
lead?: string | undefined;
|
|
15
|
+
/** After the text: one number. */
|
|
16
|
+
value?: string | undefined;
|
|
17
|
+
/** The row opens something: a chevron says so. */
|
|
18
|
+
opens?: boolean;
|
|
19
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
// src/RowBody.tsx
|
|
3
|
+
/** The class names of one family of rows: `dd-item-*` (Items) or `dd-lines-*` (the list widget). */
|
|
4
|
+
const CLASSES = {
|
|
5
|
+
item: {
|
|
6
|
+
lead: "dd-item-lead",
|
|
7
|
+
text: "dd-item-text",
|
|
8
|
+
title: "dd-item-title",
|
|
9
|
+
meta: "dd-item-meta",
|
|
10
|
+
value: "dd-item-value"
|
|
11
|
+
},
|
|
12
|
+
lines: {
|
|
13
|
+
lead: "dd-lines-avatar",
|
|
14
|
+
text: "dd-lines-text",
|
|
15
|
+
title: "dd-lines-title",
|
|
16
|
+
meta: "dd-lines-sub",
|
|
17
|
+
value: "dd-lines-meta"
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
/** One row's parts, the one markup every list of rows shares. */
|
|
21
|
+
function RowBody({ row, family }) {
|
|
22
|
+
const c = CLASSES[family];
|
|
23
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
24
|
+
row.lead === void 0 ? null : /* @__PURE__ */ jsx("span", {
|
|
25
|
+
className: c.lead,
|
|
26
|
+
"aria-hidden": "true",
|
|
27
|
+
children: row.lead
|
|
28
|
+
}),
|
|
29
|
+
/* @__PURE__ */ jsxs("span", {
|
|
30
|
+
className: c.text,
|
|
31
|
+
children: [/* @__PURE__ */ jsx("strong", {
|
|
32
|
+
className: c.title,
|
|
33
|
+
children: row.title
|
|
34
|
+
}), family === "item" && row.meta.length === 0 ? null : /* @__PURE__ */ jsx("span", {
|
|
35
|
+
className: c.meta,
|
|
36
|
+
children: row.meta.join(" · ")
|
|
37
|
+
})]
|
|
38
|
+
}),
|
|
39
|
+
row.badge === void 0 ? null : /* @__PURE__ */ jsx("span", {
|
|
40
|
+
className: "dd-item-badge",
|
|
41
|
+
"data-tone": row.badge.tone ?? "neutral",
|
|
42
|
+
children: row.badge.text
|
|
43
|
+
}),
|
|
44
|
+
row.value === void 0 ? null : /* @__PURE__ */ jsx("span", {
|
|
45
|
+
className: c.value,
|
|
46
|
+
children: row.value
|
|
47
|
+
}),
|
|
48
|
+
row.opens === true ? /* @__PURE__ */ jsx("span", {
|
|
49
|
+
className: "dd-item-go",
|
|
50
|
+
"aria-hidden": "true",
|
|
51
|
+
children: "›"
|
|
52
|
+
}) : null
|
|
53
|
+
] });
|
|
54
|
+
}
|
|
55
|
+
export { RowBody };
|