Skip to content

Commit 5e0ff31

Browse files
authored
fix: Fix an issue where the add new statement button is not working (#33)
1 parent 8a72e41 commit 5e0ff31

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const DEFAULT_MODE = process.env.REACT_APP_DEFAULT_MODE;
2626
const App: FC = () => {
2727
const [searchParams] = useSearchParams();
2828
const mode = searchParams.get('mode');
29-
const composerMode = mode || DEFAULT_MODE;
29+
const composerMode = mode || DEFAULT_MODE || 'Full';
3030
return composerMode === 'ThreatsOnly' || composerMode === 'EditorOnly' ? (
3131
<Standalone composeMode={composerMode} />
3232
) : (

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@
1414
limitations under the License.
1515
******************************************************************************************************************** */
1616
import { FC, useCallback, useState } from 'react';
17-
import { useSearchParams } from 'react-router-dom';
1817
import { ThreatModel, ThreatModelView } from 'threat-composer';
1918

2019
const ThreatModelReport: FC = () => {
21-
const [searchParms] = useSearchParams();
2220
const [isPreview] = useState(() => {
2321
const urlParams = new URLSearchParams(window.location.search);
2422
const previewParams = urlParams.get('preview');
@@ -48,7 +46,7 @@ const ThreatModelReport: FC = () => {
4846
}, []);
4947

5048
return (data
51-
? (<ThreatModelView composerMode={searchParms.get('mode') || ''} data={data} onPrintButtonClick={isPreview ? undefined : handlePrintButtonClick} />)
49+
? (<ThreatModelView composerMode='Full' data={data} onPrintButtonClick={isPreview ? undefined : handlePrintButtonClick} />)
5250
: (<ThreatModel
5351
onPrintButtonClick={isPreview ? undefined : handlePrintButtonClick}
5452
/>));

packages/threat-composer-app/src/utils/generateUrl/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ import { generatePath } from 'react-router-dom';
1717

1818
const ROUTE_BASE_PATH=process.env.REACT_APP_ROUTE_BASE_PATH || '';
1919

20-
const generateUrl = (path: string, searchParms: URLSearchParams, workspaceId: string, threatId?: string) => {
21-
const mode = searchParms.get('mode');
22-
if (mode) {
20+
const generateUrl = (path: string, searchParams: URLSearchParams, workspaceId: string, threatId?: string) => {
21+
if (Array.from(searchParams.entries()).length > 0) {
2322
return `${ROUTE_BASE_PATH}${generatePath(path, {
2423
workspaceId,
2524
threatId,
26-
})}?mode=${mode}`;
25+
})}?${searchParams.toString()}`;
2726
}
2827

2928
return `${ROUTE_BASE_PATH}${generatePath(path, {
30-
workspaceId: workspaceId,
29+
workspaceId,
30+
threatId,
3131
})}`;
3232
};
3333

0 commit comments

Comments
 (0)