Skip to content

Commit ca922a3

Browse files
chore: Export demo updates
1 parent 7dbde13 commit ca922a3

File tree

17 files changed

+57
-36
lines changed

17 files changed

+57
-36
lines changed

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: MIT-0
3+
34
module.exports = {
45
preset: 'ts-jest',
56
testEnvironment: 'node',

package.json

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
11
{
22
"name": "@cloudscape-design/demos",
3-
"private": true,
43
"version": "3.0.0",
4+
"scripts": {
5+
"typecheck": "tsc",
6+
"clean": "rm -rf lib",
7+
"lint": "eslint --fix --ignore-path .gitignore --ext ts,tsx,js,jsx .",
8+
"prepare": "husky install",
9+
"generate-html": "cross-env THEME=$npm_config_theme node ./scripts/generate-html-files",
10+
"webpack": "cross-env NODE_ENV=production webpack",
11+
"build:theme": "cross-env THEME=$npm_config_theme npm run webpack && npm run generate-html",
12+
"build": "npm run build:theme --theme=all",
13+
"start": "npm run start:theme",
14+
"start:theme": "cross-env NODE_ENV=development THEME=$npm_config_theme webpack-dev-server",
15+
"serve": "node ./scripts/dev-server.js",
16+
"jest": "node --experimental-vm-modules ./node_modules/.bin/jest ./test/**/*.test.ts",
17+
"serve-test": "run-p -r serve jest",
18+
"pretest": "npm-run-all -s clean lint typecheck build",
19+
"test": "npm run test-no-build",
20+
"test-no-build": "run-s test:*",
21+
"test:default": "cross-env npm run serve-test"
22+
},
523
"devDependencies": {
624
"@babel/core": "^7.18.13",
725
"@babel/preset-env": "^7.18.10",
@@ -31,6 +49,7 @@
3149
"axe-core": "^4.4.3",
3250
"babel-loader": "^9.2.1",
3351
"copy-webpack-plugin": "^12.0.2",
52+
"cross-env": "^7.0.3",
3453
"css-loader": "^7.1.2",
3554
"date-fns": "^4.1.0",
3655
"eslint": "^8.22.0",
@@ -59,22 +78,6 @@
5978
"webpack-dev-server": "^5.2.0",
6079
"zod": "^3.23.8"
6180
},
62-
"scripts": {
63-
"webpack": "NODE_ENV=production webpack",
64-
"clean": "rm -rf lib",
65-
"generate-html-files": "node ./scripts/generate-html-files",
66-
"jest": "node --experimental-vm-modules ./node_modules/.bin/jest ./test/**/*.test.ts",
67-
"build": "npm-run-all -s generate-html-files webpack",
68-
"pretest": "npm-run-all -s clean lint typecheck build",
69-
"typecheck": "tsc",
70-
"start": "NODE_ENV=development webpack-dev-server",
71-
"start-no-live-reload": "node ./scripts/dev-server.js",
72-
"start:https": "webpack-dev-server --https --port=4443 --host=$(hostname)",
73-
"test-no-build": "run-p -r start-no-live-reload jest",
74-
"test": "npm run test-no-build",
75-
"prepare": "husky install",
76-
"lint": "eslint --fix --ignore-path .gitignore --ext ts,tsx,js,jsx ."
77-
},
7881
"browserslist": [
7982
"last 3 Chrome major versions",
8083
"last 3 Firefox major versions",
@@ -91,5 +94,6 @@
9194
"package-lock.json": [
9295
"./scripts/clean-package-lock.js"
9396
]
94-
}
97+
},
98+
"private": true
9599
}

scripts/dev-server.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: MIT-0
3+
import path from 'node:path';
34
import express from 'express';
45
import config from './config.js';
56

67
const app = express();
8+
const defaultTheme = '';
79

8-
app.use(express.static(config.outputPath));
10+
app.use(express.static(`${path.join(config.outputPath, process.env.THEME ?? defaultTheme)}`));
911
app.listen(config.devServerPort, () => {
10-
console.log(`Local server listening at localhost:${config.devServerPort}`);
12+
console.log(`Local server listening at http://localhost:${config.devServerPort}`);
1113
});

scripts/generate-html-files.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: MIT-0
33
import path from 'node:path';
4-
import examplesList from '../examples-list.json' assert { type: 'json' };
4+
import examplesList from '../examples-list.json' with { type: 'json' };
55
import { writeFileAsync } from './utils/fsAsync.js';
66
import config from './config.js';
77

src/pages/commons/common-components.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
import React, { forwardRef } from 'react';
44

55
import AppLayout, { AppLayoutProps } from '@cloudscape-design/components/app-layout';
6+
import AppLayoutToolbar from '@cloudscape-design/components/app-layout-toolbar';
67
import Badge from '@cloudscape-design/components/badge';
78
import Box from '@cloudscape-design/components/box';
89
import Button from '@cloudscape-design/components/button';
910
import { I18nProvider } from '@cloudscape-design/components/i18n';
1011
import enMessages from '@cloudscape-design/components/i18n/messages/all.en.json';
1112
import SpaceBetween from '@cloudscape-design/components/space-between';
1213

14+
import { isVisualRefresh } from '../../common/apply-mode';
15+
1316
// backward compatibility
1417
export * from './index';
1518

