diff --git a/atst/routes/applications/settings.py b/atst/routes/applications/settings.py index 586e6d3d..07b08fd5 100644 --- a/atst/routes/applications/settings.py +++ b/atst/routes/applications/settings.py @@ -169,6 +169,19 @@ def update(application_id): environments_obj=get_environments_obj_for_app(application=application), ) +@applications_bp.route("/applications//add_environment", methods=["POST"]) +@user_can(Permissions.EDIT_APPLICATION, message="add application environment") +def add_environment(application_id): + application = Applications.get(application_id) + form = ApplicationForm(http_request.form) + + return render_template( + "portfolios/applications/settings.html", + application=application, + form=form, + environments_obj=get_environments_obj_for_app(application=application), + ) + @applications_bp.route("/environments//roles", methods=["POST"]) @user_can(Permissions.ASSIGN_ENVIRONMENT_MEMBER, message="update environment roles") diff --git a/templates/fragments/applications/add_new_environment.html b/templates/fragments/applications/add_new_environment.html new file mode 100644 index 00000000..9adf1e7e --- /dev/null +++ b/templates/fragments/applications/add_new_environment.html @@ -0,0 +1,33 @@ +{% from "components/toggle_list.html" import ToggleButton, ToggleSection %} + +
+ {{ form.csrf_token }} + + +
+ {% set add_env_link %} + + {{ "portfolios.applications.add_environment" | translate }} + {{ Icon('plus') }} + + {% endset %} + + {% call ToggleSection(section_name="add-new-environment") %} +
+ {{ "portfolios.applications.create_new_env" | translate }} +
{{ "portfolios.applications.create_new_env_info" | translate }}
+ {{ "portfolios.applications.enter_env_name" | translate }} +
+ {% endcall %} + + {{ + ToggleButton( + open_html=add_env_link, + close_html=add_env_link, + section_name="add-new-environment" + ) + }} +
+
+ +
diff --git a/templates/portfolios/applications/settings.html b/templates/portfolios/applications/settings.html index efa44f0f..b21710ec 100644 --- a/templates/portfolios/applications/settings.html +++ b/templates/portfolios/applications/settings.html @@ -69,6 +69,10 @@ {% if user_can(permissions.EDIT_APPLICATION) %} {% include "fragments/applications/edit_environments.html" %} + {% if user_can(permissions.CREATE_ENVIRONMENT) %} + {% include "fragments/applications/add_new_environment.html" %} + {% endif %} + {% elif user_can(permissions.VIEW_ENVIRONMENT) %} {% include "fragments/applications/read_only_environments.html" %} {% endif %} diff --git a/translations.yaml b/translations.yaml index 449bd585..d7161885 100644 --- a/translations.yaml +++ b/translations.yaml @@ -420,6 +420,8 @@ portfolios: add_another_environment: Add another environment app_settings_text: App settings create_button_text: Create + create_new_env: Create a new environment. + create_new_env_info: Creating an environment gives you access to the Cloud Service Provider. This environment will function within the constraints of the task order, and any costs will be billed against the portfolio. csp_console_text: CSP console delete: alert: @@ -427,6 +429,7 @@ portfolios: title: Warning! This action is permanent. button: Delete application header: Are you sure you want to delete this application? + enter_env_name: "Enter environment name:" environments: name: Name delete: