<form>
{{#if (not (token/is-legacy item))}}
  {{partial 'dc/acls/tokens/fieldsets'}}
{{else}}
  {{partial 'dc/acls/tokens/fieldsets-legacy'}}
{{/if}}
    {{!TODO: Make this into a slotted component}}
    <div>
{{#if (and create (can "create tokens")) }}
  {{! new tokens can be saved without you filling anything in, old tokens remain using isPristine }}
        <button type="submit" {{ action "create" item}} disabled={{if (or (and (token/is-legacy item) item.isPristine) item.isInvalid) 'disabled'}}>Save</button>
{{ else }}
  {{#if (can "write token" item=item)}}
        <button type="submit" {{ action "update" item}} disabled={{if item.isInvalid 'disabled'}}>Save</button>
  {{/if}}
{{/if}}

        <button type="reset" {{ action "cancel" item}}>Cancel</button>
{{# if (and (not create) (can "delete token" item=item token=token) ) }}
        <ConfirmationDialog @message="Are you sure you want to delete this Token?">
            <BlockSlot @name="action" as |confirm|>
                <button type="button" data-test-delete class="type-delete" {{action confirm 'delete' item}}>Delete</button>
            </BlockSlot>
            <BlockSlot @name="dialog" as |execute cancel message|>
              <DeleteConfirmation @message={{message}} @execute={{execute}} @cancel={{cancel}} />
            </BlockSlot>
        </ConfirmationDialog>
{{/if}}
    </div>
</form>
