hashicorp-copywrite[bot] 5fb9df1640
[COMPLIANCE] License changes (#18443)
* Adding explicit MPL license for sub-package

This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository.

* Adding explicit MPL license for sub-package

This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository.

* Updating the license from MPL to Business Source License

Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at <Blog URL>, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl.

* add missing license headers

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
2023-08-11 09:12:13 -04:00

209 lines
6.0 KiB
Handlebars

{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
}}
<ModalDialog
class="role-selector"
data-test-role-form
id="new-role"
@onclose={{action (mut state) "role"}}
@aria={{hash
label=(if (eq state 'role') 'New Role' 'New Policy')
}}
as |modal|>
<Ref @target={{this}} @name="modal" @value={{modal}} />
<BlockSlot @name="header">
{{#if (eq state 'role')}}
<h2>New Role</h2>
{{else}}
<h2>New Policy</h2>
{{/if}}
</BlockSlot>
<BlockSlot @name="body">
<input id="{{name}}_state_role" type="radio" name="{{name}}[state]" value="role" checked={{if (eq state 'role') 'checked'}} onchange={{action 'change'}} />
<RoleForm
@form={{form}}
@dc={{dc}}
@nspace={{nspace}}
@partition={{partition}}
>
<BlockSlot @name="policy">
<PolicySelector
@source={{source}}
@dc={{dc}}
@partition={{partition}}
@nspace={{nspace}}
@items={{item.Policies}}
>
<BlockSlot @name="trigger">
<Hds::Button
@text='Create new policy'
@size='small'
@color='tertiary'
@icon='plus'
class='type-dialog'
data-test-create-policy
{{action 'triggerStateCheckboxChange'}}
/>
</BlockSlot>
</PolicySelector>
</BlockSlot>
</RoleForm>
<input id="{{name}}_state_policy" type="radio" name="{{name}}[state]" value="policy" checked={{if (eq state 'policy') 'checked'}} onchange={{action 'change'}} />
<PolicyForm
data-test-policy-form
@name="role[policy]"
@form={{policyForm}}
@dc={{dc}}
@nspace={{nspace}}
@partition={{partition}}
/>
</BlockSlot>
<BlockSlot @name="actions" as |close|>
<Hds::ButtonSet>
{{#if (eq state 'role')}}
<Hds::Button
type='submit'
@text='Create and apply'
@isLoading={{item.isSaving}}
onclick={{perform this.save item items (queue (action close) (action 'reset'))}}
disabled={{if (or item.isSaving item.isPristine item.isInvalid) 'disabled'}}
/>
<Hds::Button
@text='Cancel'
type='reset'
@color='secondary'
disabled={{if item.isSaving 'disabled'}}
{{on 'click' (action (queue (action close) (action 'reset')))}}
/>
{{else}}
<Hds::Button
type='submit'
@text='Create and apply'
@isLoading={{policy.isSaving}}
{{action 'dispatch' 'save' (array policy item.Policies (action (mut state) 'role'))}}
disabled={{if (or policy.isSaving policy.isPristine policy.isInvalid) 'disabled'}}
/>
<Hds::Button
@text='Cancel'
type='reset'
@color='secondary'
disabled={{if policy.isSaving 'disabled'}}
{{on 'click' (action (mut state) 'role')}}
/>
{{/if}}
</Hds::ButtonSet>
</BlockSlot>
</ModalDialog>
<ChildSelector
@disabled={{disabled}}
@repo={{repo}}
@dc={{dc}}
@partition={{partition}}
@nspace={{nspace}}
@type="role"
@placeholder="Search for role"
@items={{items}}
>
<BlockSlot @name="label">
Apply an existing role
</BlockSlot>
<BlockSlot @name="create">
<Hds::Button
@text='Create new role'
@size='small'
@color='tertiary'
@icon='plus'
class='type-dialog'
data-test-role-create
{{on "click" (optional this.modal.open)}}
/>
</BlockSlot>
<BlockSlot @name="option" as |option|>
{{option.Name}}
</BlockSlot>
<BlockSlot @name="set">
<TabularCollection
data-test-roles
@rows={{5}}
@items={{sort-by 'CreateTime:desc' 'Name:asc' items}} as |item index|
>
<BlockSlot @name="header">
<th>Name</th>
<th>Description</th>
</BlockSlot>
<BlockSlot @name="row">
<td>
<a href={{href-to 'dc.acls.roles.edit' item.ID}}>{{item.Name}}</a>
</td>
<td>
{{item.Description}}
</td>
</BlockSlot>
<BlockSlot @name="actions" as |index change checked|>
<PopoverMenu @expanded={{if (eq checked index) true false}} @onchange={{action change index}} @keyboardAccess={{false}}>
<BlockSlot @name="trigger">
More
</BlockSlot>
<BlockSlot @name="menu" as |confirm send keypressClick|>
<li role="none">
<a role="menuitem" tabindex="-1" href={{href-to 'dc.acls.roles.edit' item.ID}}>
{{#if (can "edit role" item=item)}}
Edit
{{else}}
View
{{/if}}
</a>
</li>
{{#if (not disabled)}}
<li role="none" class="dangerous">
<label for={{confirm}} role="menuitem" tabindex="-1" onkeypress={{keypressClick}} data-test-delete>Remove</label>
<div role="menu">
<InformedAction
class="warning"
>
<:header>
Confirm Remove
</:header>
<:body>
<p>
Are you sure you want to remove this role?
</p>
</:body>
<:actions as |Actions|>
<Actions.Action class="dangerous">
<Action
tabindex="-1"
{{on 'click' (action send 'remove' item items)}}
>
Remove
</Action>
</Actions.Action>
<Actions.Action>
<Action
@for={{confirm}}
>
Cancel
</Action>
</Actions.Action>
</:actions>
</InformedAction>
</div>
</li>
{{/if}}
</BlockSlot>
</PopoverMenu>
</BlockSlot>
</TabularCollection>
</BlockSlot>
</ChildSelector>