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

fix: Fix workspace urls to allow direct navigations to the workspace relative pages #120

Merged
merged 2 commits into from
Jun 18, 2024
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
4 changes: 4 additions & 0 deletions .projen/tasks.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/threat-composer-app/.projen/deps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/threat-composer-app/.projen/tasks.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/threat-composer-app/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/** *******************************************************************************************************************
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License").
You may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************************************************** */
import { MarkdownEditor, MarkdownEditorProps } from '@aws/threat-composer';
import { FC, useState } from 'react';
import { unstable_usePrompt } from 'react-router-dom';

const MarkdownEditorWithPrompt: FC<MarkdownEditorProps> = ({
value, ...props
}) => {
const [previousValue] = useState(value);

unstable_usePrompt({
message: 'You have unsaved changes, proceed anyway?',
when: ({ currentLocation, nextLocation }) =>
previousValue !== value &&
currentLocation.pathname !== nextLocation.pathname,
});

return <MarkdownEditor value={value} {...props} />;
};

export default MarkdownEditorWithPrompt;
28 changes: 28 additions & 0 deletions packages/threat-composer-app/src/config/appMode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/** *******************************************************************************************************************
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License").
You may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************************************************** */

import {
APP_MODE_BROWSER_EXTENSION,
APP_MODE_IDE_EXTENSION,
} from '@aws/threat-composer';

const appModeEnv = process.env.REACT_APP_APP_MODE;

export const appMode = appModeEnv === APP_MODE_BROWSER_EXTENSION ?
APP_MODE_BROWSER_EXTENSION :
(appModeEnv === APP_MODE_IDE_EXTENSION ?
APP_MODE_IDE_EXTENSION : undefined);

46 changes: 32 additions & 14 deletions packages/threat-composer-app/src/config/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,35 @@
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************************************************** */
export const ROUTE_WORKSPACE_HOME = '/workspaces/:workspaceId/dashboard';
export const ROUTE_THREAT_LIST = '/workspaces/:workspaceId/threats';
export const ROUTE_THREAT_EDITOR = '/workspaces/:workspaceId/threats/:threatId';
export const ROUTE_MITIGATION_LIST = '/workspaces/:workspaceId/mitigations';
export const ROUTE_ASSUMPTION_LIST = '/workspaces/:workspaceId/assumptions';
export const ROUTE_APPLICATION_INFO = '/workspaces/:workspaceId/application';
export const ROUTE_ARCHITECTURE_INFO = '/workspaces/:workspaceId/architecture';
export const ROUTE_DATAFLOW_INFO = '/workspaces/:workspaceId/dataflow';
export const ROUTE_VIEW_THREAT_MODEL = '/workspaces/:workspaceId/threatModel';
export const ROUTE_THREAT_PACKS = '/workspaces/:workspaceId/threatPacks';
export const ROUTE_THREAT_PACK = '/workspaces/:workspaceId/threatPacks/:threatPackId';
export const ROUTE_THREAT_PACK_THREAT = '/workspaces/:workspaceId/threatPacks/:threatPackId/:threatId';
export const ROUTE_MITIGATION_PACKS = '/workspaces/:workspaceId/mitigationPacks';
export const ROUTE_MITIGATION_PACK = '/workspaces/:workspaceId/mitigationPacks/:mitigationPackId';
export const ROUTE_WORKSPACE_PATH = 'workspaces/:workspaceId';
export const ROUTE_WORKSPACE_HOME_PATH = 'dashboard';
export const ROUTE_WORKSPACE_HOME = `/${ROUTE_WORKSPACE_PATH}/${ROUTE_WORKSPACE_HOME_PATH}`;
export const ROUTE_THREAT_LIST_PATH = 'threats';
export const ROUTE_THREAT_LIST = `/${ROUTE_WORKSPACE_PATH}/${ROUTE_THREAT_LIST_PATH}`;
export const ROUTE_THREAT_EDITOR_PATH = 'threats/:threatId';
export const ROUTE_THREAT_EDITOR = `/${ROUTE_WORKSPACE_PATH}/${ROUTE_THREAT_EDITOR_PATH}`;
export const ROUTE_MITIGATION_LIST_PATH = 'mitigations';
export const ROUTE_MITIGATION_LIST = `/${ROUTE_WORKSPACE_PATH}/${ROUTE_MITIGATION_LIST_PATH}`;
export const ROUTE_ASSUMPTION_LIST_PATH = 'assumptions';
export const ROUTE_ASSUMPTION_LIST = `/${ROUTE_WORKSPACE_PATH}/${ROUTE_ASSUMPTION_LIST_PATH}`;
export const ROUTE_APPLICATION_INFO_PATH = 'application';
export const ROUTE_APPLICATION_INFO = `/${ROUTE_WORKSPACE_PATH}/${ROUTE_APPLICATION_INFO_PATH}`;
export const ROUTE_ARCHITECTURE_INFO_PATH = 'architecture';
export const ROUTE_ARCHITECTURE_INFO = `/${ROUTE_WORKSPACE_PATH}/${ROUTE_ARCHITECTURE_INFO_PATH}`;
export const ROUTE_DATAFLOW_INFO_PATH = 'dataflow';
export const ROUTE_DATAFLOW_INFO = `/${ROUTE_WORKSPACE_PATH}/${ROUTE_DATAFLOW_INFO_PATH}`;
export const ROUTE_VIEW_THREAT_MODEL_PATH = 'threatModel';
export const ROUTE_VIEW_THREAT_MODEL = `/${ROUTE_WORKSPACE_PATH}/${ROUTE_VIEW_THREAT_MODEL_PATH}`;
export const ROUTE_THREAT_PACKS_PATH = 'threatPacks';
export const ROUTE_THREAT_PACKS = `/${ROUTE_WORKSPACE_PATH}/${ROUTE_THREAT_PACKS_PATH}`;
export const ROUTE_THREAT_PACK_PATH = 'threatPacks/:threatPackId';
export const ROUTE_THREAT_PACK = `/${ROUTE_WORKSPACE_PATH}/${ROUTE_THREAT_PACK_PATH}`;
export const ROUTE_THREAT_PACK_THREAT_PATH = 'threatPacks/:threatPackId/:threatId';
export const ROUTE_THREAT_PACK_THREAT = `/${ROUTE_WORKSPACE_PATH}/${ROUTE_THREAT_PACK_THREAT_PATH}`;
export const ROUTE_MITIGATION_PACKS_PATH = 'mitigationPacks';
export const ROUTE_MITIGATION_PACKS = `/${ROUTE_WORKSPACE_PATH}/${ROUTE_MITIGATION_PACKS_PATH}`;
export const ROUTE_MITIGATION_PACK_PATH = 'mitigationPacks/:mitigationPackId';
export const ROUTE_MITIGATION_PACK = `/${ROUTE_WORKSPACE_PATH}/${ROUTE_MITIGATION_PACK_PATH}`;
export const ROUTE_PREVIEW_PATH = 'preview/:dataKey';
export const ROUTE_PREVIEW = `/${ROUTE_PREVIEW_PATH}`;
export const ROUTE_WORKSPACE_DEFAULT = 'workspaces/default';
Loading
Loading