sls-dev-tools
Version:
The Dev Tools for the Serverless World
41 lines (30 loc) • 1.11 kB
JavaScript
;
var _box = require("../components/box");
var _modalLayout = require("../components/modalLayout");
var _modalTitle = require("../components/modalTitle");
var _interactiveList = require("../components/interactiveList");
var _constants = require("../constants");
function updateRegionTable(table) {
const regions = _constants.awsRegionLocations.map(region => region.label);
table.setItems(regions);
}
const regionWizardModal = (screen, application) => {
const wizardLayout = new _modalLayout.ModalLayout(screen, 112, 27, true);
const closeModal = () => {
wizardLayout.destroy();
application.returnFocus();
};
new _modalTitle.ModalTitle(wizardLayout, 110, "Select your region");
const regionTable = new _interactiveList.InteractiveList(wizardLayout, 110, 20, "Regions");
new _box.Box(wizardLayout, 110, 4, "Arrow keys to navigate | ENTER to select region");
updateRegionTable(regionTable);
regionTable.focus();
regionTable.key(["enter"], () => {
closeModal();
});
screen.render();
return regionTable;
};
module.exports = {
regionWizardModal
};