Skip to content

Commit

Permalink
Add scenario duplication functionality, add copy icon
Browse files Browse the repository at this point in the history
  • Loading branch information
e-halinen committed Jun 15, 2023
1 parent 48a4606 commit 97f75ae
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/renderer/components/HelmetProject/HelmetProject.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ const HelmetProject = ({
}
};

const duplicateScenario = (scenario) => {
var duplicatedScenario = structuredClone(scenario);
//Change ID and rename the scenario to avoid conflicts.
duplicatedScenario.id = uuidv4();
duplicatedScenario.name += `(${duplicatedScenario.id.split('-')[0]})`;
setScenarios(scenarios.concat(duplicatedScenario));
configStores.current[duplicatedScenario.id] = new Store({cwd: projectPath, name: duplicatedScenario.name});
configStores.current[duplicatedScenario.id].set(duplicatedScenario);
}

const _runAllActiveScenarios = (activeScenarioIDs) => {
const scenariosToRun = scenarios.filter((s) => activeScenarioIDs.includes(s.id)).sort((a, b) => scenarioIDsToRun.indexOf(a.id) - scenarioIDsToRun.indexOf(b.id));

Expand Down Expand Up @@ -349,6 +359,7 @@ const HelmetProject = ({
statusIterationsTotal={statusIterationsTotal}
statusIterationsCompleted={statusIterationsCompleted}
statusReadyScenariosLogfiles={statusReadyScenariosLogfiles}
duplicateScenario={duplicateScenario}
/>
<CostBenefitAnalysis
resultsPath={resultsPath}
Expand Down
14 changes: 12 additions & 2 deletions src/renderer/components/HelmetProject/Runtime/Runtime.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

.Runtime__scenarios {
max-height: 160px;
width: 580px;
width: 700px;
overflow-y: auto;
}

Expand Down Expand Up @@ -89,6 +89,16 @@
background-repeat: no-repeat;
}

.Runtime__scenario-clone {
margin-left: 15px;
margin-bottom: -5px;
display: inline-block;
vertical-align: top;
width: 24px;
height: 24px;
color: #007AC9;
}

.Runtime__scenarios-footer {
padding-top: 22px;
}
Expand Down Expand Up @@ -127,4 +137,4 @@
}

.Runtime__start-stop-btn {
}
}
8 changes: 7 additions & 1 deletion src/renderer/components/HelmetProject/Runtime/Runtime.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const Runtime = ({
reloadScenarios,
handleClickScenarioToActive, handleClickNewScenario,
statusIterationsTotal, statusIterationsCompleted, statusReadyScenariosLogfiles,
handleClickStartStop,
handleClickStartStop, duplicateScenario
}) => {
return (
<div className="Runtime">
Expand Down Expand Up @@ -58,6 +58,12 @@ const Runtime = ({
<div className={"Runtime__scenario-delete"}
onClick={(e) => runningScenarioID ? undefined : deleteScenario(s)}
></div>
&nbsp;
<div className={"Runtime__scenario-clone"}
onClick={(e) => duplicateScenario(s)}
>
<CopyIcon/>
</div>
</div>
)
})}
Expand Down
9 changes: 9 additions & 0 deletions src/renderer/icons/CopyIcon.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';

const CopyIcon = () => {
return (
<svg width="19" height="22" viewBox="0 0 19 22" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14 0H2C0.9 0 0 0.9 0 2V16H2V2H14V0ZM17 4H6C4.9 4 4 4.9 4 6V20C4 21.1 4.9 22 6 22H17C18.1 22 19 21.1 19 20V6C19 4.9 18.1 4 17 4ZM17 20H6V6H17V20Z" fill="#007AC9"/>
</svg>
)
}
1 change: 1 addition & 0 deletions src/renderer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
window.useMockAssignment = function() {aliasIpcRenderer.send('message-from-ui-to-disable-emme')};
window.useEmmeAssignment = function () {aliasIpcRenderer.send('message-from-ui-to-enable-emme')};
</script>
<script type="text/babel" src="./icons/CopyIcon.jsx"></script>
</head>
<body>

Expand Down

0 comments on commit 97f75ae

Please sign in to comment.