A bug was caused by using the MemberManagementTemplate macro and not supplying all of the necessary kwargs. Intially, this bug was fixed by supplying the kwargs used by the macro at the time, but in this refactor, we simply remove those kwargs and refer to the permissions directly in the template by importing the macro with context.
186 lines
8.1 KiB
HTML
186 lines
8.1 KiB
HTML
{% from "components/alert.html" import Alert %}
|
|
{% from "components/icon.html" import Icon %}
|
|
{% import "applications/fragments/new_member_modal_content.html" as member_steps %}
|
|
{% import "applications/fragments/member_form_fields.html" as member_fields %}
|
|
{% from "components/modal.html" import Modal %}
|
|
{% from "components/multi_step_modal_form.html" import MultiStepModalForm %}
|
|
{% from "components/save_button.html" import SaveButton %}
|
|
|
|
{% macro MemberManagementTemplate(
|
|
application,
|
|
members,
|
|
new_member_form,
|
|
action) %}
|
|
|
|
<div class="subheading" id="application-members">
|
|
{{ 'portfolios.applications.settings.team_members' | translate }}
|
|
</div>
|
|
|
|
{% if g.matchesPath("application-members") %}
|
|
{% include "fragments/flash.html" %}
|
|
{% endif %}
|
|
|
|
<div class="panel">
|
|
{% if not application.members %}
|
|
<div class='empty-state panel__content'>
|
|
<p class='empty-state__message'>{{ ("portfolios.applications.team_settings.blank_slate.title" | translate) }}</p>
|
|
|
|
{{ Icon('avatar') }}
|
|
|
|
{% if not user_can(permissions.CREATE_APPLICATION_MEMBER) %}
|
|
<p class='empty-state__sub-message'>{{ ("portfolios.applications.team_settings.blank_slate.sub_message" | translate) }}</p>
|
|
{% endif %}
|
|
|
|
{% if user_can(permissions.CREATE_APPLICATION_MEMBER) %}
|
|
{% set new_member_modal_name = "add-app-mem" %}
|
|
<a class="usa-button usa-button-big" v-on:click="openModal('{{ new_member_modal_name }}')">
|
|
{{ "portfolios.applications.team_settings.blank_slate.action_label" | translate }}
|
|
</a>
|
|
{{ MultiStepModalForm(
|
|
name=new_member_modal_name,
|
|
form=new_member_form,
|
|
form_action=url_for(action, application_id=application.id),
|
|
steps=[
|
|
member_steps.MemberStepOne(new_member_form),
|
|
member_steps.MemberStepTwo(new_member_form, application)
|
|
],
|
|
) }}
|
|
{% endif %}
|
|
</div>
|
|
|
|
{% else %}
|
|
{% set new_member_modal_name = "add-app-mem" %}
|
|
|
|
{% for member in members %}
|
|
{%- if user_can(permissions.EDIT_APPLICATION_MEMBER) %}
|
|
{% set modal_name = "edit_member-{}".format(loop.index) %}
|
|
{% call Modal(modal_name, classes="form-content--app-mem") %}
|
|
<div class="modal__form--header">
|
|
<h1>{{ Icon('avatar') }} {{ member.user_name }}</h1>
|
|
<hr>
|
|
</div>
|
|
<base-form inline-template>
|
|
<form id='{{ modal_name }}' method="POST" action="{{ url_for('applications.update_member', application_id=application.id, application_role_id=member.role_id) }}">
|
|
{{ member.form.csrf_token }}
|
|
{{ member_fields.PermsFields(form=member.form, member_role_id=member.role_id) }}
|
|
<div class="action-group">
|
|
{{ SaveButton(text='Update', element='input', additional_classes='action-group__action') }}
|
|
<a class='action-group__action usa-button usa-button-secondary' v-on:click="closeModal('{{ modal_name }}')">{{ "common.cancel" | translate }}</a>
|
|
</div>
|
|
</form>
|
|
</base-form>
|
|
{% endcall %}
|
|
|
|
{%- if member.role_status == 'pending' %}
|
|
{% set resend_invite_modal = "resend_invite-{}".format(member.role_id) %}
|
|
{% call Modal(resend_invite_modal, classes="form-content--app-mem") %}
|
|
<div class="modal__form--header">
|
|
<h1>Verify Member Information</h1>
|
|
<hr>
|
|
</div>
|
|
<base-form inline-template>
|
|
<form id='{{ resend_invite_modal }}' method="POST" action="{{ url_for('applications.resend_invite', application_id=application.id, application_role_id=member.role_id) }}">
|
|
{{ member.update_invite_form.csrf_token }}
|
|
{{ member_fields.InfoFields(member.update_invite_form) }}
|
|
<div class="action-group">
|
|
<input type="submit" class="usa-button usa-button-primary action-group__action" tabindex="0" value="Resend Invite" />
|
|
<a class='action-group__action' v-on:click="closeModal('{{ resend_invite_modal }}')">{{ "common.cancel" | translate }}</a>
|
|
</div>
|
|
</form>
|
|
</base-form>
|
|
{% endcall %}
|
|
{% endif -%}
|
|
{% endif -%}
|
|
|
|
{% if user_can(permissions.DELETE_APPLICATION_MEMBER) and member.role_status == 'pending' -%}
|
|
{% set revoke_invite_modal = "revoke_invite_{}".format(member.role_id) %}
|
|
{% call Modal(name=revoke_invite_modal) %}
|
|
<form method="post" action="{{ url_for('applications.revoke_invite', application_id=application.id, application_role_id=member.role_id) }}">
|
|
{{ member.form.csrf_token }}
|
|
<h1>{{ "invites.revoke" | translate }}</h1>
|
|
<hr>
|
|
{{ "invites.revoke_modal_text" | translate({"application": application.name}) }}
|
|
<div class="action-group">
|
|
<button class="action-group__action usa-button usa-button-primary" type="submit">{{ "invites.revoke" | translate }}</button>
|
|
<button class='action-group__action usa-button usa-button-secondary' v-on:click='closeModal("{{revoke_invite_modal}}")' type="button">{{ "common.cancel" | translate }}</button>
|
|
</div>
|
|
</form>
|
|
{% endcall %}
|
|
{%- endif %}
|
|
{% endfor %}
|
|
|
|
<section class="member-list application-list">
|
|
<div class='responsive-table-wrapper'>
|
|
<table class="atat-table">
|
|
<thead>
|
|
<tr>
|
|
<th>Member</th>
|
|
<th>Application Permissions</th>
|
|
<th>Environment Access</th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for member in members %}
|
|
{% set modal_name = "edit_member-{}".format(loop.index) %}
|
|
<tr>
|
|
<td>
|
|
<strong>{{ member.user_name }}</strong>
|
|
<a class="icon-link" v-on:click="openModal('{{ modal_name }}')">
|
|
{{ Icon('edit') }}
|
|
</a>
|
|
<br>
|
|
{% if member.role_status == 'pending' %}
|
|
<span class='label label--purple'>INVITE PENDING</span>
|
|
{% endif %}
|
|
|
|
</td>
|
|
|
|
<td>
|
|
{% for perm, value in member.permission_sets.items() %}
|
|
{{ ("portfolios.applications.members.{}.{}".format(perm, value)) | translate }}<br>
|
|
{% endfor %}
|
|
</td>
|
|
<td>
|
|
{% for env in member.environment_roles %}
|
|
{{ env.environment_name }}{% if not env == member.environment_roles[-1]%},{% endif %}
|
|
{% endfor %}
|
|
</td>
|
|
<td>
|
|
{% if member.role_status == 'pending' -%}
|
|
{% set revoke_invite_modal = "revoke_invite_{}".format(member.role_id) %}
|
|
{% set resend_invite_modal = "resend_invite-{}".format(member.role_id) %}
|
|
<a v-on:click='openModal("{{ resend_invite_modal }}")'>Resend Invite</a><br>
|
|
{% if user_can(permissions.DELETE_APPLICATION_MEMBER) -%}
|
|
<a v-on:click='openModal("{{ revoke_invite_modal }}")'>{{ 'invites.revoke' | translate }}</a>
|
|
{%- endif %}
|
|
{%- endif %}
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
{% if user_can(permissions.CREATE_APPLICATION_MEMBER) %}
|
|
<a class="usa-button usa-button-secondary add-new-button" v-on:click="openModal('{{ new_member_modal_name }}')">
|
|
{{ "portfolios.applications.add_member" | translate }}
|
|
</a>
|
|
{% endif %}
|
|
</div>
|
|
|
|
{% if user_can(permissions.CREATE_APPLICATION_MEMBER) %}
|
|
{{ MultiStepModalForm(
|
|
name=new_member_modal_name,
|
|
form=new_member_form,
|
|
form_action=url_for(action, application_id=application.id),
|
|
steps=[
|
|
member_steps.MemberStepOne(new_member_form),
|
|
member_steps.MemberStepTwo(new_member_form, application)
|
|
],
|
|
) }}
|
|
{% endif %}
|
|
</section>
|
|
{% endif %}
|
|
</div>
|
|
|
|
{% endmacro %}
|