@@ -66,7 +69,7 @@ export const TableEmptyState = ({ resourceName }: { resourceName: string }) => (
6669
export const CustomAppLayout = forwardRef<AppLayoutProps.Ref, AppLayoutProps>(function CustomAppLayout(props, ref) {
6770
return (
6871
<I18nProvider locale="en" messages={[enMessages]}>
69-
<AppLayout ref={ref} {...props} />
72+
{isVisualRefresh ? <AppLayoutToolbar ref={ref} {...props} /> : <AppLayout ref={ref} {...props} />}
7073
</I18nProvider>
7174
);
7275
});

src/pages/configurable-dashboard/app.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ import { DashboardSideNavigation } from '../dashboard/components/side-navigation
1313
import Palette from './components/palette';
1414
import { Content } from './content';
1515
import { StoredWidgetPlacement } from './interfaces';
16-
import { getPaletteWidgets } from './widgets';
16+
import { allWidgets, getPaletteWidgets } from './widgets';
17+
18+
const supportedWidgets = new Set(Object.keys(allWidgets));
1719

1820
export function App() {
1921
const appLayoutRef = useRef<AppLayoutProps.Ref>(null);
@@ -25,6 +27,8 @@ export function App() {
2527
'ConfigurableDashboards-widgets-layout',
2628
);
2729
const [toolsContent, setToolsContent] = useState<React.ReactNode>(() => <DashboardMainInfo />);
30+
// some deleted/unavailable widgets might be dangling in localStorage, therefore we need to filter them
31+
const filteredLayout = layout?.filter(item => supportedWidgets.has(item.id));
2832

2933
const loadHelpPanelContent = (content: React.ReactNode) => {
3034
setToolsOpen(true);
@@ -45,15 +49,15 @@ export function App() {
4549
notifications={<Notifications />}
4650
content={
4751
<Content
48-
layout={layout ?? null}
52+
layout={filteredLayout ?? null}
4953
setLayout={setLayout}
5054
resetLayout={resetLayout}
5155
setSplitPanelOpen={setSplitPanelOpen}
5256
/>
5357
}
5458
splitPanel={
5559
<SplitPanel header="Add widgets" closeBehavior="hide" hidePreferencesButton={true}>
56-
<Palette items={getPaletteWidgets(layout ?? [])} />
60+
<Palette items={getPaletteWidgets(filteredLayout ?? [])} />
5761
</SplitPanel>
5862
}
5963
splitPanelPreferences={{ position: 'side' }}

src/pages/configurable-dashboard/widgets.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import { BoardProps } from '@cloudscape-design/board-components/board';
44

55
import {
6-
accountAttributes,
76
alarms,
87
events,
98
featuresSpotlight,
@@ -22,7 +21,6 @@ export type { DashboardWidgetItem };
2221
export { PaletteItem } from './components/palette-item';
2322

2423
export const allWidgets: Record<string, WidgetConfig> = {
25-
accountAttributes,
2624
alarms,
2725
serviceOverview,
2826
featuresSpotlight,
@@ -45,7 +43,6 @@ const defaultLayout: ReadonlyArray<StoredWidgetPlacement> = [
4543
{ id: 'events' },
4644
{ id: 'zoneStatus' },
4745
{ id: 'featuresSpotlight' },
48-
{ id: 'accountAttributes' },
4946
];
5047

5148
function merge<T extends { id: string }>(
@@ -71,7 +68,6 @@ export function getDefaultLayout(width: number) {
7168
{ id: 'zoneStatus', columnOffset: { '6': 2 } },
7269
{ id: 'events', columnOffset: { '6': 0 } },
7370
{ id: 'featuresSpotlight', columnOffset: { '6': 4 }, columnSpan: 2, rowSpan: 4 },
74-
{ id: 'accountAttributes', columnOffset: { '6': 2 }, columnSpan: 2, rowSpan: 2 },
7571
]);
7672
}
7773
if (width > 1045) {
@@ -92,7 +88,6 @@ export function getDefaultLayout(width: number) {
9288
{ id: 'serviceHealth', columnSpan: 2 },
9389
{ id: 'instanceHours', columnSpan: 1 },
9490
{ id: 'networkTraffic', columnSpan: 1 },
95-
{ id: 'accountAttributes', rowSpan: 2 },
9691
]);
9792
}
9893
if (width > 687) {

src/pages/dashboard/components/content.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import React from 'react';
55
import Grid from '@cloudscape-design/components/grid';
66

77
import {
8-
accountAttributes,
98
alarms,
109
BaseStaticWidget,
1110
events,
@@ -44,7 +43,6 @@ export function Content() {
4443
events,
4544
zoneStatus,
4645
featuresSpotlight,
47-
accountAttributes,
4846
].map((widget, index) => (
4947
<BaseStaticWidget key={index} config={widget.data} />
5048
))}

src/pages/dashboard/widgets/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: MIT-0
33
export { BaseStaticWidget } from './base-static-widget';
4-
export { accountAttributes } from './account-attributes';
54
export { alarms } from './alarms';
65
export { events } from './events';
76
export { featuresSpotlight } from './features-spotlight';

test/e2e/common/base-example-page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default class BaseExamplePage extends BasePageObject {
1313
*/
1414
public async scrollIntoViewAndClick(selector: string) {
1515
const element = await this.browser.$(selector);
16-
await element.scrollIntoView();
16+
await element.scrollIntoView({ block: 'center' });
1717
await element.click();
1818
}
1919
}

0 commit comments

Comments
 (0)