Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Full mode by default #31

Merged
merged 7 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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