@malloy-publisher/sdk 0.2.7 → 0.3.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 +180 -204
- package/dist/DocumentStorageProvider-BeBD0uWc.cjs.js +134 -0
- package/dist/DocumentStorageProvider-tGvodI8f.es.js +24268 -0
- package/dist/RenderedResult-CPi6uQWq.cjs.js +115 -0
- package/dist/RenderedResult-mDE-4u8S.es.js +542 -0
- package/dist/{ServerProvider-xXW1HJOJ.cjs.js → ServerProvider-CH71GsoL.cjs.js} +1 -1
- package/dist/{ServerProvider-ksC5Su_x.es.js → ServerProvider-X2Ma0HRs.es.js} +324 -359
- package/dist/builder/index.cjs.js +105 -0
- package/dist/builder/index.d.ts +2 -0
- package/dist/builder/index.es.js +9561 -0
- package/dist/builder-entry.d.ts +8 -0
- package/dist/client/api.d.ts +13 -1
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/ApiErrorDisplay.d.ts +1 -2
- package/dist/components/Dashboard/Dashboard.d.ts +23 -16
- package/dist/components/Dashboard/DashboardGrid.d.ts +67 -0
- package/dist/components/Dashboard/DashboardTile.d.ts +6 -1
- package/dist/components/Dashboard/ExploreDialog.d.ts +18 -0
- package/dist/components/Dashboard/RowsDialog.d.ts +47 -0
- package/dist/components/Dashboard/TileCard.d.ts +44 -0
- package/dist/components/Dashboard/index.d.ts +2 -0
- package/dist/components/Dashboard/promoteMeasureRow.d.ts +40 -0
- package/dist/components/Dashboard/telemetry.d.ts +43 -0
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +35 -0
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +29 -0
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +112 -0
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +32 -0
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +15 -0
- package/dist/components/DashboardBuilder/DrillDialog.d.ts +15 -0
- package/dist/components/DashboardBuilder/FilterDialog.d.ts +54 -0
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +17 -0
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +20 -0
- package/dist/components/DashboardBuilder/TileFrame.d.ts +42 -0
- package/dist/components/DashboardBuilder/TileMenu.d.ts +24 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +62 -0
- package/dist/components/DashboardBuilder/controls.d.ts +157 -0
- package/dist/components/DashboardBuilder/diff.d.ts +35 -0
- package/dist/components/DashboardBuilder/document.d.ts +218 -0
- package/dist/components/DashboardBuilder/layout.d.ts +71 -0
- package/dist/components/DashboardBuilder/malloyText.d.ts +45 -0
- package/dist/components/DashboardBuilder/preview.d.ts +60 -0
- package/dist/components/DashboardBuilder/readDocument.d.ts +106 -0
- package/dist/components/DashboardBuilder/sortable.d.ts +51 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +44 -0
- package/dist/components/DashboardBuilder/testing/fixtures.d.ts +10 -0
- package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +22 -0
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +63 -0
- package/dist/components/DashboardBuilder/useDraft.d.ts +13 -0
- package/dist/components/DashboardBuilder/useFilterForm.d.ts +65 -0
- package/dist/components/DashboardBuilder/useTileReorder.d.ts +22 -0
- package/dist/components/DashboardBuilder/useTileResize.d.ts +29 -0
- package/dist/components/DocumentStorage/BrowserDocumentStorage.d.ts +14 -0
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +58 -0
- package/dist/components/DocumentStorage/DocumentStorageProvider.d.ts +25 -0
- package/dist/components/DocumentStorage/index.d.ts +3 -0
- package/dist/components/FloatingIconButton.d.ts +16 -0
- package/dist/components/Model/index.d.ts +0 -1
- package/dist/components/Prose.d.ts +46 -0
- package/dist/components/RenderedResult/RenderedResult.d.ts +12 -0
- package/dist/components/RenderedResult/ResultContainer.d.ts +7 -1
- package/dist/components/RenderedResult/ResultPanel.d.ts +30 -0
- package/dist/components/RenderedResult/index.d.ts +2 -0
- package/dist/components/RenderedResult/resultSizing.d.ts +183 -0
- package/dist/components/drill/index.d.ts +2 -1
- package/dist/components/drill/resolveDrill.d.ts +22 -0
- package/dist/components/drill/useDrill.d.ts +11 -2
- package/dist/components/drill/useDrillSelf.d.ts +46 -0
- package/dist/components/given/filterValue.d.ts +63 -0
- package/dist/components/given/index.d.ts +1 -0
- package/dist/components/given/useGivenUrlParams.d.ts +39 -0
- package/dist/components/index.d.ts +3 -3
- package/dist/components/styles.d.ts +3 -7
- package/dist/core-8NVBCLZh.cjs.js +148 -0
- package/dist/{core-BY7vB5gN.es.js → core-B8oMW4sm.es.js} +3540 -2335
- package/dist/hooks/index.d.ts +3 -1
- package/dist/hooks/useDocumentControls.d.ts +70 -0
- package/dist/hooks/useQueryResult.d.ts +40 -0
- package/dist/hooks/useSuggestOptions.d.ts +28 -12
- package/dist/index.cjs.js +34 -1
- package/dist/index.es.js +21487 -79
- package/dist/sdk.css +1 -1
- package/dist/styles.css +0 -1
- package/dist/utils/malloyLiteral.d.ts +11 -0
- package/package.json +25 -14
- package/src/builder-entry.ts +55 -0
- package/src/components/ApiErrorDisplay.tsx +1 -1
- package/src/components/Connections/EditConnectionDialog.tsx +96 -86
- package/src/components/Dashboard/Dashboard.spec.tsx +7 -10
- package/src/components/Dashboard/Dashboard.tsx +184 -229
- package/src/components/Dashboard/DashboardGrid.tsx +124 -0
- package/src/components/Dashboard/DashboardTile.spec.tsx +30 -6
- package/src/components/Dashboard/DashboardTile.tsx +67 -101
- package/src/components/Dashboard/ExploreDialog.tsx +84 -0
- package/src/components/Dashboard/RowsDialog.spec.ts +42 -0
- package/src/components/Dashboard/RowsDialog.tsx +234 -0
- package/src/components/Dashboard/TileCard.tsx +120 -0
- package/src/components/Dashboard/index.ts +2 -0
- package/src/components/Dashboard/promoteMeasureRow.spec.ts +207 -0
- package/src/components/Dashboard/promoteMeasureRow.ts +160 -0
- package/src/components/Dashboard/telemetry.ts +44 -0
- package/src/components/Dashboard/tileGridColumn.spec.ts +1 -1
- package/src/components/DashboardBuilder/AddTileDialog.tsx +249 -0
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +270 -0
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +858 -0
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +653 -0
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +211 -0
- package/src/components/DashboardBuilder/DashboardEditor.tsx +493 -0
- package/src/components/DashboardBuilder/DiffDialog.tsx +129 -0
- package/src/components/DashboardBuilder/DrillDialog.tsx +281 -0
- package/src/components/DashboardBuilder/FilterDialog.tsx +581 -0
- package/src/components/DashboardBuilder/FilterStrip.tsx +125 -0
- package/src/components/DashboardBuilder/SettingsPopover.tsx +168 -0
- package/src/components/DashboardBuilder/TileFrame.tsx +380 -0
- package/src/components/DashboardBuilder/TileMenu.tsx +188 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +215 -0
- package/src/components/DashboardBuilder/catalog.ts +225 -0
- package/src/components/DashboardBuilder/controls.spec.ts +243 -0
- package/src/components/DashboardBuilder/controls.ts +398 -0
- package/src/components/DashboardBuilder/diff.spec.ts +44 -0
- package/src/components/DashboardBuilder/diff.ts +93 -0
- package/src/components/DashboardBuilder/document.ts +209 -0
- package/src/components/DashboardBuilder/keepRowStructure.spec.ts +84 -0
- package/src/components/DashboardBuilder/layout.ts +143 -0
- package/src/components/DashboardBuilder/malloyText.spec.ts +84 -0
- package/src/components/DashboardBuilder/malloyText.ts +151 -0
- package/src/components/DashboardBuilder/moveIntoGap.spec.ts +90 -0
- package/src/components/DashboardBuilder/preview.spec.ts +149 -0
- package/src/components/DashboardBuilder/preview.ts +172 -0
- package/src/components/DashboardBuilder/readDocument.spec.ts +375 -0
- package/src/components/DashboardBuilder/readDocument.ts +467 -0
- package/src/components/DashboardBuilder/sortable.tsx +151 -0
- package/src/components/DashboardBuilder/spliceDocument.spec.ts +1108 -0
- package/src/components/DashboardBuilder/spliceDocument.ts +1098 -0
- package/src/components/DashboardBuilder/testing/fixtures.ts +48 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +88 -0
- package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +255 -0
- package/src/components/DashboardBuilder/useDashboardEditor.ts +193 -0
- package/src/components/DashboardBuilder/useDraft.ts +43 -0
- package/src/components/DashboardBuilder/useFilterForm.spec.tsx +144 -0
- package/src/components/DashboardBuilder/useFilterForm.ts +352 -0
- package/src/components/DashboardBuilder/useTileReorder.spec.tsx +97 -0
- package/src/components/DashboardBuilder/useTileReorder.ts +115 -0
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +121 -0
- package/src/components/DashboardBuilder/useTileResize.ts +110 -0
- package/src/components/DashboardBuilder/withGaps.spec.ts +96 -0
- package/src/components/DocumentStorage/BrowserDocumentStorage.spec.ts +81 -0
- package/src/components/DocumentStorage/BrowserDocumentStorage.ts +105 -0
- package/src/components/DocumentStorage/DocumentStorage.ts +73 -0
- package/src/components/DocumentStorage/DocumentStorageProvider.tsx +58 -0
- package/src/components/DocumentStorage/index.ts +16 -0
- package/src/components/Environment/About.tsx +4 -36
- package/src/components/FloatingIconButton.tsx +41 -0
- package/src/components/Model/Model.tsx +6 -23
- package/src/components/Model/ModelCell.tsx +34 -72
- package/src/components/Model/index.ts +0 -1
- package/src/components/Notebook/Notebook.tsx +27 -156
- package/src/components/Notebook/NotebookCell.tsx +37 -191
- package/src/components/Prose.spec.tsx +85 -0
- package/src/components/Prose.tsx +179 -0
- package/src/components/QueryResult/QueryResult.tsx +15 -43
- package/src/components/RenderedResult/RenderedResult.tsx +86 -76
- package/src/components/RenderedResult/ResultContainer.tsx +25 -36
- package/src/components/RenderedResult/ResultPanel.spec.tsx +49 -0
- package/src/components/RenderedResult/ResultPanel.tsx +73 -0
- package/src/components/RenderedResult/index.ts +16 -0
- package/src/components/RenderedResult/resultSizing.spec.ts +249 -0
- package/src/components/RenderedResult/resultSizing.ts +308 -0
- package/src/components/ResultsDialog.tsx +2 -1
- package/src/components/drill/index.ts +6 -0
- package/src/components/drill/resolveDrill.ts +22 -1
- package/src/components/drill/useDrill.spec.tsx +94 -0
- package/src/components/drill/useDrill.tsx +52 -12
- package/src/components/drill/useDrillSelf.spec.tsx +64 -0
- package/src/components/drill/useDrillSelf.ts +110 -0
- package/src/components/given/GivenInput.spec.tsx +196 -2
- package/src/components/given/GivenInput.tsx +300 -25
- package/src/components/given/GivensPanel.tsx +1 -1
- package/src/components/given/filterValue.spec.ts +112 -0
- package/src/components/given/filterValue.ts +188 -0
- package/src/components/given/index.ts +4 -0
- package/src/components/given/useGivenUrlParams.spec.tsx +74 -0
- package/src/components/given/useGivenUrlParams.ts +87 -0
- package/src/components/index.ts +11 -3
- package/src/components/styles.ts +0 -37
- package/src/hooks/index.ts +13 -1
- package/src/hooks/useDocumentControls.ts +170 -0
- package/src/hooks/useGivensState.spec.ts +158 -0
- package/src/hooks/useGivensState.ts +114 -23
- package/src/hooks/useQueryResult.ts +82 -0
- package/src/hooks/useSuggestOptions.dom.spec.ts +60 -1
- package/src/hooks/useSuggestOptions.ts +94 -51
- package/src/utils/malloyLiteral.spec.ts +43 -0
- package/src/utils/malloyLiteral.ts +76 -0
- package/vite.config.ts +5 -1
- package/dist/components/AnalyzePackageButton.d.ts +0 -6
- package/dist/components/Workbook/BrowserWorkbookStorage.d.ts +0 -9
- package/dist/components/Workbook/EditableMalloyCell.d.ts +0 -11
- package/dist/components/Workbook/ModelPicker.d.ts +0 -11
- package/dist/components/Workbook/MutableCell.d.ts +0 -17
- package/dist/components/Workbook/Workbook.d.ts +0 -7
- package/dist/components/Workbook/WorkbookList.d.ts +0 -7
- package/dist/components/Workbook/WorkbookManager.d.ts +0 -84
- package/dist/components/Workbook/WorkbookStorage.d.ts +0 -17
- package/dist/components/Workbook/WorkbookStorageProvider.d.ts +0 -12
- package/dist/components/Workbook/index.d.ts +0 -7
- package/dist/core-CWKmWEg2.cjs.js +0 -148
- package/dist/index-B0WyZAUA.es.js +0 -66412
- package/dist/index-kxVD1RjY.cjs.js +0 -356
- package/dist/markdown-editor.css +0 -341
- package/src/components/AnalyzePackageButton.tsx +0 -319
- package/src/components/Workbook/BrowserWorkbookStorage.ts +0 -64
- package/src/components/Workbook/EditableMalloyCell.tsx +0 -49
- package/src/components/Workbook/ModelPicker.tsx +0 -134
- package/src/components/Workbook/MutableCell.tsx +0 -458
- package/src/components/Workbook/Workbook.tsx +0 -501
- package/src/components/Workbook/WorkbookList.tsx +0 -110
- package/src/components/Workbook/WorkbookManager.ts +0 -214
- package/src/components/Workbook/WorkbookStorage.ts +0 -35
- package/src/components/Workbook/WorkbookStorageProvider.tsx +0 -40
- package/src/components/Workbook/index.ts +0 -10
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Where authored documents are kept, as an interface the host hands the SDK.
|
|
6
|
+
*
|
|
7
|
+
* The SDK renders dashboards and notebooks that a Publisher server serves out
|
|
8
|
+
* of a package, and it will author them too, but it does not decide where an
|
|
9
|
+
* authored document goes. That is the host's business: the Console keeps one
|
|
10
|
+
* in the browser, a platform keeps one in its own document store, a repo-backed
|
|
11
|
+
* host writes it to the package directory. So the SDK asks for a
|
|
12
|
+
* {@link DocumentStorage} through {@link DocumentStorageProvider} and calls it,
|
|
13
|
+
* and never touches a backend itself.
|
|
14
|
+
*
|
|
15
|
+
* A document is a string. The interface does not know whether it is a
|
|
16
|
+
* `dashboards/*.malloy` file, a `.malloynb`, or something else; the
|
|
17
|
+
* {@link DocumentLocator.type} says what kind it is so a backend can keep the
|
|
18
|
+
* kinds apart (a database column, a directory, a key prefix) and a listing can
|
|
19
|
+
* ask for one kind. Everything else a backend may know about a document, who
|
|
20
|
+
* changed it and when, who may see it, stays with the backend.
|
|
21
|
+
*
|
|
22
|
+
* Every method rejects rather than returning a sentinel when the document is
|
|
23
|
+
* not there, so a caller can tell "missing" from "empty".
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The kinds of document the SDK authors. A `dashboard` is a
|
|
28
|
+
* `dashboards/<slug>.malloy` file; a `notebook` is a `.malloynb`.
|
|
29
|
+
*/
|
|
30
|
+
export type DocumentType = "dashboard" | "notebook";
|
|
31
|
+
|
|
32
|
+
/** A place documents live, as the backend presents it to a reader. */
|
|
33
|
+
export interface Workspace {
|
|
34
|
+
name: string;
|
|
35
|
+
/** False for a workspace this reader may list and open but not save into. */
|
|
36
|
+
writeable: boolean;
|
|
37
|
+
description: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** One document's address: which workspace, which kind, and its path there. */
|
|
41
|
+
export interface DocumentLocator {
|
|
42
|
+
workspace: string;
|
|
43
|
+
type: DocumentType;
|
|
44
|
+
/**
|
|
45
|
+
* The document's path within the workspace, spelled the way the backend
|
|
46
|
+
* spells it. For a repo-backed store that is the file path relative to the
|
|
47
|
+
* package (`dashboards/overview.malloy`); a database store may use a slug.
|
|
48
|
+
*/
|
|
49
|
+
path: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface DocumentStorage {
|
|
53
|
+
/** The workspaces this reader can see; only the writeable ones when asked. */
|
|
54
|
+
listWorkspaces(writeableOnly: boolean): Promise<Workspace[]>;
|
|
55
|
+
|
|
56
|
+
/** Every document in a workspace, or only those of one kind. */
|
|
57
|
+
listDocuments(
|
|
58
|
+
workspace: Workspace,
|
|
59
|
+
type?: DocumentType,
|
|
60
|
+
): Promise<DocumentLocator[]>;
|
|
61
|
+
|
|
62
|
+
/** The document's content. Rejects when there is no document there. */
|
|
63
|
+
getDocument(locator: DocumentLocator): Promise<string>;
|
|
64
|
+
|
|
65
|
+
/** Write the content, creating the document or replacing it. */
|
|
66
|
+
saveDocument(locator: DocumentLocator, content: string): Promise<void>;
|
|
67
|
+
|
|
68
|
+
/** Remove the document. Rejects when there is no document there. */
|
|
69
|
+
deleteDocument(locator: DocumentLocator): Promise<void>;
|
|
70
|
+
|
|
71
|
+
/** Rename or relocate a document, keeping its content. Rejects when `from` is missing. */
|
|
72
|
+
moveDocument(from: DocumentLocator, to: DocumentLocator): Promise<void>;
|
|
73
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import React, { createContext, useContext, useMemo } from "react";
|
|
5
|
+
import type { DocumentStorage } from "./DocumentStorage";
|
|
6
|
+
|
|
7
|
+
export interface DocumentStorageProviderProps {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
documentStorage: DocumentStorage;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface DocumentStorageContextValue {
|
|
13
|
+
documentStorage: DocumentStorage;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const DocumentStorageContext = createContext<
|
|
17
|
+
DocumentStorageContextValue | undefined
|
|
18
|
+
>(undefined);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Hands a {@link DocumentStorage} to every SDK component beneath it. The host
|
|
22
|
+
* constructs the storage; the SDK only ever reads it through
|
|
23
|
+
* {@link useDocumentStorage}.
|
|
24
|
+
*/
|
|
25
|
+
export function DocumentStorageProvider({
|
|
26
|
+
children,
|
|
27
|
+
documentStorage,
|
|
28
|
+
}: DocumentStorageProviderProps) {
|
|
29
|
+
const value = useMemo(() => ({ documentStorage }), [documentStorage]);
|
|
30
|
+
return (
|
|
31
|
+
<DocumentStorageContext.Provider value={value}>
|
|
32
|
+
{children}
|
|
33
|
+
</DocumentStorageContext.Provider>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The host's storage, or a thrown error outside a provider: there is no default. */
|
|
38
|
+
export function useDocumentStorage(): DocumentStorageContextValue {
|
|
39
|
+
const context = useContext(DocumentStorageContext);
|
|
40
|
+
if (!context) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
"useDocumentStorage must be used within a DocumentStorageProvider",
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
return context;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The host's storage, or undefined outside a provider. For a component that
|
|
50
|
+
* can do without one — the dashboard editor still edits and exports with no
|
|
51
|
+
* place to save — rather than the throwing form, which is for components that
|
|
52
|
+
* cannot.
|
|
53
|
+
*/
|
|
54
|
+
export function useOptionalDocumentStorage():
|
|
55
|
+
| DocumentStorageContextValue
|
|
56
|
+
| undefined {
|
|
57
|
+
return useContext(DocumentStorageContext);
|
|
58
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
export type {
|
|
5
|
+
DocumentLocator,
|
|
6
|
+
DocumentStorage,
|
|
7
|
+
DocumentType,
|
|
8
|
+
Workspace,
|
|
9
|
+
} from "./DocumentStorage";
|
|
10
|
+
export {
|
|
11
|
+
DocumentStorageProvider,
|
|
12
|
+
useDocumentStorage,
|
|
13
|
+
useOptionalDocumentStorage,
|
|
14
|
+
type DocumentStorageProviderProps,
|
|
15
|
+
} from "./DocumentStorageProvider";
|
|
16
|
+
export { BrowserDocumentStorage } from "./BrowserDocumentStorage";
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
import { Box, Button } from "@mui/material";
|
|
5
|
-
import Markdown from "markdown-to-jsx";
|
|
6
5
|
import { useState } from "react";
|
|
7
6
|
import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
8
7
|
import { parseResourceUri } from "../../utils/formatting";
|
|
9
8
|
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
10
9
|
import { Loading } from "../Loading";
|
|
10
|
+
import { Prose } from "../Prose";
|
|
11
11
|
import { useServer } from "../ServerProvider";
|
|
12
12
|
import {
|
|
13
13
|
PackageCard,
|
|
@@ -42,42 +42,10 @@ export default function About({ resourceUri }: AboutProps) {
|
|
|
42
42
|
<PackageCard>
|
|
43
43
|
<PackageCardContent>
|
|
44
44
|
<PackageSectionTitle>Readme</PackageSectionTitle>
|
|
45
|
-
<Box sx={{ mt: 1
|
|
46
|
-
<
|
|
47
|
-
options={{
|
|
48
|
-
overrides: {
|
|
49
|
-
h1: {
|
|
50
|
-
component: "p",
|
|
51
|
-
props: {
|
|
52
|
-
style: {
|
|
53
|
-
fontSize: "inherit",
|
|
54
|
-
fontWeight: "italic",
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
h2: {
|
|
59
|
-
component: "p",
|
|
60
|
-
props: {
|
|
61
|
-
style: {
|
|
62
|
-
fontSize: "inherit",
|
|
63
|
-
fontWeight: "italic",
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
h3: {
|
|
68
|
-
component: "p",
|
|
69
|
-
props: {
|
|
70
|
-
style: {
|
|
71
|
-
fontSize: "inherit",
|
|
72
|
-
fontWeight: "italic",
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
}}
|
|
78
|
-
>
|
|
45
|
+
<Box sx={{ mt: 1 }}>
|
|
46
|
+
<Prose variant="caption">
|
|
79
47
|
{expanded || !shouldTruncate ? readmeContent : preview}
|
|
80
|
-
</
|
|
48
|
+
</Prose>
|
|
81
49
|
|
|
82
50
|
{shouldTruncate && (
|
|
83
51
|
<Box sx={{ mt: 1 }}>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { IconButton, type IconButtonProps } from "@mui/material";
|
|
5
|
+
import { usePublisherTheme } from "../theme/ThemeContext";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A small round button that sits OVER content — a rendered result, an
|
|
9
|
+
* explorer, a chart — to open something about it: the code, the full result,
|
|
10
|
+
* a render warning.
|
|
11
|
+
*
|
|
12
|
+
* On the instance theme's tile colour, with its border, so it reads as a chip
|
|
13
|
+
* of the same card it floats on in both modes. Six of these were drawn by hand
|
|
14
|
+
* before, every one on a hardcoded white plate with a hardcoded dark icon,
|
|
15
|
+
* and the notebook's comment said why that was the only way: a white plate
|
|
16
|
+
* needs a dark icon whatever the mode. The plate follows the theme now, so
|
|
17
|
+
* the icon can too.
|
|
18
|
+
*
|
|
19
|
+
* Positioning is the caller's: it passes `sx` for where the button floats.
|
|
20
|
+
*/
|
|
21
|
+
export function FloatingIconButton({ sx, ...props }: IconButtonProps) {
|
|
22
|
+
const { theme } = usePublisherTheme();
|
|
23
|
+
return (
|
|
24
|
+
<IconButton
|
|
25
|
+
size="small"
|
|
26
|
+
{...props}
|
|
27
|
+
sx={[
|
|
28
|
+
{
|
|
29
|
+
width: 32,
|
|
30
|
+
height: 32,
|
|
31
|
+
bgcolor: theme.tile,
|
|
32
|
+
border: theme.border,
|
|
33
|
+
color: theme.tileTitle,
|
|
34
|
+
"&:hover": { bgcolor: theme.tile, color: theme.drillLink },
|
|
35
|
+
"& .MuiSvgIcon-root": { fontSize: 18 },
|
|
36
|
+
},
|
|
37
|
+
...(Array.isArray(sx) ? sx : [sx]),
|
|
38
|
+
]}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -4,17 +4,11 @@
|
|
|
4
4
|
import "@malloydata/malloy-explorer/styles.css";
|
|
5
5
|
import LinkOutlinedIcon from "@mui/icons-material/LinkOutlined";
|
|
6
6
|
import SearchIcon from "@mui/icons-material/Search";
|
|
7
|
-
import {
|
|
8
|
-
Box,
|
|
9
|
-
IconButton,
|
|
10
|
-
Snackbar,
|
|
11
|
-
Stack,
|
|
12
|
-
Tooltip,
|
|
13
|
-
Typography,
|
|
14
|
-
} from "@mui/material";
|
|
7
|
+
import { Box, Snackbar, Stack, Tooltip, Typography } from "@mui/material";
|
|
15
8
|
import React, { useState } from "react";
|
|
16
9
|
import { parseResourceUri } from "../../utils/formatting";
|
|
17
10
|
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
11
|
+
import { FloatingIconButton } from "../FloatingIconButton";
|
|
18
12
|
import { Loading } from "../Loading";
|
|
19
13
|
import { ModelCell } from "./ModelCell";
|
|
20
14
|
import { ModelExplorer } from "./ModelExplorer";
|
|
@@ -151,29 +145,18 @@ export default function Model({
|
|
|
151
145
|
/>
|
|
152
146
|
|
|
153
147
|
{/* Magnifying glass icon */}
|
|
154
|
-
<
|
|
148
|
+
<FloatingIconButton
|
|
149
|
+
aria-label="Expand results"
|
|
155
150
|
sx={{
|
|
156
151
|
position: "absolute",
|
|
157
152
|
top: "90px",
|
|
158
153
|
right: "4px",
|
|
159
|
-
backgroundColor: "rgba(255, 255, 255, 0.9)",
|
|
160
|
-
"&:hover": {
|
|
161
|
-
backgroundColor: "rgba(255, 255, 255, 1)",
|
|
162
|
-
},
|
|
163
|
-
width: "32px",
|
|
164
|
-
height: "32px",
|
|
165
154
|
zIndex: 2,
|
|
166
155
|
}}
|
|
167
156
|
onClick={() => setDialogOpen(true)}
|
|
168
157
|
>
|
|
169
|
-
<SearchIcon
|
|
170
|
-
|
|
171
|
-
fontSize: "18px",
|
|
172
|
-
color: "text.secondary",
|
|
173
|
-
marginBottom: "5px",
|
|
174
|
-
}}
|
|
175
|
-
/>
|
|
176
|
-
</IconButton>
|
|
158
|
+
<SearchIcon />
|
|
159
|
+
</FloatingIconButton>
|
|
177
160
|
</Stack>
|
|
178
161
|
)}
|
|
179
162
|
|
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
|
|
4
4
|
import PlayArrowIcon from "@mui/icons-material/PlayArrow";
|
|
5
5
|
import SearchIcon from "@mui/icons-material/Search";
|
|
6
|
-
import { Box, Button,
|
|
6
|
+
import { Box, Button, Typography } from "@mui/material";
|
|
7
7
|
import React, { useEffect } from "react";
|
|
8
|
-
import {
|
|
8
|
+
import { useQueryResult } from "../../hooks/useQueryResult";
|
|
9
9
|
import { usePublisherTheme } from "../../theme/ThemeContext";
|
|
10
10
|
import { parseResourceUri } from "../../utils/formatting";
|
|
11
|
-
import {
|
|
11
|
+
import { FloatingIconButton } from "../FloatingIconButton";
|
|
12
12
|
import { highlight } from "../highlighter";
|
|
13
|
-
import
|
|
13
|
+
import { ResultPanel } from "../RenderedResult/ResultPanel";
|
|
14
|
+
import { MODEL_CELL_MAX_HEIGHT } from "../RenderedResult/resultSizing";
|
|
14
15
|
import ResultsDialog from "../ResultsDialog";
|
|
15
|
-
import {
|
|
16
|
-
import { CleanMetricCard, CleanNotebookCell } from "../styles";
|
|
16
|
+
import { CleanMetricCard } from "../styles";
|
|
17
17
|
|
|
18
18
|
interface ModelCellProps {
|
|
19
19
|
sourceName?: string;
|
|
@@ -39,29 +39,13 @@ export function ModelCell({
|
|
|
39
39
|
|
|
40
40
|
const { packageName, environmentName, versionId, modelPath } =
|
|
41
41
|
parseResourceUri(resourceUri);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
queryKey: ["namedQueryResult", resourceUri, queryName],
|
|
50
|
-
queryFn: () =>
|
|
51
|
-
apiClients.models.executeQueryModel(
|
|
52
|
-
environmentName,
|
|
53
|
-
packageName,
|
|
54
|
-
modelPath,
|
|
55
|
-
{
|
|
56
|
-
query: undefined,
|
|
57
|
-
sourceName: undefined,
|
|
58
|
-
queryName: queryName,
|
|
59
|
-
versionId: versionId,
|
|
60
|
-
},
|
|
61
|
-
),
|
|
62
|
-
enabled: runOnDemand ? hasRun : true, // Execute on demand or always
|
|
63
|
-
...CHART_RESULT_QUERY_OPTIONS,
|
|
64
|
-
});
|
|
42
|
+
// Run on demand or always; a query not yet asked for is not fetched.
|
|
43
|
+
const shouldRun = !runOnDemand || hasRun;
|
|
44
|
+
const state = useQueryResult(
|
|
45
|
+
{ environmentName, packageName, modelPath, versionId, queryName },
|
|
46
|
+
{ enabled: shouldRun },
|
|
47
|
+
);
|
|
48
|
+
const queryData = state.data;
|
|
65
49
|
|
|
66
50
|
const { mode } = usePublisherTheme();
|
|
67
51
|
useEffect(() => {
|
|
@@ -76,7 +60,7 @@ export function ModelCell({
|
|
|
76
60
|
}, [annotations, mode]);
|
|
77
61
|
|
|
78
62
|
return (
|
|
79
|
-
<
|
|
63
|
+
<Box>
|
|
80
64
|
{highlightedAnnotations && (
|
|
81
65
|
<Box sx={{ marginBottom: "16px" }}>
|
|
82
66
|
<Typography
|
|
@@ -109,29 +93,24 @@ export function ModelCell({
|
|
|
109
93
|
variant="body2"
|
|
110
94
|
sx={{
|
|
111
95
|
fontSize: "15px",
|
|
112
|
-
fontWeight:
|
|
113
|
-
color: "
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
96
|
+
fontWeight: 600,
|
|
97
|
+
color: "text.primary",
|
|
98
|
+
px: 2,
|
|
99
|
+
py: 1,
|
|
100
|
+
bgcolor: "action.hover",
|
|
101
|
+
borderRadius: 1.5,
|
|
102
|
+
border: 1,
|
|
103
|
+
borderColor: "divider",
|
|
118
104
|
}}
|
|
119
105
|
>
|
|
120
106
|
{queryName}
|
|
121
107
|
</Typography>
|
|
122
|
-
<
|
|
123
|
-
|
|
124
|
-
backgroundColor: "rgba(255, 255, 255, 0.9)",
|
|
125
|
-
"&:hover": {
|
|
126
|
-
backgroundColor: "rgba(255, 255, 255, 1)",
|
|
127
|
-
},
|
|
128
|
-
width: "32px",
|
|
129
|
-
height: "32px",
|
|
130
|
-
}}
|
|
108
|
+
<FloatingIconButton
|
|
109
|
+
aria-label="Expand results"
|
|
131
110
|
onClick={() => setResultsDialogOpen(true)}
|
|
132
111
|
>
|
|
133
|
-
<SearchIcon
|
|
134
|
-
</
|
|
112
|
+
<SearchIcon />
|
|
113
|
+
</FloatingIconButton>
|
|
135
114
|
</Box>
|
|
136
115
|
|
|
137
116
|
<CleanMetricCard
|
|
@@ -157,36 +136,19 @@ export function ModelCell({
|
|
|
157
136
|
variant="contained"
|
|
158
137
|
startIcon={<PlayArrowIcon />}
|
|
159
138
|
onClick={() => setHasRun(true)}
|
|
160
|
-
sx={{
|
|
161
|
-
backgroundColor: "#1976d2",
|
|
162
|
-
"&:hover": {
|
|
163
|
-
backgroundColor: "#1565c0",
|
|
164
|
-
},
|
|
165
|
-
textTransform: "none",
|
|
166
|
-
fontSize: "14px",
|
|
167
|
-
fontWeight: 600,
|
|
168
|
-
padding: "8px 24px",
|
|
169
|
-
}}
|
|
170
139
|
>
|
|
171
140
|
Run Query
|
|
172
141
|
</Button>
|
|
173
142
|
</Box>
|
|
174
143
|
)}
|
|
175
|
-
{
|
|
176
|
-
<
|
|
177
|
-
|
|
178
|
-
|
|
144
|
+
{shouldRun && (
|
|
145
|
+
<ResultPanel
|
|
146
|
+
state={state}
|
|
147
|
+
context={queryName}
|
|
148
|
+
maxHeight={MODEL_CELL_MAX_HEIGHT}
|
|
149
|
+
maxResultSize={maxResultSize}
|
|
150
|
+
/>
|
|
179
151
|
)}
|
|
180
|
-
{(!runOnDemand || hasRun) &&
|
|
181
|
-
isSuccess &&
|
|
182
|
-
queryData?.data?.result && (
|
|
183
|
-
<ResultContainer
|
|
184
|
-
result={queryData.data.result}
|
|
185
|
-
maxHeight={600}
|
|
186
|
-
maxResultSize={maxResultSize}
|
|
187
|
-
renderLogs={queryData.data.renderLogs}
|
|
188
|
-
/>
|
|
189
|
-
)}
|
|
190
152
|
</CleanMetricCard>
|
|
191
153
|
|
|
192
154
|
{/* Results Dialog */}
|
|
@@ -197,6 +159,6 @@ export function ModelCell({
|
|
|
197
159
|
renderLogs={queryData?.data?.renderLogs}
|
|
198
160
|
title={`Query: ${queryName}`}
|
|
199
161
|
/>
|
|
200
|
-
</
|
|
162
|
+
</Box>
|
|
201
163
|
);
|
|
202
164
|
}
|
|
@@ -5,7 +5,6 @@ export { default as Model } from "./Model";
|
|
|
5
5
|
export { ModelExplorer } from "./ModelExplorer";
|
|
6
6
|
export { ModelExplorerDialog } from "./ModelExplorerDialog";
|
|
7
7
|
export { SourcesExplorer } from "./SourcesExplorer";
|
|
8
|
-
export { SourceExplorerComponent } from "./SourcesExplorer";
|
|
9
8
|
export type { SourceAndPath, QueryExplorerResult } from "./SourcesExplorer";
|
|
10
9
|
export { useModelData } from "./useModelData";
|
|
11
10
|
export type { ModelExplorerProps } from "./ModelExplorer";
|