consul/ui-v2/app/components/consul-intention-form/index.hbs

81 lines
2.7 KiB
Handlebars

<DataForm
@dc={{dc}}
@nspace={{nspace}}
@type="intention"
@autofill={{autofill}}
@item={{item}}
@src={{src}}
@onchange={{action "change"}}
@onsubmit={{action onsubmit}}
as |api|
>
<BlockSlot @name="error" as |Notification|>
<Notification>
<p data-notification role="alert" class="error notification-update">
{{#if (starts-with 'duplicate intention found:' api.error.detail)}}
<strong>Intention exists</strong>
An intention already exists for this Source-Destination pair. Please enter a different combination of Services, or search the intentions to edit an existing intention.
{{else}}
<strong>Error!</strong>
There was an error saving your intention.
{{#if (and api.error.status api.error.detail)}}
<br />{{api.error.status}}: {{api.error.detail}}
{{/if}}
{{/if}}
</p>
</Notification>
</BlockSlot>
<BlockSlot @name="form">
{{#let api.data as |item|}}
{{#if item.IsEditable}}
<DataSource
@src={{concat '/' nspace '/' dc '/services'}}
@onchange={{action "createServices" item}}
/>
{{#if (env 'CONSUL_NSPACES_ENABLED')}}
<DataSource
@src="/*/*/namespaces"
@onchange={{action "createNspaces" item}}
/>
{{/if}}
<form onsubmit={{action api.submit}}>
<ConsulIntentionForm::Fieldsets
@nspaces={{nspaces}}
@services={{services}}
@SourceName={{SourceName}}
@SourceNS={{SourceNS}}
@DestinationName={{DestinationName}}
@DestinationNS={{DestinationNS}}
@item={{item}}
@disabled={{api.disabled}}
@create={{api.isCreate}}
@onchange={{api.change}}
/>
<div>
<button type="submit" disabled={{or item.isInvalid api.disabled}}>Save</button>
<button type="reset" onclick={{action oncancel item}} disabled={{api.disabled}}>Cancel</button>
{{#if (not api.isCreate)}}
{{#if (not-eq item.ID 'anonymous') }}
<ConfirmationDialog @message="Are you sure you want to delete this Intention?">
<BlockSlot @name="action" as |confirm|>
<button data-test-delete type="button" class="type-delete" {{action confirm api.delete}} disabled={{api.disabled}}>Delete</button>
</BlockSlot>
<BlockSlot @name="dialog" as |execute cancel message|>
<DeleteConfirmation @message={{message}} @execute={{execute}} @cancel={{cancel}} />
</BlockSlot>
</ConfirmationDialog>
{{/if}}
{{/if}}
</div>
</form>
{{else}}
<ConsulIntentionView
@item={{item}}
/>
{{/if}}
{{/let}}
</BlockSlot>
</DataForm>