configurator: fix displayed scenario path

fix displayed scenario path

Tracked-On: #6691
Signed-off-by: Weiyi Feng <weiyix.feng@intel.com>
This commit is contained in:
Weiyi Feng 2022-03-31 21:57:59 +08:00 committed by acrnsi-robot
parent 34bfaa71f6
commit 578a482626
1 changed files with 17 additions and 9 deletions

View File

@ -66,15 +66,12 @@ export default class CreateNewOrImportAnExistingScenario extends Component {
let {configurator} = this.context
return configurator.programLayer.loadScenario(this.scenarioXMLSelect.current.value)
.then(() => {
let printPath = configurator.WorkingFolder;
if (_.endsWith(configurator.WorkingFolder, "/") || _.endsWith(configurator.WorkingFolder, "\\")) {
printPath = printPath + 'scenario.xml'
} else {
printPath = printPath + (configurator.WorkingFolder[1] === ":" ? "\\" : '/') + 'scenario.xml'
}
this.setState({selected: printPath})
this.setState({selected: this.getScenarioPath()})
}).then(() => {
document.querySelectorAll(".accordion-button")[2].click()
let tabButton = document.querySelectorAll(".accordion-button")[2];
if (tabButton.className.indexOf('collapsed') >= 0) {
tabButton.click()
}
})
.catch((reason) => {
console.log(reason)
@ -82,6 +79,17 @@ export default class CreateNewOrImportAnExistingScenario extends Component {
})
};
getScenarioPath = () => {
let {configurator} = this.context
let printPath = configurator.WorkingFolder;
if (_.endsWith("/", configurator.WorkingFolder) || _.endsWith("\\", configurator.WorkingFolder)) {
printPath = printPath + 'scenario.xml'
} else {
printPath = printPath + (configurator.WorkingFolder[1] === ":" ? "\\" : '/') + 'scenario.xml'
}
return printPath;
}
render = () => {
let {configurator} = this.context
let scenarioHistorySelect = this.state.scenarioConfigFiles.map((optionValue, index) => {
@ -101,7 +109,7 @@ export default class CreateNewOrImportAnExistingScenario extends Component {
{this.state.selected ? this.state.selected : "none selected"}</p>
<div className="py-4 text-center">
<CreateScenarioModal cb={() => {
this.setState({selected: configurator.WorkingFolder + '/scenario.xml'})
this.setState({selected: this.getScenarioPath()})
}}/>
</div>
</Col>