Skip to content

Commit

Permalink
Merge pull request #226 from mindvalley/feat/add-allowed-admin-prompt…
Browse files Browse the repository at this point in the history
…-in-application-init

DX-766 feat: add `allowed admins` prompt into application init flow
  • Loading branch information
onimsha authored Aug 26, 2024
2 parents 224774b + da5d9c6 commit d764ddf
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions cli/src/commands/application/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,28 @@ pub async fn handle_application_init(context: Context) -> Result<bool, WKCliErro
)
.prompt()?;

println!();
let elixir_livebook_enabled = selected_addons.contains(&"Elixir Livebook");

let allowed_admins = if elixir_livebook_enabled {
let mut admins_list = vec![];
println!();
println!("Add one or more Mindvalley emails allowed to access the Elixir Livebook.");
while admins_list.len() < 10 {
let admin = inquire::Text::new("Add an admin")
.with_render_config(inquire_render_config())
.with_placeholder("[email protected]")
.with_help_message("Type in a valid email and press enter to add another admin. Press enter on an empty line to finish.\nA maximum of 10 admins are allowed per app")
.prompt()?;
if admin.is_empty() {
break;
}
admins_list.push(admin);
}
println!();
admins_list
} else {
vec![]
};

let configure_staging_namespace =
inquire::Confirm::new("Do you want to configure the staging namespace?")
Expand All @@ -113,23 +134,19 @@ pub async fn handle_application_init(context: Context) -> Result<bool, WKCliErro
excluded_workflows,
};

let elixir_livebook_enabled = selected_addons
.iter()
.find(|addon| addon == &&"Elixir livebook");

application_configs.application = ApplicationConfig {
name,
enable: true,
workflows: Some(workflows),
namespaces,
addons: Some(ApplicationAddonsConfig {
elixir_livebook: if elixir_livebook_enabled.is_none() {
None
} else {
elixir_livebook: if elixir_livebook_enabled {
Some(ApplicationAddonElixirLivebookConfig {
enable: true,
allowed_admins: vec![],
allowed_admins,
})
} else {
None
},
}),
};
Expand Down

0 comments on commit d764ddf

Please sign in to comment.