-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create modal wizard component, open when region not supplied
- Loading branch information
1 parent
749c83f
commit 9498507
Showing
2 changed files
with
77 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Box } from "../components/box"; | ||
import { ModalLayout } from "../components/modalLayout"; | ||
import { ModalTitle } from "../components/modalTitle"; | ||
import { InteractiveList } from "../components/interactiveList"; | ||
import { awsRegionLocations } from "../constants"; | ||
|
||
function updateRegionTable(table) { | ||
const regions = awsRegionLocations.map((region) => region.label); | ||
table.setItems(regions); | ||
} | ||
|
||
const clargsWizardModal = (screen, application) => { | ||
let region = ""; | ||
const wizardLayout = new ModalLayout(screen, 112, 27, true); | ||
|
||
const closeModal = () => { | ||
application.updateRegion(region); | ||
application.setIsModalOpen(false); | ||
application.returnFocus(); | ||
wizardLayout.destroy(); | ||
}; | ||
|
||
new ModalTitle(wizardLayout, 110, "Select your stack/region"); | ||
|
||
const regionTable = new InteractiveList(wizardLayout, 110, 20, "Regions"); | ||
|
||
new Box( | ||
wizardLayout, | ||
110, | ||
4, | ||
"Arrow keys to navigate | ENTER to select region" | ||
); | ||
|
||
updateRegionTable(regionTable); | ||
regionTable.focus(); | ||
|
||
regionTable.key(["enter"], () => { | ||
region = regionTable.ritems[regionTable.selected]; | ||
closeModal(); | ||
}); | ||
|
||
return wizardLayout; | ||
}; | ||
|
||
module.exports = { clargsWizardModal }; |