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

Add scenario duplication functionality, add copy icon #182

Merged
merged 3 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
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 @@ -83,12 +83,22 @@
.Runtime__scenario-delete {
display: inline-block;
vertical-align: top;
margin-right: 31px;
width: 24px;
height: 24px;
background-image: url('../../trash.png');
background-repeat: no-repeat;
}

.Runtime__scenario-clone {
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
Loading