Skip to content

Commit

Permalink
feat: Full mode by default (#31)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Jessie Wei <[email protected]>
  • Loading branch information
dboyd13 and jessieweiyi authored Aug 28, 2023
1 parent f55916b commit 8a72e41
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 54 deletions.
78 changes: 46 additions & 32 deletions README.md

Large diffs are not rendered by default.

Binary file removed docs/screenshot-threatsonly-mode.png
Binary file not shown.
Binary file added docs/threat-composer.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 38 additions & 18 deletions packages/threat-composer-app/src/components/Notifications/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,50 @@
import Flashbar, { FlashbarProps } from '@cloudscape-design/components/flashbar';
import Link from '@cloudscape-design/components/link';
import * as awsui from '@cloudscape-design/design-tokens';
import { FC, useState } from 'react';
import { FC, useEffect, useState } from 'react';

export interface NotificationsProps {
addPadding?: boolean;
}

const Notifications: FC<NotificationsProps> = ({ addPadding }) => {
const [items, setItems] = useState<FlashbarProps.MessageDefinition[]>([
{
type: 'info',
dismissible: true,
dismissLabel: 'Dismiss message',
onDismiss: () => setItems([]),
content: (
<>
This GitHub Page is provided for demonstration purposes only. Refer to {' '}
<Link color="inverted" href="https://github.com/awslabs/threat-composer" external={true}>
threat-composer GitHub Repo
</Link> for self-hosting deployment instructions.
</>
),
id: 'message_1',
},
]);
const [items, setItems] = useState<FlashbarProps.MessageDefinition[]>([]);

useEffect(() => {
setItems([
{
type: 'info',
dismissible: true,
dismissLabel: 'Dismiss message',
onDismiss: () => setItems(prevItems => prevItems.filter((x) => x.id !== 'message_1')),
content: (
<>
The 'Full' mode is now the default. To view the 'Threats Only' mode navigate the {' '}
<Link color="inverted" href="https://awslabs.github.io/threat-composer?mode=ThreatsOnly" external={false}>
ThreatsOnly
</Link> URL, and bookmark or future reference.
</>
),
id: 'message_1',
},
{
type: 'info',
dismissible: true,
dismissLabel: 'Dismiss message',
onDismiss: () => setItems(prevItems => prevItems.filter((x) => x.id !== 'message_2')),
content: (
<>
This GitHub Page is provided for demonstration purposes only. Refer to {' '}
<Link color="inverted" href="https://github.com/awslabs/threat-composer" external={true}>
threat-composer GitHub Repo
</Link> for self-hosting deployment instructions.
</>
),
id: 'message_2',
},
]);
}, []);

return items && items.length > 0 ? (<div style={addPadding ? {
padding: awsui.spaceScaledL,
backgroundColor: awsui.colorBackgroundHomeHeader,
Expand Down
7 changes: 6 additions & 1 deletion packages/threat-composer-app/src/containers/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ const DEFAULT_MODE = process.env.REACT_APP_DEFAULT_MODE;
const App: FC = () => {
const [searchParams] = useSearchParams();
const mode = searchParams.get('mode');
return mode === 'Full' || DEFAULT_MODE === 'Full' ? <Full/> : <Standalone composeMode={mode} />;
const composerMode = mode || DEFAULT_MODE;
return composerMode === 'ThreatsOnly' || composerMode === 'EditorOnly' ? (
<Standalone composeMode={composerMode} />
) : (
<Full />
);
};

export default App;
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface ContextAggregatorProps extends ViewNavigationEvent {
const ContextAggregator: FC<PropsWithChildren<ContextAggregatorProps>> = ({
children,
onWorkspaceChanged,
composerMode = 'ThreatsOnly',
composerMode = 'Full',
onPreview,
onPreviewClose,
onImported,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface GlobalSetupContextApi {

const initialState: GlobalSetupContextApi = {
hasVisitBefore: false,
composerMode: 'ThreatsOnly',
composerMode: 'Full',
showInfoModal: () => { },
showImportUpdate: 0,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface GlobalSetupContextProviderProps {

const GlobalSetupContextProvider: FC<PropsWithChildren<GlobalSetupContextProviderProps>> = ({
children,
composerMode = 'ThreatsOnly',
composerMode = 'Full',
onPreview,
onPreviewClose,
onImported,
Expand Down

0 comments on commit 8a72e41

Please sign in to comment.