Skip to content

Commit

Permalink
Fixed bug with imported reports having multiple entries for requireme…
Browse files Browse the repository at this point in the history
…nts under certain conditions.
  • Loading branch information
andreaskatis committed Oct 6, 2022
1 parent 49c57fb commit 6f632c9
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 26 deletions.
2 changes: 2 additions & 0 deletions fret-electron/app/components/AnalysisReportContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ class AnalysisReportContent extends React.Component {
existingProjectNames={[selectedProject]}
connectedComponent={selected.compositional.connectedComponents[connectedComponentIndex]}
importedRequirements={selected.requirements}
selectedRequirements={selected.selectedReqs}
/>
</div>
</DiagnosisProvider>
Expand All @@ -256,6 +257,7 @@ class AnalysisReportContent extends React.Component {
existingProjectNames={[selectedProject]}
connectedComponent={{}}
importedRequirements={selected.requirements}
selectedRequirements={selected.selectedReqs}
/>
</div>
</DiagnosisProvider>
Expand Down
42 changes: 20 additions & 22 deletions fret-electron/app/components/DiagnosisRequirementsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ function ccStableSort(array, conflictReqs, selectedReqs, connectedComponent, cmp
if (conflictReqs.length === 0) {
const ccData = array.filter(el => connectedComponent.requirements.includes(el.reqid));
const notSelectedData = array.filter(el => !selectedReqs.includes(el.reqid));

const remainingData = array.filter(el => (!connectedComponent.requirements.includes(el.reqid) && !notSelectedData.map(el => el.reqid).includes(el.reqid)));

const sortedRemaining = remainingData.map((el, index) => [el, index]);
Expand Down Expand Up @@ -314,7 +313,7 @@ class DiagnosisRequirementsTableHead extends React.Component {
return (
<TableHead>
<TableRow>
{(importedRequirements.length === 0) &&
{importedRequirements.length === 0 &&
<TableCell padding="checkbox">
<Checkbox
indeterminate={numSelected > 0 && numSelected < rowCount}
Expand Down Expand Up @@ -420,15 +419,17 @@ class DiagnosisRequirementsTable extends React.Component {
}

componentDidMount() {
const { importedRequirements } = this.props;
const { importedRequirements, selectedRequirements } = this.props;
this.mounted = true;
if (importedRequirements.length === 0) {
this.synchStateWithDB();
} else {
this.setState({
data: importedRequirements.map(r => {
return createData(r._id, r._rev, r.reqid, r.fulltext, r.project);
}).sort((a, b) => {return a.reqid > b.reqid})
}).sort((a, b) => {return a.reqid > b.reqid}),
selected: [].concat(selectedRequirements),
tempSelected: [].concat(selectedRequirements)
});
}
}
Expand All @@ -444,13 +445,13 @@ class DiagnosisRequirementsTable extends React.Component {

componentDidUpdate(prevProps) {
const { connectedComponent, importedRequirements, selectedRequirements } = this.props;
if (connectedComponent !== prevProps.connectedComponent) {

if (connectedComponent && (connectedComponent !== prevProps.connectedComponent)) {
if (importedRequirements.length === 0) {
const {setMessage} = this.context;
setMessage({reqs : '', color : ''})
let newSelectedReqs = selectedRequirements;
this.setState({selected: [].concat(newSelectedReqs)})
}
this.setState({selected: [].concat(selectedRequirements)})
}
}
}

Expand Down Expand Up @@ -602,7 +603,7 @@ class DiagnosisRequirementsTable extends React.Component {
const isSelected = this.isSelected(n.reqid);
const label = n.reqid ? n.reqid.replace(/-/g,'') : 'NONE'
var isInConflict = (reqs.length !== 0 && reqs.includes(label)) ? true : false;
const isInConflictOrCC = (isInConflict || connectedComponent.requirements.includes(n.reqid));
const isInConflictOrCC = (isInConflict || connectedComponent.requirements.includes(n.reqid));
return (
<TableRow
key={n.rowid}
Expand All @@ -611,13 +612,11 @@ class DiagnosisRequirementsTable extends React.Component {
borderStyle: isInConflict ? 'solid' : 'initial',
borderColor: isInConflict ? color : 'initial'}}
classes={{selected: (isSelected && isInConflictOrCC) ? classes.tableRowSelected : 'initial'}}
onClick={event => { this.handleClick(event, n.reqid)}}
onClick={event => { importedRequirements.length === 0 ? this.handleClick(event, n.reqid) : null}}
>
{(importedRequirements.length === 0) &&
{true &&
<TableCell padding="checkbox">
<Checkbox
checked={isSelected}
/>
<Checkbox checked={isSelected}/>
</TableCell>
}
<TableCell id={"qa_diagReqTbl_tc_body_id_"+label}>
Expand All @@ -640,23 +639,22 @@ class DiagnosisRequirementsTable extends React.Component {
const isSelected = this.isSelected(n.reqid);
const label = n.reqid ? n.reqid.replace(/-/g,'') : 'NONE'
var isInConflict = (reqs.length !== 0 && reqs.includes(label)) ? true : false;
var isAssumption = n.reqid.includes('assumption')
const isInConflictOrAssumptions = (isInConflict || reqs.length === 0 || isAssumption);
//var isAssumption = n.reqid.includes('assumption')
//const isInConflictOrAssumptions = (isInConflict || reqs.length === 0 || isAssumption);
const isInConflictOrSelected = (isInConflict || isSelected);
return (
<TableRow
key={n.rowid}
style={{
opacity : isInConflictOrAssumptions ? 1 : .6,
opacity : isInConflictOrSelected ? 1 : .6,
borderStyle: isInConflict ? 'solid' : 'initial',
borderColor: isInConflict ? color : 'initial'}}
classes={{selected: classes.tableRowSelected}}
onClick={event => this.handleClick(event, n.reqid)}
onClick={event => (importedRequirements.length === 0 ? this.handleClick(event, n.reqid) : null)}
>
{(importedRequirements.length === 0) &&
{true &&
<TableCell padding="checkbox">
<Checkbox
checked={isSelected}
/>
<Checkbox checked={isSelected}/>
</TableCell>
}
<TableCell id={"qa_diagReqTbl_tc_body_id_"+label}>
Expand Down
7 changes: 6 additions & 1 deletion fret-electron/app/components/RealizabilityContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,12 @@ class RealizabilityContent extends React.Component {

projectReport.systemComponents = [].concat(projectReport.systemComponents.map(obj => {
if (obj.name === component.component_name) {
return {...obj, comments: '', monolithic: {result: 'UNCHECKED', time: '', diagnosisStatus: '', diagnosisReport: '', error: ''}, compositional: {result: 'UNCHECKED', connectedComponents: ccArray, error: ''}, requirements: fretResult.docs};
return {...obj,
comments: '',
monolithic: {result: 'UNCHECKED', time: '', diagnosisStatus: '', diagnosisReport: '', error: ''},
compositional: {result: 'UNCHECKED', connectedComponents: ccArray, error: ''},
requirements: fretResult.docs,
selectedReqs: (selectedReqs.length === 0 ? fretResult.docs.filter(doc => doc.semantics.component_name === component.component_name).map(doc => doc.reqid) : selectedReqs)};
}
return obj;
}))
Expand Down
3 changes: 2 additions & 1 deletion fret-electron/app/components/RealizabilityView.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ class RealizabilityView extends React.Component {
}
}

handleLoadClick = (event) => {
handleLoadClick = (event) => {
event.stopPropagation();
var homeDir = app.getPath('home');
var filepaths = dialog.showOpenDialogSync({
defaultPath: homeDir,
Expand Down
3 changes: 1 addition & 2 deletions fret-electron/app/components/SaveRealizabilityReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@ class SaveRealizabilityReport extends React.Component {

saveRealizabilityResults = async (event) => {
event.stopPropagation();
const {projectReport} = this.props;
const {projectReport, selectedRequirements} = this.props;
const homeDir = app.getPath('home');

projectReport.systemComponents = projectReport.systemComponents.filter(sc => sc.monolithic);

// const self = this;
var filePathObject = await dialog.showSaveDialog({
defaultPath : homeDir,
Expand Down

0 comments on commit 6f632c9

Please sign in to comment.