Skip to content

Commit 8a72e41

Browse files
dboyd13jessieweiyi
andauthored
feat: Full mode by default (#31)
--------- Co-authored-by: Jessie Wei <[email protected]>
1 parent f55916b commit 8a72e41

File tree

8 files changed

+93
-54
lines changed

8 files changed

+93
-54
lines changed

README.md

Lines changed: 46 additions & 32 deletions
Large diffs are not rendered by default.

docs/screenshot-threatsonly-mode.png

-53.2 KB
Binary file not shown.

docs/threat-composer.gif

570 KB
Loading

packages/threat-composer-app/src/components/Notifications/index.tsx

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,50 @@
1616
import Flashbar, { FlashbarProps } from '@cloudscape-design/components/flashbar';
1717
import Link from '@cloudscape-design/components/link';
1818
import * as awsui from '@cloudscape-design/design-tokens';
19-
import { FC, useState } from 'react';
19+
import { FC, useEffect, useState } from 'react';
2020

2121
export interface NotificationsProps {
2222
addPadding?: boolean;
2323
}
2424

2525
const Notifications: FC<NotificationsProps> = ({ addPadding }) => {
26-
const [items, setItems] = useState<FlashbarProps.MessageDefinition[]>([
27-
{
28-
type: 'info',
29-
dismissible: true,
30-
dismissLabel: 'Dismiss message',
31-
onDismiss: () => setItems([]),
32-
content: (
33-
<>
34-
This GitHub Page is provided for demonstration purposes only. Refer to {' '}
35-
<Link color="inverted" href="https://github.com/awslabs/threat-composer" external={true}>
36-
threat-composer GitHub Repo
37-
</Link> for self-hosting deployment instructions.
38-
</>
39-
),
40-
id: 'message_1',
41-
},
42-
]);
26+
const [items, setItems] = useState<FlashbarProps.MessageDefinition[]>([]);
27+
28+
useEffect(() => {
29+
setItems([
30+
{
31+
type: 'info',
32+
dismissible: true,
33+
dismissLabel: 'Dismiss message',
34+
onDismiss: () => setItems(prevItems => prevItems.filter((x) => x.id !== 'message_1')),
35+
content: (
36+
<>
37+
The 'Full' mode is now the default. To view the 'Threats Only' mode navigate the {' '}
38+
<Link color="inverted" href="https://awslabs.github.io/threat-composer?mode=ThreatsOnly" external={false}>
39+
ThreatsOnly
40+
</Link> URL, and bookmark or future reference.
41+
</>
42+
),
43+
id: 'message_1',
44+
},
45+
{
46+
type: 'info',
47+
dismissible: true,
48+
dismissLabel: 'Dismiss message',
49+
onDismiss: () => setItems(prevItems => prevItems.filter((x) => x.id !== 'message_2')),
50+
content: (
51+
<>
52+
This GitHub Page is provided for demonstration purposes only. Refer to {' '}
53+
<Link color="inverted" href="https://github.com/awslabs/threat-composer" external={true}>
54+
threat-composer GitHub Repo
55+
</Link> for self-hosting deployment instructions.
56+
</>
57+
),
58+
id: 'message_2',
59+
},
60+
]);
61+
}, []);
62+
4363
return items && items.length > 0 ? (<div style={addPadding ? {
4464
padding: awsui.spaceScaledL,
4565
backgroundColor: awsui.colorBackgroundHomeHeader,

packages/threat-composer-app/src/containers/App/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ const DEFAULT_MODE = process.env.REACT_APP_DEFAULT_MODE;
2626
const App: FC = () => {
2727
const [searchParams] = useSearchParams();
2828
const mode = searchParams.get('mode');
29-
return mode === 'Full' || DEFAULT_MODE === 'Full' ? <Full/> : <Standalone composeMode={mode} />;
29+
const composerMode = mode || DEFAULT_MODE;
30+
return composerMode === 'ThreatsOnly' || composerMode === 'EditorOnly' ? (
31+
<Standalone composeMode={composerMode} />
32+
) : (
33+
<Full />
34+
);
3035
};
3136

3237
export default App;

packages/threat-composer/src/contexts/ContextAggregator/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export interface ContextAggregatorProps extends ViewNavigationEvent {
3131
const ContextAggregator: FC<PropsWithChildren<ContextAggregatorProps>> = ({
3232
children,
3333
onWorkspaceChanged,
34-
composerMode = 'ThreatsOnly',
34+
composerMode = 'Full',
3535
onPreview,
3636
onPreviewClose,
3737
onImported,

packages/threat-composer/src/contexts/GlobalSetupContext/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface GlobalSetupContextApi {
3030

3131
const initialState: GlobalSetupContextApi = {
3232
hasVisitBefore: false,
33-
composerMode: 'ThreatsOnly',
33+
composerMode: 'Full',
3434
showInfoModal: () => { },
3535
showImportUpdate: 0,
3636
};

packages/threat-composer/src/contexts/GlobalSetupContext/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export interface GlobalSetupContextProviderProps {
3333

3434
const GlobalSetupContextProvider: FC<PropsWithChildren<GlobalSetupContextProviderProps>> = ({
3535
children,
36-
composerMode = 'ThreatsOnly',
36+
composerMode = 'Full',
3737
onPreview,
3838
onPreviewClose,
3939
onImported,

0 commit comments

Comments
 (0)