Skip to content

Commit

Permalink
fix: Fix an issue where the add new statement button is not working (#33
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jessieweiyi authored Aug 28, 2023
1 parent 8a72e41 commit 5e0ff31
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 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,7 @@ const DEFAULT_MODE = process.env.REACT_APP_DEFAULT_MODE;
const App: FC = () => {
const [searchParams] = useSearchParams();
const mode = searchParams.get('mode');
const composerMode = mode || DEFAULT_MODE;
const composerMode = mode || DEFAULT_MODE || 'Full';
return composerMode === 'ThreatsOnly' || composerMode === 'EditorOnly' ? (
<Standalone composeMode={composerMode} />
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
limitations under the License.
******************************************************************************************************************** */
import { FC, useCallback, useState } from 'react';
import { useSearchParams } from 'react-router-dom';
import { ThreatModel, ThreatModelView } from 'threat-composer';

const ThreatModelReport: FC = () => {
const [searchParms] = useSearchParams();
const [isPreview] = useState(() => {
const urlParams = new URLSearchParams(window.location.search);
const previewParams = urlParams.get('preview');
Expand Down Expand Up @@ -48,7 +46,7 @@ const ThreatModelReport: FC = () => {
}, []);

return (data
? (<ThreatModelView composerMode={searchParms.get('mode') || ''} data={data} onPrintButtonClick={isPreview ? undefined : handlePrintButtonClick} />)
? (<ThreatModelView composerMode='Full' data={data} onPrintButtonClick={isPreview ? undefined : handlePrintButtonClick} />)
: (<ThreatModel
onPrintButtonClick={isPreview ? undefined : handlePrintButtonClick}
/>));
Expand Down
10 changes: 5 additions & 5 deletions packages/threat-composer-app/src/utils/generateUrl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ import { generatePath } from 'react-router-dom';

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

const generateUrl = (path: string, searchParms: URLSearchParams, workspaceId: string, threatId?: string) => {
const mode = searchParms.get('mode');
if (mode) {
const generateUrl = (path: string, searchParams: URLSearchParams, workspaceId: string, threatId?: string) => {
if (Array.from(searchParams.entries()).length > 0) {
return `${ROUTE_BASE_PATH}${generatePath(path, {
workspaceId,
threatId,
})}?mode=${mode}`;
})}?${searchParams.toString()}`;
}

return `${ROUTE_BASE_PATH}${generatePath(path, {
workspaceId: workspaceId,
workspaceId,
threatId,
})}`;
};

Expand Down

0 comments on commit 5e0ff31

Please sign in to comment.