@ms-cloudpack/overlay 0.18.3 → 0.19.0
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 +2 -0
- package/dist/browser-esm/240.chunk.js +1 -1
- package/dist/browser-esm/240.chunk.js.map +1 -1
- package/dist/browser-esm/31.chunk.js +2 -0
- package/dist/browser-esm/31.chunk.js.map +1 -0
- package/dist/browser-esm/570.chunk.js +2 -0
- package/dist/browser-esm/570.chunk.js.map +1 -0
- package/dist/browser-esm/582.chunk.js +2 -0
- package/dist/browser-esm/{318.chunk.js.map → 582.chunk.js.map} +1 -1
- package/dist/browser-esm/lib/index.js +1 -1
- package/dist/browser-esm/lib/index.js.LICENSE.txt +0 -30
- package/dist/browser-esm/lib/index.js.map +1 -1
- package/lib/components/Button/Button.d.ts +26 -4
- package/lib/components/Button/Button.d.ts.map +1 -1
- package/lib/components/Button/Button.js +27 -4
- package/lib/components/Button/Button.js.map +1 -1
- package/lib/components/CloudpackProvider/CloudpackProvider.d.ts +4 -3
- package/lib/components/CloudpackProvider/CloudpackProvider.d.ts.map +1 -1
- package/lib/components/CloudpackProvider/CloudpackProvider.js +4 -2
- package/lib/components/CloudpackProvider/CloudpackProvider.js.map +1 -1
- package/lib/components/CloudpackProvider/useStatus.js +1 -1
- package/lib/components/CloudpackProvider/useStatus.js.map +1 -1
- package/lib/components/CloudpackProvider/useStatusDetails.js +1 -1
- package/lib/components/CloudpackProvider/useStatusDetails.js.map +1 -1
- package/lib/components/Dialog/Dialog.d.ts +4 -4
- package/lib/components/Dialog/Dialog.d.ts.map +1 -1
- package/lib/components/Dialog/Dialog.js +9 -13
- package/lib/components/Dialog/Dialog.js.map +1 -1
- package/lib/components/ErrorDialog/ErrorDialog.d.ts +2 -2
- package/lib/components/ErrorDialog/ErrorDialog.d.ts.map +1 -1
- package/lib/components/ErrorDialog/ErrorDialog.js +4 -5
- package/lib/components/ErrorDialog/ErrorDialog.js.map +1 -1
- package/lib/components/ErrorDialog/PathError.d.ts +6 -2
- package/lib/components/ErrorDialog/PathError.d.ts.map +1 -1
- package/lib/components/ErrorDialog/PathError.js +14 -36
- package/lib/components/ErrorDialog/PathError.js.map +1 -1
- package/lib/components/ErrorDialog/useErrorEvents.d.ts +9 -0
- package/lib/components/ErrorDialog/useErrorEvents.d.ts.map +1 -1
- package/lib/components/ErrorDialog/useErrorEvents.js +30 -5
- package/lib/components/ErrorDialog/useErrorEvents.js.map +1 -1
- package/lib/components/Overlay/Overlay.d.ts +3 -0
- package/lib/components/Overlay/Overlay.d.ts.map +1 -0
- package/lib/components/{StatusOverlay/StatusOverlay.js → Overlay/Overlay.js} +10 -8
- package/lib/components/Overlay/Overlay.js.map +1 -0
- package/lib/components/ResultsAccordion/ResultsAccordion.d.ts +40 -0
- package/lib/components/ResultsAccordion/ResultsAccordion.d.ts.map +1 -0
- package/lib/components/ResultsAccordion/ResultsAccordion.js +43 -0
- package/lib/components/ResultsAccordion/ResultsAccordion.js.map +1 -0
- package/lib/components/StatusBadge/StatusBadge.d.ts +3 -5
- package/lib/components/StatusBadge/StatusBadge.d.ts.map +1 -1
- package/lib/components/StatusBadge/StatusBadge.js +49 -60
- package/lib/components/StatusBadge/StatusBadge.js.map +1 -1
- package/lib/components/StatusDialog/Searchbox.d.ts +4 -4
- package/lib/components/StatusDialog/Searchbox.d.ts.map +1 -1
- package/lib/components/StatusDialog/Searchbox.js +4 -3
- package/lib/components/StatusDialog/Searchbox.js.map +1 -1
- package/lib/components/StatusDialog/StatusDialog.d.ts +2 -2
- package/lib/components/StatusDialog/StatusDialog.d.ts.map +1 -1
- package/lib/components/StatusDialog/StatusDialog.js +5 -9
- package/lib/components/StatusDialog/StatusDialog.js.map +1 -1
- package/lib/components/StatusDialog/TaskList.d.ts +2 -2
- package/lib/components/StatusDialog/TaskList.d.ts.map +1 -1
- package/lib/components/StatusDialog/TaskList.js +2 -2
- package/lib/components/StatusDialog/TaskList.js.map +1 -1
- package/lib/components/StatusDialog/TaskResultItem.d.ts +8 -3
- package/lib/components/StatusDialog/TaskResultItem.d.ts.map +1 -1
- package/lib/components/StatusDialog/TaskResultItem.js +52 -29
- package/lib/components/StatusDialog/TaskResultItem.js.map +1 -1
- package/lib/components/StatusDialog/TaskStatus.d.ts +7 -3
- package/lib/components/StatusDialog/TaskStatus.d.ts.map +1 -1
- package/lib/components/StatusDialog/TaskStatus.js +17 -56
- package/lib/components/StatusDialog/TaskStatus.js.map +1 -1
- package/lib/components/ThemeProvider/ThemeProvider.d.ts +4 -2
- package/lib/components/ThemeProvider/ThemeProvider.d.ts.map +1 -1
- package/lib/components/ThemeProvider/ThemeProvider.js +2 -2
- package/lib/components/ThemeProvider/ThemeProvider.js.map +1 -1
- package/lib/hooks/useDraggable.d.ts +1 -1
- package/lib/hooks/useDraggable.d.ts.map +1 -1
- package/lib/hooks/useDraggable.js +1 -1
- package/lib/hooks/useDraggable.js.map +1 -1
- package/lib/hooks/usePageLoadTimeReporter.js +3 -3
- package/lib/hooks/usePageLoadTimeReporter.js.map +1 -1
- package/lib/index.js +4 -7
- package/lib/index.js.map +1 -1
- package/package.json +5 -8
- package/dist/browser-esm/119.chunk.js +0 -2
- package/dist/browser-esm/119.chunk.js.map +0 -1
- package/dist/browser-esm/318.chunk.js +0 -2
- package/dist/browser-esm/464.chunk.js +0 -2
- package/dist/browser-esm/464.chunk.js.map +0 -1
- package/lib/components/StatusOverlay/StatusOverlay.d.ts +0 -3
- package/lib/components/StatusOverlay/StatusOverlay.d.ts.map +0 -1
- package/lib/components/StatusOverlay/StatusOverlay.js.map +0 -1
- package/lib/hooks/preferDarkTheme.d.ts +0 -5
- package/lib/hooks/preferDarkTheme.d.ts.map +0 -1
- package/lib/hooks/preferDarkTheme.js +0 -7
- package/lib/hooks/preferDarkTheme.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useErrorEvents.js","sourceRoot":"","sources":["../../../src/components/ErrorDialog/useErrorEvents.ts"],"names":[],"m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,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;IAE5B,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC","sourcesContent":["import { useEffect, useState } from 'preact/hooks';\nimport { parseImportString } from '@ms-cloudpack/path-string-parsing';\nimport { useCloudpack } from '../CloudpackProvider/CloudpackProvider.js';\nimport { errorEntrySource } from '@ms-cloudpack/api-server/browser';\n\n// Interface with reason as a record.\ninterface ReasonRecord extends PromiseRejectionEvent {\n readonly reason: Record<string, unknown>;\n}\n\n// Interface with message as a string.\ninterface ReasonString extends ReasonRecord {\n readonly reason: { message: string };\n}\n\n// Verify the reason is a record.\nconst reasonIsRecord = (event: PromiseRejectionEvent): event is ReasonRecord => {\n return typeof event.reason === 'object' && !Array.isArray(event.reason) && event.reason !== null;\n};\n\n// Verify the reason has a message which is a string.\nconst hasMessage = (event: PromiseRejectionEvent): event is ReasonString => {\n return reasonIsRecord(event) && typeof event.reason.message === 'string';\n};\n\nexport type ErrorEvents = {\n unsupported: UnsupportedErrorEvent[];\n};\n\nexport type UnsupportedErrorEvent = {\n /** Package name being imported */\n packageName: string;\n /** Path within the package being imported (`'.'` for root) */\n importPath: string;\n /**\n * URL that issued the bad request. This will be undefined if the browser didn't set it, or if it\n * was incorrectly set to the current page URL (most browsers except Firefox do this).\n */\n issuerUrl?: string;\n /** True if this is a valid import that can be handled by `addPackageOverride` */\n fixable?: boolean;\n /** True if the package exists in the resolve map (even if the import path wasn't valid) */\n isValidPackage?: boolean;\n};\n\nexport const useErrorEvents = (): ErrorEvents => {\n const [errorEvents, setErrorEvents] = useState<ErrorEvents>({ unsupported: [] });\n const cloudpack = useCloudpack();\n // This should always be set by an inline script\n const pageErrors = window.__pageErrors;\n\n useEffect(() => {\n if (!pageErrors) {\n console.error('[Cloudpack] window.__pageErrors not found (unable to handle unsupported imports)');\n return;\n }\n\n const handleUnsupportedError = (message: string, issuerUrl?: string): void => {\n const errorRegex = /[Mm]odule specifier,? ['\"](.*?)['\"]/;\n const match = message.match(errorRegex);\n\n if (!match) {\n return;\n }\n\n const importString = parseImportString(match[1]);\n const { packageName, importPath } = importString;\n\n (async () => {\n if (issuerUrl && issuerUrl === location.href) {\n // Issuer URL is often incorrectly set to the current page URL, so just remove it\n issuerUrl = undefined;\n }\n\n // Check whether importPath is valid for this package.\n // Unfortunately, due to the lack of issuerUrl support in most browsers, this might not be\n // accurate if there are multiple versions of the same package (it will fall back to\n // whichever version is at the top level of the resolve map, which may not be the version\n // that's actually being imported in context).\n const { fixable } = await cloudpack.validatePackageOverride.query({\n packageName,\n importPath,\n issuerUrl,\n });\n\n // If importPath doesn't appear to be valid, attempt to check whether the package exists\n // elsewhere in the resolve map (to refine the error message). This check isn't perfect\n // since it assumes the path '.' exists for that package, and it's also possible that the\n // package is installed somewhere in the repo but hasn't ended up in the resolve map yet.\n const isValidPackage =\n fixable ||\n (importPath !== '.' &&\n (await cloudpack.validatePackageOverride.query({ packageName, importPath: '.', issuerUrl })).fixable);\n\n setErrorEvents((prev) => ({\n ...prev,\n unsupported: [...prev.unsupported, { packageName, importPath, issuerUrl, fixable, isValidPackage }],\n }));\n })().catch(() => {\n // no-op\n });\n };\n\n const subscription = cloudpack.onDataChanged.subscribe(errorEntrySource, {\n onData: (data) => {\n if (data) {\n console.error(data);\n handleUnsupportedError(String(data));\n }\n },\n });\n\n pageErrors.unregister();\n\n // Append unsupported paths to the list.\n window.addEventListener('error', (event: ErrorEvent) => {\n handleUnsupportedError(event.message, event.filename);\n });\n\n // Handle errors caught before rendering.\n for (const error of pageErrors.uncaughtErrors) {\n handleUnsupportedError(error.message, error.filename);\n }\n\n // Append unsupported paths to the list.\n window.addEventListener('unhandledrejection', (event: PromiseRejectionEvent) => {\n hasMessage(event) && handleUnsupportedError(event.reason.message);\n });\n\n // Handle rejections caught before rendering.\n for (const error of pageErrors.uncaughtRejections) {\n hasMessage(error) && handleUnsupportedError(error.reason.message);\n }\n\n return () => {\n subscription.unsubscribe();\n };\n }, [cloudpack, pageErrors]);\n\n return errorEvents;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Overlay.d.ts","sourceRoot":"","sources":["../../../src/components/Overlay/Overlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAWhD,eAAO,MAAM,OAAO,EAAE,iBAmCrB,CAAC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
2
|
+
import { lazy, Suspense } from 'preact/compat';
|
|
3
|
+
import { useCallback, useState, useRef, useEffect } from 'preact/hooks';
|
|
2
4
|
import { StatusBadge } from '../StatusBadge/StatusBadge.js';
|
|
3
5
|
import { useStatus } from '../CloudpackProvider/useStatus.js';
|
|
4
6
|
import { useErrorEvents } from '../ErrorDialog/useErrorEvents.js';
|
|
5
7
|
import { usePageLoadTimeReporter } from '../../hooks/usePageLoadTimeReporter.js';
|
|
6
|
-
const StatusDialog =
|
|
7
|
-
const ErrorDialog =
|
|
8
|
-
export const
|
|
8
|
+
const StatusDialog = lazy(() => import('../StatusDialog/StatusDialog.js'));
|
|
9
|
+
const ErrorDialog = lazy(() => import('../ErrorDialog/ErrorDialog.js'));
|
|
10
|
+
export const Overlay = () => {
|
|
9
11
|
const pageLoadTimeReport = usePageLoadTimeReporter();
|
|
10
12
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
11
13
|
const status = useStatus();
|
|
@@ -13,7 +15,7 @@ export const StatusOverlay = () => {
|
|
|
13
15
|
const { unsupported } = useErrorEvents();
|
|
14
16
|
// If we haven't set a specific state and we become idle,
|
|
15
17
|
// pop open the details if there are errors.
|
|
16
|
-
|
|
18
|
+
useEffect(() => {
|
|
17
19
|
if (!isExpanded &&
|
|
18
20
|
prevStatus.current?.status !== 'idle' &&
|
|
19
21
|
status.status === 'idle' &&
|
|
@@ -26,7 +28,7 @@ export const StatusOverlay = () => {
|
|
|
26
28
|
console.log(`Toggling minimized state to ${!isExpanded}`);
|
|
27
29
|
setIsExpanded(!isExpanded);
|
|
28
30
|
}, [isExpanded]);
|
|
29
|
-
const result = unsupported.length ? (
|
|
30
|
-
return
|
|
31
|
+
const result = unsupported.length ? (_jsx(ErrorDialog, { unsupported: unsupported })) : isExpanded ? (_jsx(StatusDialog, { onClose: toggleMinimized })) : (_jsx(StatusBadge, { onExpand: toggleMinimized, pageLoadTimeReport: pageLoadTimeReport }));
|
|
32
|
+
return _jsx(Suspense, { fallback: null, children: result });
|
|
31
33
|
};
|
|
32
|
-
//# sourceMappingURL=
|
|
34
|
+
//# sourceMappingURL=Overlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Overlay.js","sourceRoot":"","sources":["../../../src/components/Overlay/Overlay.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAwB,MAAM,mCAAmC,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,iCAAiC,CAAC,CAAC,CAAC;AAC3E,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,+BAA+B,CAAC,CAAC,CAAC;AAExE,MAAM,CAAC,MAAM,OAAO,GAAsB,GAAG,EAAE;IAC7C,MAAM,kBAAkB,GAAG,uBAAuB,EAAE,CAAC;IACrD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAA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';\nimport { lazy, Suspense } from 'preact/compat';\nimport { useCallback, useState, useRef, useEffect } from 'preact/hooks';\nimport { StatusBadge } from '../StatusBadge/StatusBadge.js';\nimport { useStatus, type CloudpackStatus } from '../CloudpackProvider/useStatus.js';\nimport { useErrorEvents } from '../ErrorDialog/useErrorEvents.js';\nimport { usePageLoadTimeReporter } from '../../hooks/usePageLoadTimeReporter.js';\n\nconst StatusDialog = lazy(() => import('../StatusDialog/StatusDialog.js'));\nconst ErrorDialog = lazy(() => import('../ErrorDialog/ErrorDialog.js'));\n\nexport const Overlay: FunctionComponent = () => {\n const pageLoadTimeReport = usePageLoadTimeReporter();\n const [isExpanded, setIsExpanded] = useState<boolean>(false);\n const status = useStatus();\n const prevStatus = useRef<CloudpackStatus | undefined>();\n const { unsupported } = useErrorEvents();\n\n // If we haven't set a specific state and we become idle,\n // pop open the details if there are errors.\n useEffect(() => {\n if (\n !isExpanded &&\n prevStatus.current?.status !== 'idle' &&\n status.status === 'idle' &&\n (prevStatus.current?.totalErrors || 0) !== (status.totalErrors || 0)\n ) {\n setIsExpanded(true);\n }\n prevStatus.current = status;\n }, [status, isExpanded]);\n\n const toggleMinimized = useCallback(() => {\n console.log(`Toggling minimized state to ${!isExpanded}`);\n setIsExpanded(!isExpanded);\n }, [isExpanded]);\n\n const result = unsupported.length ? (\n <ErrorDialog unsupported={unsupported} />\n ) : isExpanded ? (\n <StatusDialog onClose={toggleMinimized} />\n ) : (\n <StatusBadge onExpand={toggleMinimized} pageLoadTimeReport={pageLoadTimeReport} />\n );\n\n return <Suspense fallback={null}>{result}</Suspense>;\n};\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ComponentChildren, FunctionComponent } from 'preact';
|
|
2
|
+
export interface ResultsAccordionProps {
|
|
3
|
+
/** Name of the bundle task or other item (can have formatting, but should not have a header element) */
|
|
4
|
+
name: ComponentChildren;
|
|
5
|
+
/** Index used for generating accordion element IDs */
|
|
6
|
+
index: number;
|
|
7
|
+
result: 'success' | 'warning' | 'error';
|
|
8
|
+
/** Info that goes at the end of the header, inside the clickable area */
|
|
9
|
+
headerEndContent?: string;
|
|
10
|
+
/** Commands to go at the end of the header, outside the clickable area */
|
|
11
|
+
headerCommands?: ComponentChildren;
|
|
12
|
+
/**
|
|
13
|
+
* Get the content, only if the section is expanded.
|
|
14
|
+
* Use `CollapsibleResultsSubSection` for formatting (returning multiple sections if needed).
|
|
15
|
+
*
|
|
16
|
+
* This callback is to prevent rendering thousands of bundle result details unnecessarily.
|
|
17
|
+
*/
|
|
18
|
+
getContent: () => ComponentChildren;
|
|
19
|
+
}
|
|
20
|
+
export interface ResultsAccordionContentProps {
|
|
21
|
+
/** Will be at start of sub-section and styled slightly larger if provided */
|
|
22
|
+
title?: string;
|
|
23
|
+
/** Item name, such as "Input path". Ignored if `itemValue` is not provided. */
|
|
24
|
+
itemName?: string;
|
|
25
|
+
/** Value corresponding to `itemName`, such as the path to a package. Requires `itemName`. */
|
|
26
|
+
itemValue?: ComponentChildren;
|
|
27
|
+
/** Custom children */
|
|
28
|
+
children?: ComponentChildren;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Collapsible section for displaying results of a bundle task or other item.
|
|
32
|
+
* This handles the header formatting and layout, expanding/collapsing, and displaying content.
|
|
33
|
+
*/
|
|
34
|
+
export declare const ResultsAccordion: FunctionComponent<ResultsAccordionProps>;
|
|
35
|
+
/**
|
|
36
|
+
* Sub-section to return from `ResultsAccordionProps.getContent`.
|
|
37
|
+
* If there are no children and no `itemValue`, the section will be ignored.
|
|
38
|
+
*/
|
|
39
|
+
export declare const ResultsAccordionContent: FunctionComponent<ResultsAccordionContentProps>;
|
|
40
|
+
//# sourceMappingURL=ResultsAccordion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResultsAccordion.d.ts","sourceRoot":"","sources":["../../../src/components/ResultsAccordion/ResultsAccordion.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAUnE,MAAM,WAAW,qBAAqB;IACpC,wGAAwG;IACxG,IAAI,EAAE,iBAAiB,CAAC;IACxB,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IACxC,yEAAyE;IACzE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,0EAA0E;IAC1E,cAAc,CAAC,EAAE,iBAAiB,CAAC;IACnC;;;;;OAKG;IACH,UAAU,EAAE,MAAM,iBAAiB,CAAC;CACrC;AAED,MAAM,WAAW,4BAA4B;IAC3C,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6FAA6F;IAC7F,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,sBAAsB;IACtB,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC9B;AAQD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,iBAAiB,CAAC,qBAAqB,CAuCrE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,iBAAiB,CAAC,4BAA4B,CAmBnF,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
|
|
2
|
+
import { useState } from 'preact/hooks';
|
|
3
|
+
import cx from 'classnames';
|
|
4
|
+
import styles from './ResultsAccordion.module.css';
|
|
5
|
+
import ErrorIcon from '../../images/error-24.inline.svg';
|
|
6
|
+
import SuccessIcon from '../../images/success-24.inline.svg';
|
|
7
|
+
import WarningIcon from '../../images/warning-24.inline.svg';
|
|
8
|
+
import ChevronDownIcon from '../../images/chevrondown-20.inline.svg';
|
|
9
|
+
import { Button } from '../Button/Button.js';
|
|
10
|
+
const resultIcons = {
|
|
11
|
+
error: _jsx("img", { src: ErrorIcon, alt: "Error" }),
|
|
12
|
+
warning: _jsx("img", { src: WarningIcon, alt: "Warning" }),
|
|
13
|
+
success: _jsx("img", { src: SuccessIcon, alt: "Success" }),
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Collapsible section for displaying results of a bundle task or other item.
|
|
17
|
+
* This handles the header formatting and layout, expanding/collapsing, and displaying content.
|
|
18
|
+
*/
|
|
19
|
+
export const ResultsAccordion = (props) => {
|
|
20
|
+
const { name, result, headerEndContent, headerCommands, getContent, index } = props;
|
|
21
|
+
const [isOpen, setIsOpen] = useState(undefined);
|
|
22
|
+
const showContent = isOpen === true || (isOpen === undefined && result === 'error');
|
|
23
|
+
const headerButtonId = `results-accordion-button-${index}`;
|
|
24
|
+
const contentId = `results-accordion-content-${index}`;
|
|
25
|
+
// Trying to follow the accordion pattern: https://www.w3.org/WAI/ARIA/apg/patterns/accordion/
|
|
26
|
+
// except the odd thing is we want to allow a separate click target for a refresh button at the end
|
|
27
|
+
return (_jsxs("div", { class: styles.root, children: [_jsxs("div", { class: cx(styles.header, styles[result], showContent && styles.expanded), children: [_jsx("h3", { class: styles.headerButtonWrapper, children: _jsxs(Button, { id: headerButtonId, class: styles.headerButton, variant: "custom", "aria-expanded": showContent, "aria-controls": contentId, onClick: () => setIsOpen(!showContent), children: [_jsx("img", { class: cx(styles.expandIcon, !showContent && styles.collapsed), src: ChevronDownIcon,
|
|
28
|
+
// With the wrapping button, the chevron is presentation-only
|
|
29
|
+
alt: "" }), resultIcons[result], _jsx("div", { class: styles.title, children: name }), headerEndContent && _jsx("div", { class: styles.headerEnd, children: headerEndContent })] }) }), headerCommands && _jsx("div", { class: styles.headerCommands, children: headerCommands })] }), _jsx("div", { id: contentId, class: showContent ? styles.content : styles.contentHidden, children: showContent && getContent() })] }));
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Sub-section to return from `ResultsAccordionProps.getContent`.
|
|
33
|
+
* If there are no children and no `itemValue`, the section will be ignored.
|
|
34
|
+
*/
|
|
35
|
+
export const ResultsAccordionContent = (props) => {
|
|
36
|
+
const { title, itemName, itemValue, children } = props;
|
|
37
|
+
if (!children && !(itemValue && itemName)) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
// Use a fragment so the sub-parts use the parent's flex styling
|
|
41
|
+
return (_jsxs(_Fragment, { children: [title && _jsx("h4", { class: styles.title, children: title }), itemName && itemValue ? (_jsxs("div", { children: [_jsx("div", { class: styles.itemName, children: itemName }), _jsx("div", { class: styles.itemValue, children: itemValue })] })) : null, children] }));
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=ResultsAccordion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResultsAccordion.js","sourceRoot":"","sources":["../../../src/components/ResultsAccordion/ResultsAccordion.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,MAAM,MAAM,+BAA+B,CAAC;AACnD,OAAO,SAAS,MAAM,kCAAkC,CAAC;AACzD,OAAO,WAAW,MAAM,oCAAoC,CAAC;AAC7D,OAAO,WAAW,MAAM,oCAAoC,CAAC;AAC7D,OAAO,eAAe,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAgC7C,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,cAAK,GAAG,EAAE,SAAS,EAAE,GAAG,EAAC,OAAO,GAAG;IAC1C,OAAO,EAAE,cAAK,GAAG,EAAE,WAAW,EAAE,GAAG,EAAC,SAAS,GAAG;IAChD,OAAO,EAAE,cAAK,GAAG,EAAE,WAAW,EAAE,GAAG,EAAC,SAAS,GAAG;CACjD,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAA6C,CAAC,KAAK,EAAE,EAAE;IAClF,MAAM,EAAE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AC,cAAc,YAAG,cAAc,GAAO,IACxE,EACN,cAAK,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,YAC3E,WAAW,IAAI,UAAU,EAAE,GACxB,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAoD,CAAC,KAAK,EAAE,EAAE;IAChG,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACvD,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,SAAS,IAAI,QAAQ,CAAC,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gEAAgE;IAChE,OAAO,CACL,8BACG,KAAK,IAAI,aAAI,KAAK,EAAE,MAAM,CAAC,KAAK,YAAG,KAAK,GAAM,EAC9C,QAAQ,IAAI,SAAS,CAAC,CAAC,CAAC,CACvB,0BACE,cAAK,KAAK,EAAE,MAAM,CAAC,QAAQ,YAAG,QAAQ,GAAO,EAC7C,cAAK,KAAK,EAAE,MAAM,CAAC,SAAS,YAAG,SAAS,GAAO,IAC3C,CACP,CAAC,CAAC,CAAC,IAAI,EACP,QAAQ,IACR,CACJ,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { ComponentChildren, FunctionComponent } from 'preact';\nimport { useState } from 'preact/hooks';\nimport cx from 'classnames';\nimport styles from './ResultsAccordion.module.css';\nimport ErrorIcon from '../../images/error-24.inline.svg';\nimport SuccessIcon from '../../images/success-24.inline.svg';\nimport WarningIcon from '../../images/warning-24.inline.svg';\nimport ChevronDownIcon from '../../images/chevrondown-20.inline.svg';\nimport { Button } from '../Button/Button.js';\n\nexport interface ResultsAccordionProps {\n /** Name of the bundle task or other item (can have formatting, but should not have a header element) */\n name: ComponentChildren;\n /** Index used for generating accordion element IDs */\n index: number;\n result: 'success' | 'warning' | 'error';\n /** Info that goes at the end of the header, inside the clickable area */\n headerEndContent?: string;\n /** Commands to go at the end of the header, outside the clickable area */\n headerCommands?: ComponentChildren;\n /**\n * Get the content, only if the section is expanded.\n * Use `CollapsibleResultsSubSection` for formatting (returning multiple sections if needed).\n *\n * This callback is to prevent rendering thousands of bundle result details unnecessarily.\n */\n getContent: () => ComponentChildren;\n}\n\nexport interface ResultsAccordionContentProps {\n /** Will be at start of sub-section and styled slightly larger if provided */\n title?: string;\n /** Item name, such as \"Input path\". Ignored if `itemValue` is not provided. */\n itemName?: string;\n /** Value corresponding to `itemName`, such as the path to a package. Requires `itemName`. */\n itemValue?: ComponentChildren;\n /** Custom children */\n children?: ComponentChildren;\n}\n\nconst resultIcons = {\n error: <img src={ErrorIcon} alt=\"Error\" />,\n warning: <img src={WarningIcon} alt=\"Warning\" />,\n success: <img src={SuccessIcon} alt=\"Success\" />,\n};\n\n/**\n * Collapsible section for displaying results of a bundle task or other item.\n * This handles the header formatting and layout, expanding/collapsing, and displaying content.\n */\nexport const ResultsAccordion: FunctionComponent<ResultsAccordionProps> = (props) => {\n const { name, result, headerEndContent, headerCommands, getContent, index } = props;\n const [isOpen, setIsOpen] = useState<boolean | undefined>(undefined);\n const showContent = isOpen === true || (isOpen === undefined && result === 'error');\n const headerButtonId = `results-accordion-button-${index}`;\n const contentId = `results-accordion-content-${index}`;\n\n // Trying to follow the accordion pattern: https://www.w3.org/WAI/ARIA/apg/patterns/accordion/\n // except the odd thing is we want to allow a separate click target for a refresh button at the end\n return (\n <div class={styles.root}>\n <div class={cx(styles.header, styles[result], showContent && styles.expanded)}>\n <h3 class={styles.headerButtonWrapper}>\n <Button\n id={headerButtonId}\n class={styles.headerButton}\n variant=\"custom\"\n aria-expanded={showContent}\n aria-controls={contentId}\n onClick={() => setIsOpen(!showContent)}\n >\n <img\n class={cx(styles.expandIcon, !showContent && styles.collapsed)}\n src={ChevronDownIcon}\n // With the wrapping button, the chevron is presentation-only\n alt=\"\"\n />\n {resultIcons[result]}\n <div class={styles.title}>{name}</div>\n {headerEndContent && <div class={styles.headerEnd}>{headerEndContent}</div>}\n </Button>\n </h3>\n {headerCommands && <div class={styles.headerCommands}>{headerCommands}</div>}\n </div>\n <div id={contentId} class={showContent ? styles.content : styles.contentHidden}>\n {showContent && getContent()}\n </div>\n </div>\n );\n};\n\n/**\n * Sub-section to return from `ResultsAccordionProps.getContent`.\n * If there are no children and no `itemValue`, the section will be ignored.\n */\nexport const ResultsAccordionContent: FunctionComponent<ResultsAccordionContentProps> = (props) => {\n const { title, itemName, itemValue, children } = props;\n if (!children && !(itemValue && itemName)) {\n return null;\n }\n\n // Use a fragment so the sub-parts use the parent's flex styling\n return (\n <>\n {title && <h4 class={styles.title}>{title}</h4>}\n {itemName && itemValue ? (\n <div>\n <div class={styles.itemName}>{itemName}</div>\n <div class={styles.itemValue}>{itemValue}</div>\n </div>\n ) : null}\n {children}\n </>\n );\n};\n"]}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { FunctionComponent } from 'preact';
|
|
2
2
|
import type { PageLoadTimeReport } from '../../hooks/usePageLoadTimeReporter.js';
|
|
3
3
|
export interface StatusBadgeProps {
|
|
4
|
-
|
|
5
|
-
onExpand?: () => void;
|
|
6
|
-
onToggle?: () => void;
|
|
4
|
+
onExpand: () => void;
|
|
7
5
|
pageLoadTimeReport: PageLoadTimeReport;
|
|
8
6
|
}
|
|
9
|
-
export declare const StatusBadge:
|
|
7
|
+
export declare const StatusBadge: FunctionComponent<StatusBadgeProps>;
|
|
10
8
|
//# sourceMappingURL=StatusBadge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatusBadge.d.ts","sourceRoot":"","sources":["../../../src/components/StatusBadge/StatusBadge.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"StatusBadge.d.ts","sourceRoot":"","sources":["../../../src/components/StatusBadge/StatusBadge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAOhD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAGjF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,kBAAkB,EAAE,kBAAkB,CAAC;CACxC;AAQD,eAAO,MAAM,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,CAgE3D,CAAC"}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { useCallback, useRef, useState } from 'preact/hooks';
|
|
2
3
|
import { useDraggable } from '../../hooks/useDraggable.js';
|
|
3
4
|
import styles from './StatusBadge.module.css';
|
|
4
|
-
import
|
|
5
|
+
import cx from 'classnames';
|
|
5
6
|
import { useStatus } from '../CloudpackProvider/useStatus.js';
|
|
6
7
|
import { elementIds } from '../../constants.js';
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
import { Button } from '../Button/Button.js';
|
|
9
|
+
const badgeStatusKey = 'cloudpack.badgeStatus';
|
|
10
|
+
const leftChevron = '\u00AB';
|
|
11
|
+
const rightChevron = '\u00BB';
|
|
12
|
+
const buttonHint = '(see details)';
|
|
13
|
+
const buttonHelp = 'Show bundle result details';
|
|
14
|
+
export const StatusBadge = ({ onExpand, pageLoadTimeReport }) => {
|
|
9
15
|
const rootElementRef = useRef(null);
|
|
10
16
|
const dragElementRef = useRef(null);
|
|
11
17
|
const status = useStatus();
|
|
@@ -13,77 +19,60 @@ export const StatusBadge = ({ inline, onExpand, pageLoadTimeReport }) => {
|
|
|
13
19
|
const shouldRender = status.status !== 'unknown';
|
|
14
20
|
const toggleBadgeVisibility = useCallback(() => {
|
|
15
21
|
const newCollapsedState = !isCollapsed;
|
|
16
|
-
console.log('Status badge collapsed state:', newCollapsedState);
|
|
17
22
|
setIsCollapsed(newCollapsedState);
|
|
18
23
|
localStorage.setItem(badgeStatusKey, newCollapsedState ? 'collapsed' : '');
|
|
19
24
|
}, [isCollapsed]);
|
|
20
25
|
useDraggable({
|
|
21
26
|
// If we're not yet able to render, don't enable dragging yet.
|
|
22
27
|
// Otherwise the event handlers won't be attached when the component renders.
|
|
23
|
-
enabled: shouldRender
|
|
28
|
+
enabled: shouldRender,
|
|
24
29
|
containerElementRef: rootElementRef,
|
|
25
30
|
dragElementRef,
|
|
26
31
|
});
|
|
27
32
|
if (!shouldRender) {
|
|
28
33
|
return null;
|
|
29
34
|
}
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const badge = (
|
|
37
|
-
|
|
38
|
-
React.createElement("div", { className: styles.grip }),
|
|
39
|
-
React.createElement("div", { className: styles.grip }))),
|
|
40
|
-
React.createElement("button", { className: styles.button, onClick: onExpand, "aria-label": "Expand overlay" },
|
|
41
|
-
React.createElement("div", { className: styles.value }, getStatusString(status))),
|
|
42
|
-
React.createElement("div", null,
|
|
43
|
-
getStatsString(status),
|
|
44
|
-
metric),
|
|
45
|
-
React.createElement("button", { className: `${styles.button} ${styles.chevron}`, onClick: toggleBadgeVisibility }, isCollapsed ? leftChevron : rightChevron)));
|
|
46
|
-
return inline ? (badge) : (React.createElement("div", { className: styles.fixedOverlay },
|
|
47
|
-
React.createElement("div", { className: styles.contentSurface }, badge)));
|
|
35
|
+
const { buttonStatusText, statusClass, statsText } = processStatus(status, pageLoadTimeReport);
|
|
36
|
+
// WARNING: If you change this text, also update the `name` used to find the button in
|
|
37
|
+
// apps/test-start-e2e/src/utilities/verifyOverlay.ts
|
|
38
|
+
const buttonText = 'Cloudpack: ' + buttonStatusText;
|
|
39
|
+
const buttonAriaLabel = `${buttonText.replace(buttonHint, '')}. ${buttonHelp}`;
|
|
40
|
+
const collapseButtonText = isCollapsed ? 'Expand Cloudpack badge' : 'Collapse';
|
|
41
|
+
const badge = (_jsxs("div", { id: elementIds.statusBadgeRoot, ref: rootElementRef, class: cx(styles.badge, isCollapsed && styles.collapsed, statusClass), children: [_jsxs("div", { ref: dragElementRef, class: styles.gripArea, "aria-hidden": true, children: [_jsx("div", { class: styles.grip }), _jsx("div", { class: styles.grip })] }), _jsx(Button, { variant: "custom", class: styles.button, onClick: onExpand, title: buttonHelp, "aria-label": buttonAriaLabel, children: _jsx("div", { class: styles.buttonText, children: buttonText }) }), _jsx("div", { children: statsText }), _jsx(Button, { variant: "custom", class: cx(styles.button, styles.chevron), onClick: toggleBadgeVisibility, title: collapseButtonText, "aria-label": collapseButtonText, children: isCollapsed ? leftChevron : rightChevron })] }));
|
|
42
|
+
return (_jsx("div", { class: styles.fixedOverlay, children: _jsx("div", { class: styles.contentSurface, children: badge }) }));
|
|
48
43
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Based on the status, get the badge color, button text, and stats text.
|
|
46
|
+
*/
|
|
47
|
+
function processStatus(cpStatus, pltReport) {
|
|
48
|
+
const { status, totalTasks, remainingTasks, totalErrors, totalWarnings } = cpStatus;
|
|
49
|
+
let statusClass;
|
|
50
|
+
let buttonStatusText;
|
|
51
|
+
let statsText = '';
|
|
52
|
+
if (status === 'idle' && totalTasks) {
|
|
53
|
+
[statusClass, buttonStatusText] = totalErrors
|
|
54
|
+
? [styles.error, `errors ${buttonHint}`]
|
|
55
|
+
: totalWarnings
|
|
56
|
+
? [styles.warning, `warnings ${buttonHint}`]
|
|
57
|
+
: [styles.success, 'success'];
|
|
52
58
|
}
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
else {
|
|
60
|
+
// no styling for this case
|
|
61
|
+
buttonStatusText = status === 'pending' ? 'bundling...' : 'idle';
|
|
55
62
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
function getCollapsedClassName(isCollapsed) {
|
|
69
|
-
return cx(styles.badge, {
|
|
70
|
-
[styles.collapsed]: isCollapsed,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
function getStatsString(status) {
|
|
74
|
-
const { totalTasks, remainingTasks, totalErrors, totalWarnings } = status;
|
|
75
|
-
if (totalTasks === 0) {
|
|
76
|
-
return '';
|
|
63
|
+
if (totalTasks) {
|
|
64
|
+
// "Number of tasks" is likely not a meaningful metric for users (and doesn't strictly correspond to
|
|
65
|
+
// number of packages), so just show either estimated percentage or "completed" plus any issue counts.
|
|
66
|
+
const taskStats = [
|
|
67
|
+
remainingTasks === 0 ? 'completed' : `${(remainingTasks / totalTasks).toFixed(1)}% completed`,
|
|
68
|
+
totalErrors && `${totalErrors} error${totalErrors > 1 ? 's' : ''}`,
|
|
69
|
+
totalWarnings && `${totalWarnings} warning${totalWarnings > 1 ? 's' : ''}`,
|
|
70
|
+
]
|
|
71
|
+
.filter(Boolean)
|
|
72
|
+
.join(', ');
|
|
73
|
+
const pltStat = pltReport.status === 'success' ? ` in ${Math.round(pltReport.pageLoadTime) ?? '??'}ms` : '';
|
|
74
|
+
statsText = taskStats + pltStat;
|
|
77
75
|
}
|
|
78
|
-
return
|
|
79
|
-
remainingTasks > 0 && `${remainingTasks} of ${totalTasks} tasks pending`,
|
|
80
|
-
remainingTasks === 0 && `${totalTasks} tasks completed`,
|
|
81
|
-
totalErrors === 1 && `${totalErrors} error`,
|
|
82
|
-
totalErrors > 1 && `${totalErrors} errors`,
|
|
83
|
-
totalWarnings === 1 && `${totalWarnings} warning`,
|
|
84
|
-
totalWarnings > 1 && `${totalWarnings} warnings`,
|
|
85
|
-
]
|
|
86
|
-
.filter(Boolean)
|
|
87
|
-
.join(', ');
|
|
76
|
+
return { statusClass, buttonStatusText, statsText };
|
|
88
77
|
}
|
|
89
78
|
//# sourceMappingURL=StatusBadge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatusBadge.js","sourceRoot":"","sources":["../../../src/components/StatusBadge/StatusBadge.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"StatusBadge.js","sourceRoot":"","sources":["../../../src/components/StatusBadge/StatusBadge.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,MAAM,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAwB,MAAM,mCAAmC,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAO7C,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAC/C,MAAM,WAAW,GAAG,QAAQ,CAAC;AAC7B,MAAM,YAAY,GAAG,QAAQ,CAAC;AAC9B,MAAM,UAAU,GAAG,eAAe,CAAC;AACnC,MAAM,UAAU,GAAG,4BAA4B,CAAC;AAEhD,MAAM,CAAC,MAAM,WAAW,GAAwC,CAAC,EAAE,QAAQ,EAAE,kBAAkB,EAAE,EAAE,EAAE;IACnG,MAAM,cAAc,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IACpD,MAAM,cAAc,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IACpD,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAU,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;IAEhG,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,KAAK,SAAS,CAAC;IAEjD,MAAM,qBAAqB,GAAG,WAAW,C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AAM,CAAC;QACN,2BAA2B;QAC3B,gBAAgB,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC;IACnE,CAAC;IAED,IAAI,UAAU,EAAE,CAAC;QACf,oGAAoG;QACpG,sGAAsG;QACtG,MAAM,SAAS,GAAG;YAChB,cAAc,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,GAAG,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa;YAC7F,WAAW,IAAI,GAAG,WAAW,SAAS,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YAClE,aAAa,IAAI,GAAG,aAAa,WAAW,aAAa,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;SAC3E;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,IAAI,CAAC,CAAC;QAEd,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QAE5G,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IAClC,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC;AACtD,CAAC","sourcesContent":["import type { FunctionComponent } from 'preact';\nimport { useCallback, useRef, useState } from 'preact/hooks';\nimport { useDraggable } from '../../hooks/useDraggable.js';\nimport styles from './StatusBadge.module.css';\nimport cx from 'classnames';\nimport { useStatus, type CloudpackStatus } from '../CloudpackProvider/useStatus.js';\nimport { elementIds } from '../../constants.js';\nimport type { PageLoadTimeReport } from '../../hooks/usePageLoadTimeReporter.js';\nimport { Button } from '../Button/Button.js';\n\nexport interface StatusBadgeProps {\n onExpand: () => void;\n pageLoadTimeReport: PageLoadTimeReport;\n}\n\nconst badgeStatusKey = 'cloudpack.badgeStatus';\nconst leftChevron = '\\u00AB';\nconst rightChevron = '\\u00BB';\nconst buttonHint = '(see details)';\nconst buttonHelp = 'Show bundle result details';\n\nexport const StatusBadge: FunctionComponent<StatusBadgeProps> = ({ onExpand, pageLoadTimeReport }) => {\n const rootElementRef = useRef<HTMLDivElement>(null);\n const dragElementRef = useRef<HTMLDivElement>(null);\n const status = useStatus();\n const [isCollapsed, setIsCollapsed] = useState<boolean>(!!localStorage.getItem(badgeStatusKey));\n\n const shouldRender = status.status !== 'unknown';\n\n const toggleBadgeVisibility = useCallback(() => {\n const newCollapsedState = !isCollapsed;\n setIsCollapsed(newCollapsedState);\n localStorage.setItem(badgeStatusKey, newCollapsedState ? 'collapsed' : '');\n }, [isCollapsed]);\n\n useDraggable({\n // If we're not yet able to render, don't enable dragging yet.\n // Otherwise the event handlers won't be attached when the component renders.\n enabled: shouldRender,\n containerElementRef: rootElementRef,\n dragElementRef,\n });\n\n if (!shouldRender) {\n return null;\n }\n\n const { buttonStatusText, statusClass, statsText } = processStatus(status, pageLoadTimeReport);\n // WARNING: If you change this text, also update the `name` used to find the button in\n // apps/test-start-e2e/src/utilities/verifyOverlay.ts\n const buttonText = 'Cloudpack: ' + buttonStatusText;\n const buttonAriaLabel = `${buttonText.replace(buttonHint, '')}. ${buttonHelp}`;\n const collapseButtonText = isCollapsed ? 'Expand Cloudpack badge' : 'Collapse';\n\n const badge = (\n <div\n id={elementIds.statusBadgeRoot}\n ref={rootElementRef}\n class={cx(styles.badge, isCollapsed && styles.collapsed, statusClass)}\n >\n <div ref={dragElementRef} class={styles.gripArea} aria-hidden>\n <div class={styles.grip} />\n <div class={styles.grip} />\n </div>\n <Button variant=\"custom\" class={styles.button} onClick={onExpand} title={buttonHelp} aria-label={buttonAriaLabel}>\n <div class={styles.buttonText}>{buttonText}</div>\n </Button>\n <div>{statsText}</div>\n <Button\n variant=\"custom\"\n class={cx(styles.button, styles.chevron)}\n onClick={toggleBadgeVisibility}\n title={collapseButtonText}\n aria-label={collapseButtonText}\n >\n {isCollapsed ? leftChevron : rightChevron}\n </Button>\n </div>\n );\n\n return (\n <div class={styles.fixedOverlay}>\n <div class={styles.contentSurface}>{badge}</div>\n </div>\n );\n};\n\n/**\n * Based on the status, get the badge color, button text, and stats text.\n */\nfunction processStatus(\n cpStatus: CloudpackStatus,\n pltReport: PageLoadTimeReport,\n): {\n /** class (color) for the badge root */\n statusClass: string | undefined;\n /** short status text for the button to open the overlay */\n buttonStatusText: string;\n /** stats to display after the button, like \"50% completed, 2 errors, 3 warnings in 500ms\" */\n statsText: string;\n} {\n const { status, totalTasks, remainingTasks, totalErrors, totalWarnings } = cpStatus;\n\n let statusClass: string | undefined;\n let buttonStatusText: string;\n let statsText = '';\n\n if (status === 'idle' && totalTasks) {\n [statusClass, buttonStatusText] = totalErrors\n ? [styles.error, `errors ${buttonHint}`]\n : totalWarnings\n ? [styles.warning, `warnings ${buttonHint}`]\n : [styles.success, 'success'];\n } else {\n // no styling for this case\n buttonStatusText = status === 'pending' ? 'bundling...' : 'idle';\n }\n\n if (totalTasks) {\n // \"Number of tasks\" is likely not a meaningful metric for users (and doesn't strictly correspond to\n // number of packages), so just show either estimated percentage or \"completed\" plus any issue counts.\n const taskStats = [\n remainingTasks === 0 ? 'completed' : `${(remainingTasks / totalTasks).toFixed(1)}% completed`,\n totalErrors && `${totalErrors} error${totalErrors > 1 ? 's' : ''}`,\n totalWarnings && `${totalWarnings} warning${totalWarnings > 1 ? 's' : ''}`,\n ]\n .filter(Boolean)\n .join(', ');\n\n const pltStat = pltReport.status === 'success' ? ` in ${Math.round(pltReport.pageLoadTime) ?? '??'}ms` : '';\n\n statsText = taskStats + pltStat;\n }\n\n return { statusClass, buttonStatusText, statsText };\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import type { FunctionComponent } from 'preact';
|
|
2
|
+
import type { InputHTMLAttributes } from 'preact/compat';
|
|
3
|
+
export interface SearchboxProps extends Required<Pick<InputHTMLAttributes, 'onInput'>>, Pick<InputHTMLAttributes, 'style'> {
|
|
3
4
|
value: string;
|
|
4
|
-
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
5
5
|
}
|
|
6
|
-
export declare const Searchbox:
|
|
6
|
+
export declare const Searchbox: FunctionComponent<SearchboxProps>;
|
|
7
7
|
//# sourceMappingURL=Searchbox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Searchbox.d.ts","sourceRoot":"","sources":["../../../src/components/StatusDialog/Searchbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"Searchbox.d.ts","sourceRoot":"","sources":["../../../src/components/StatusDialog/Searchbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGzD,MAAM,WAAW,cACf,SAAQ,QAAQ,CAAC,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC,EACpD,IAAI,CAAC,mBAAmB,EAAE,OAAO,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,SAAS,EAAE,iBAAiB,CAAC,cAAc,CAavD,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
2
2
|
import styles from './Searchbox.module.css';
|
|
3
|
-
export const Searchbox = (
|
|
4
|
-
|
|
3
|
+
export const Searchbox = (props) => {
|
|
4
|
+
const { value, onInput, style } = props;
|
|
5
|
+
return (_jsx("input", { type: "text", "aria-label": "Search", placeholder: "Search", class: styles.searchbox, style: style, onInput: onInput, value: value }));
|
|
5
6
|
};
|
|
6
7
|
//# sourceMappingURL=Searchbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Searchbox.js","sourceRoot":"","sources":["../../../src/components/StatusDialog/Searchbox.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Searchbox.js","sourceRoot":"","sources":["../../../src/components/StatusDialog/Searchbox.tsx"],"names":[],"mappings":";AAEA,OAAO,MAAM,MAAM,wBAAwB,CAAC;AAQ5C,MAAM,CAAC,MAAM,SAAS,GAAsC,CAAC,KAAK,EAAE,EAAE;IACpE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IACxC,OAAO,CACL,gBACE,IAAI,EAAC,MAAM,gBACA,QAAQ,EACnB,WAAW,EAAC,QAAQ,EACpB,KAAK,EAAE,MAAM,CAAC,SAAS,EACvB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,GACZ,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { FunctionComponent } from 'preact';\nimport type { InputHTMLAttributes } from 'preact/compat';\nimport styles from './Searchbox.module.css';\n\nexport interface SearchboxProps\n extends Required<Pick<InputHTMLAttributes, 'onInput'>>,\n Pick<InputHTMLAttributes, 'style'> {\n value: string;\n}\n\nexport const Searchbox: FunctionComponent<SearchboxProps> = (props) => {\n const { value, onInput, style } = props;\n return (\n <input\n type=\"text\"\n aria-label=\"Search\"\n placeholder=\"Search\"\n class={styles.searchbox}\n style={style}\n onInput={onInput}\n value={value}\n />\n );\n};\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { FunctionComponent } from 'preact';
|
|
2
2
|
export interface StatusDialogProps {
|
|
3
3
|
onClose: () => void;
|
|
4
4
|
}
|
|
5
|
-
export declare const StatusDialog:
|
|
5
|
+
export declare const StatusDialog: FunctionComponent<StatusDialogProps>;
|
|
6
6
|
export default StatusDialog;
|
|
7
7
|
//# sourceMappingURL=StatusDialog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatusDialog.d.ts","sourceRoot":"","sources":["../../../src/components/StatusDialog/StatusDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"StatusDialog.d.ts","sourceRoot":"","sources":["../../../src/components/StatusDialog/StatusDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAShD,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,YAAY,EAAE,iBAAiB,CAAC,iBAAiB,CAkC7D,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { useCallback, useState } from 'preact/hooks';
|
|
2
3
|
import { TaskList } from './TaskList.js';
|
|
3
4
|
import { useCloudpack } from '../CloudpackProvider/CloudpackProvider.js';
|
|
4
5
|
import { Button } from '../Button/Button.js';
|
|
@@ -7,20 +8,15 @@ import { Searchbox } from './Searchbox.js';
|
|
|
7
8
|
import { elementIds } from '../../constants.js';
|
|
8
9
|
export const StatusDialog = ({ onClose }) => {
|
|
9
10
|
const cloudpack = useCloudpack();
|
|
10
|
-
const [searchFilter, setSearchFilter] =
|
|
11
|
-
const [issuesOnly, setIssuesOnly] =
|
|
11
|
+
const [searchFilter, setSearchFilter] = useState('');
|
|
12
|
+
const [issuesOnly, setIssuesOnly] = useState(false);
|
|
12
13
|
const handleSearchChange = useCallback((event) => {
|
|
13
14
|
event.preventDefault();
|
|
14
15
|
setSearchFilter(event.target.value);
|
|
15
16
|
}, []);
|
|
16
17
|
const restartAllTasks = () => void cloudpack.restartAllTasks.mutate();
|
|
17
18
|
const toggleIssuesOnly = () => void setIssuesOnly((value) => !value);
|
|
18
|
-
return (
|
|
19
|
-
React.createElement(Button, { primary: true, onClick: restartAllTasks, key: "restart" }, "Restart all tasks"),
|
|
20
|
-
React.createElement(Button, { onClick: toggleIssuesOnly, key: "issues" }, issuesOnly ? 'Show all tasks' : 'Show tasks with issues'),
|
|
21
|
-
] },
|
|
22
|
-
React.createElement(Searchbox, { value: searchFilter, onChange: handleSearchChange }),
|
|
23
|
-
React.createElement(TaskList, { searchFilter: searchFilter, issuesOnly: issuesOnly })));
|
|
19
|
+
return (_jsx(Dialog, { title: "Cloudpack bundle results", id: elementIds.statusDialogRoot, draggable: true, onClose: onClose, commands: _jsxs(_Fragment, { children: [_jsx(Button, { variant: "primary", iconName: "refresh", onClick: restartAllTasks, children: "Re-bundle all packages" }), _jsx(Button, { onClick: toggleIssuesOnly, children: issuesOnly ? 'Show all packages' : 'Show packages with issues' }), _jsx(Searchbox, { value: searchFilter, onInput: handleSearchChange, style: { marginLeft: 'auto' } })] }), children: _jsx(TaskList, { searchFilter: searchFilter, issuesOnly: issuesOnly }) }));
|
|
24
20
|
};
|
|
25
21
|
export default StatusDialog;
|
|
26
22
|
//# sourceMappingURL=StatusDialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatusDialog.js","sourceRoot":"","sources":["../../../src/components/StatusDialog/StatusDialog.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"StatusDialog.js","sourceRoot":"","sources":["../../../src/components/StatusDialog/StatusDialog.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,S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E,MAAM,EAAE,GAAI,IAC7F,YAGL,KAAC,QAAQ,IAAC,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,GAAI,GACzD,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import type { FunctionComponent } from 'preact';\nimport { useCallback, useState } from 'preact/hooks';\nimport { TaskList } from './TaskList.js';\nimport { useCloudpack } from '../CloudpackProvider/CloudpackProvider.js';\nimport { Button } from '../Button/Button.js';\nimport { Dialog } from '../Dialog/Dialog.js';\nimport { Searchbox, type SearchboxProps } from './Searchbox.js';\nimport { elementIds } from '../../constants.js';\n\nexport interface StatusDialogProps {\n onClose: () => void;\n}\n\nexport const StatusDialog: FunctionComponent<StatusDialogProps> = ({ onClose }) => {\n const cloudpack = useCloudpack();\n const [searchFilter, setSearchFilter] = useState('');\n const [issuesOnly, setIssuesOnly] = useState(false);\n\n const handleSearchChange = useCallback<SearchboxProps['onInput']>((event) => {\n event.preventDefault();\n setSearchFilter((event.target as HTMLInputElement).value);\n }, []);\n\n const restartAllTasks = () => void cloudpack.restartAllTasks.mutate();\n\n const toggleIssuesOnly = () => void setIssuesOnly((value) => !value);\n\n return (\n <Dialog\n title=\"Cloudpack bundle results\"\n id={elementIds.statusDialogRoot}\n draggable\n onClose={onClose}\n commands={\n <>\n <Button variant=\"primary\" iconName=\"refresh\" onClick={restartAllTasks}>\n Re-bundle all packages\n </Button>\n <Button onClick={toggleIssuesOnly}>{issuesOnly ? 'Show all packages' : 'Show packages with issues'}</Button>\n {/* Align the search box to the right */}\n <Searchbox value={searchFilter} onInput={handleSearchChange} style={{ marginLeft: 'auto' }} />\n </>\n }\n >\n <TaskList searchFilter={searchFilter} issuesOnly={issuesOnly} />\n </Dialog>\n );\n};\n\nexport default StatusDialog;\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { FunctionComponent } from 'preact';
|
|
2
2
|
export interface TaskListProps {
|
|
3
3
|
searchFilter?: string;
|
|
4
4
|
issuesOnly?: boolean;
|
|
5
5
|
}
|
|
6
|
-
export declare const TaskList:
|
|
6
|
+
export declare const TaskList: FunctionComponent<TaskListProps>;
|
|
7
7
|
//# sourceMappingURL=TaskList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TaskList.d.ts","sourceRoot":"","sources":["../../../src/components/StatusDialog/TaskList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"TaskList.d.ts","sourceRoot":"","sources":["../../../src/components/StatusDialog/TaskList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAMhD,MAAM,WAAW,aAAa;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,QAAQ,EAAE,iBAAiB,CAAC,aAAa,CAoBrD,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
2
2
|
import { TaskStatus } from './TaskStatus.js';
|
|
3
3
|
import { useStatusDetails } from '../CloudpackProvider/useStatusDetails.js';
|
|
4
4
|
import styles from './TaskList.module.css';
|
|
@@ -13,7 +13,7 @@ export const TaskList = ({ searchFilter, issuesOnly }) => {
|
|
|
13
13
|
if (issuesOnly) {
|
|
14
14
|
filteredTasks = filteredTasks.filter(({ errors, warnings }) => errors?.length || warnings?.length);
|
|
15
15
|
}
|
|
16
|
-
return (
|
|
16
|
+
return (_jsx("div", { class: styles.root, children: filteredTasks.map((task, index) => (_jsx(TaskStatus, { index: index, task: task }, task.name))) }));
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
19
|
* Really the server should be sorting. Get stuff out of the browser.
|