Skip to content

Commit

Permalink
Fixed hundred of bugs, improved performance (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
idumitru-cds authored Nov 28, 2023
1 parent e17146d commit a8c9080
Show file tree
Hide file tree
Showing 40 changed files with 4,261 additions and 35,682 deletions.
33,875 changes: 0 additions & 33,875 deletions package-lock.json

This file was deleted.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.21.4",
"@cloudscape-design/jest-preset": "*",
"@projectstorm/react-canvas-core": "^7.0.1",
"@projectstorm/react-diagrams": "^7.0.2",
"@projectstorm/react-canvas-core": "^7.0.2",
"@projectstorm/react-diagrams": "^7.1.2",
"@testing-library/jest-dom": "*",
"@testing-library/react": "*",
"@testing-library/user-event": "*",
Expand Down Expand Up @@ -59,8 +59,8 @@
"@cloudscape-design/global-styles": "*",
"@emotion/react": "*",
"@emotion/styled": "^11.11.0",
"@projectstorm/react-canvas-core": "^7.0.1",
"@projectstorm/react-diagrams": "^7.0.2",
"@projectstorm/react-canvas-core": "^7.0.2",
"@projectstorm/react-diagrams": "^7.1.2",
"browser-image-compression": "*",
"d3": "^7",
"eslint-plugin-header": "^3.1.1",
Expand Down
8 changes: 6 additions & 2 deletions src/components/architecture/ArchitectureInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ const ArchitectureInfo: FC<EditableComponentBaseProps> = (props) => {
headerTitle='Architecture'
diagramTitle='Architecture Diagram'
entity={architectureInfo}
onConfirm={(diagram) => setArchitectureInfo(diagram)}
onConfirm={
(diagram) => {
console.log(diagram);
setArchitectureInfo(diagram);
}
}
validateData={ArchitectureInfoSchema.shape.description.safeParse}
/>;
};

export default ArchitectureInfo;
17 changes: 15 additions & 2 deletions src/components/diagram/DiagramInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,32 @@
import { FC } from 'react';
import { useDiagramInfoContext } from '../../../contexts/DiagramContext/context';
import { EditableComponentBaseProps } from '../../../customTypes';
import DiagramCanvas from '../../generic/DiagramCanvas';

//import DiagramCanvas from '../../generic/DiagramCanvas';
import DFDCanvasWidget from '../../generic/CanvasWidget';

const DiagramInfo: FC<EditableComponentBaseProps> = (props) => {
//return <div><h2>DIAGRAMINFO</h2></div>;
const { diagramInfo, setDiagramInfo } = useDiagramInfoContext();
/*
return <DiagramCanvas
{...props}
headerTitle='Dataflow Diagram'
diagramTitle='Dataflow Diagram'
entity={diagramInfo}
onConfirm={(diagram) => setDiagramInfo(diagram)}
/>;
*/
return <DFDCanvasWidget
{...props}
headerTitle={'Dataflow diagram'}
diagramTitle={'Dataflow diagram'}
entity={diagramInfo}
onConfirm={
(diagram) => {
setDiagramInfo(diagram);
}
}
/>;

};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/** *******************************************************************************************************************
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 { DefaultLinkFactory } from '@projectstorm/react-diagrams';
import StraightArrowLinkModel from './StraightArrowLinkModel';
import { StraightArrowLinkWidget } from './StraightArrowLinkWidget';
import { OptionDefinition } from '@cloudscape-design/components/internal/components/option/interfaces';

export class StraightArrowLinkFactory extends DefaultLinkFactory {
public filterStatementsCallback?: (
strideFilter: string,
objectId: string,
objectType: string,
objectName?: string,
objectDescription?: string,
objectOutOfScope?: boolean,
objectOutOfScopeReason?: string,
objectTags?: string[],
dataFeatures?: ReadonlyArray<OptionDefinition>,
techFeatures?: ReadonlyArray<OptionDefinition>,
securityFeatures?: ReadonlyArray<OptionDefinition>,
threats?: {id: string}[]) => void;

constructor(props) {
super('straight-arrow');
this.filterStatementsCallback = props;
}

generateModel(): StraightArrowLinkModel {
return new StraightArrowLinkModel({ filterStatementsCallback: this.filterStatementsCallback });
}

generateReactWidget(event): JSX.Element {
return (
<StraightArrowLinkWidget link={event.model} diagramEngine={this.engine} />
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/** *******************************************************************************************************************
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 { OptionDefinition } from '@cloudscape-design/components/internal/components/option/interfaces';
import { DefaultLinkModel } from '@projectstorm/react-diagrams';

export default class StraightArrowLinkModel extends DefaultLinkModel {
filterSTRIDE: string;
name: string | undefined;
description: string | undefined;
outOfScope?: boolean;
outOfScopeReason?: string;
tags?: string[];
dataFeatures?: ReadonlyArray<OptionDefinition>;
techFeatures?: ReadonlyArray<OptionDefinition>;
securityFeatures?: ReadonlyArray<OptionDefinition>;
threats?: {id: string}[];

public filterStatementsCallback?: (
strideFilter: string,
objectId: string,
objectType: string,
objectName?: string,
objectDescription?: string,
objectOutOfScope?: boolean,
objectOutOfScopeReason?: string,
objectTags?: string[],
dataFeatures?: ReadonlyArray<OptionDefinition>,
techFeatures?: ReadonlyArray<OptionDefinition>,
securityFeatures?: ReadonlyArray<OptionDefinition>,
threats?: {id: string}[]) => void;

constructor(props: any = {}) {
super({
...props,
type: 'straight-arrow',
width: 3,
},
);
this.registerListener({ selectionChanged: this.handleSelectionChanged });
this.filterStatementsCallback = props.filterStatementsCallback;
this.filterSTRIDE = 'T,I,D';
this.name = props.name;
this.description = props.description;
this.outOfScope = props.outOfScope;
this.outOfScopeReason = props.outOfScopeReason;
this.tags = props.tags;
this.dataFeatures = props.dataFeatures;
this.techFeatures = props.techFeatures;
this.securityFeatures = props.securityFeatures;
}

serialize() {
return {
...super.serialize(),
name: this.name,
description: this.description,
outOfScope: this.outOfScope,
outOfScopeReason: this.outOfScopeReason,
tags: this.tags,
dataFeatures: this.dataFeatures,
techFeatures: this.techFeatures,
securityFeatures: this.securityFeatures,
threats: this.threats,
};
};

deserialize(event:any): void {
super.deserialize(event);
this.name = event.data.name;
this.description = event.data.description;
this.outOfScope = event.data.outOfScope;
this.outOfScopeReason = event.data.outOfScopeReason;
this.tags = event.data.tags;
this.dataFeatures = event.data.dataFeatures;
this.techFeatures = event.data.techFeatures;
this.securityFeatures = event.data.securityFeatures;
this.threats = event.data.threats;
};

handleSelectionChanged = (event) => {
if (this.filterStatementsCallback) {
if (event.isSelected) {
this.filterStatementsCallback(
this.filterSTRIDE,
this.getID(),
'straight-arrow',
this.name || '',
this.description || '',
this.outOfScope || false,
this.outOfScopeReason || '',
this.tags || [],
this.dataFeatures || [],
this.techFeatures || [],
this.securityFeatures || [],
this.threats || [],
);
} else {
this.filterStatementsCallback(
'',
'',
'straight-arrow',
'',
'',
false,
'',
[],
[],
[],
[],
[],
);
}
};
};
}
Loading

0 comments on commit a8c9080

Please sign in to comment.