1 parent
6d88206491
commit
2dbcc1c0af
9 files changed
+454
-2
No files matched your search
@@ -0,0 +1,152 @@
|
||||
{{!
|
||||
Copyright (c) HashiCorp, Inc.
|
||||
SPDX-License-Identifier: MPL-2.0
|
||||
}}
|
||||
|
||||
<Rose::Form
|
||||
@onSubmit={{@submit}}
|
||||
@cancel={{@cancel}}
|
||||
@disabled={{@model.isSaving}}
|
||||
@showEditToggle={{if @model.isNew false true}}
|
||||
as |form|
|
||||
>
|
||||
<Hds::Form::TextInput::Field
|
||||
name='name'
|
||||
@isOptional={{true}}
|
||||
@value={{@model.name}}
|
||||
@isInvalid={{@model.errors.name}}
|
||||
disabled={{form.disabled}}
|
||||
{{on 'input' (set-from-event @model 'name')}}
|
||||
as |F|
|
||||
>
|
||||
<F.Label>{{t 'form.name.label'}}</F.Label>
|
||||
<F.HelperText>{{t 'form.name.help'}}</F.HelperText>
|
||||
{{#if @model.errors.name}}
|
||||
<F.Error as |E|>
|
||||
{{#each @model.errors.name as |error|}}
|
||||
<E.Message>{{error.message}}</E.Message>
|
||||
{{/each}}
|
||||
</F.Error>
|
||||
{{/if}}
|
||||
</Hds::Form::TextInput::Field>
|
||||
<Hds::Form::Textarea::Field
|
||||
name='description'
|
||||
@isOptional={{true}}
|
||||
@value={{@model.description}}
|
||||
@isInvalid={{@model.errors.description}}
|
||||
disabled={{form.disabled}}
|
||||
as |F|
|
||||
>
|
||||
<F.Label>{{t 'form.description.label'}}</F.Label>
|
||||
<F.HelperText>{{t 'form.description.help'}}</F.HelperText>
|
||||
{{#if @model.errors.description}}
|
||||
<F.Error as |E|>
|
||||
{{#each @model.errors.description as |error|}}
|
||||
<E.Message>{{error.message}}</E.Message>
|
||||
{{/each}}
|
||||
</F.Error>
|
||||
{{/if}}
|
||||
</Hds::Form::Textarea::Field>
|
||||
|
||||
<Hds::Form::Fieldset as |F|>
|
||||
<F.Legend>
|
||||
{{t 'resources.alias.form.options.label'}}
|
||||
</F.Legend>
|
||||
<F.HelperText>
|
||||
{{t 'resources.alias.description'}}
|
||||
</F.HelperText>
|
||||
<F.Control>
|
||||
<Hds::Form::RadioCard::Group @name='type' @alignment='center' as |G|>
|
||||
<G.Legend>{{t 'resources.target.form.type.label'}}</G.Legend>
|
||||
<G.RadioCard @maxWidth='15rem' @checked='true' @disabled='true' as |R|>
|
||||
<R.Label>{{t 'resources.alias.form.type.label'}}</R.Label>
|
||||
<R.Description>{{t 'resources.alias.form.type.help'}}</R.Description>
|
||||
<R.Icon @name='target' />
|
||||
</G.RadioCard>
|
||||
</Hds::Form::RadioCard::Group>
|
||||
</F.Control>
|
||||
</Hds::Form::Fieldset>
|
||||
|
||||
<Hds::Form::TextInput::Field
|
||||
name='destination_id'
|
||||
@isOptional={{true}}
|
||||
@value={{@model.destination_id}}
|
||||
@isInvalid={{@model.errors.destination_id}}
|
||||
disabled={{form.disabled}}
|
||||
{{on 'input' (set-from-event @model 'destination_id')}}
|
||||
as |F|
|
||||
>
|
||||
<F.Label>{{t 'resources.alias.form.destination_id.label'}}</F.Label>
|
||||
<F.HelperText>{{t
|
||||
'resources.alias.form.destination_id.help'
|
||||
}}</F.HelperText>
|
||||
{{#if @model.errors.destination_id}}
|
||||
<F.Error as |E|>
|
||||
{{#each @model.errors.destination_id as |error|}}
|
||||
<E.Message>{{error.message}}</E.Message>
|
||||
{{/each}}
|
||||
</F.Error>
|
||||
{{/if}}
|
||||
</Hds::Form::TextInput::Field>
|
||||
|
||||
<Hds::Form::TextInput::Field
|
||||
name='authorize_session_arguments'
|
||||
@isOptional={{true}}
|
||||
@value={{@model.authorize_session_arguments.host_id}}
|
||||
@isInvalid={{@model.errors.authorize_session_arguments.host_id}}
|
||||
disabled={{form.disabled}}
|
||||
{{on 'input' this.handleHostIdChange}}
|
||||
as |F|
|
||||
>
|
||||
<F.Label>{{t
|
||||
'resources.alias.form.authorize_session_arguments.label'
|
||||
}}</F.Label>
|
||||
<F.HelperText>{{t
|
||||
'resources.alias.form.authorize_session_arguments.help'
|
||||
}}</F.HelperText>
|
||||
{{#if @model.errors.authorize_session_arguments.host_id}}
|
||||
<F.Error as |E|>
|
||||
{{#each @model.errors.authorize_session_arguments.host_id as |error|}}
|
||||
<E.Message>{{error.message}}</E.Message>
|
||||
{{/each}}
|
||||
</F.Error>
|
||||
{{/if}}
|
||||
</Hds::Form::TextInput::Field>
|
||||
|
||||
<InfoField
|
||||
@value={{@model.scopeModel.displayName}}
|
||||
@icon='globe'
|
||||
disabled={{form.disabled}}
|
||||
as |F|
|
||||
>
|
||||
<F.Label>{{t 'resources.scope.title'}}</F.Label>
|
||||
</InfoField>
|
||||
|
||||
<Hds::Form::TextInput::Field
|
||||
name='value'
|
||||
@isRequired={{true}}
|
||||
@value={{@model.value}}
|
||||
@isInvalid={{@model.errors.value}}
|
||||
disabled={{form.disabled}}
|
||||
{{on 'input' (set-from-event @model 'value')}}
|
||||
as |F|
|
||||
>
|
||||
<F.Label>{{t 'resources.alias.form.value.label'}}</F.Label>
|
||||
<F.HelperText>{{t 'resources.alias.form.value.help'}}</F.HelperText>
|
||||
{{#if @model.errors.value}}
|
||||
<F.Error as |E|>
|
||||
{{#each @model.errors.value as |error|}}
|
||||
<E.Message>{{error.message}}</E.Message>
|
||||
{{/each}}
|
||||
</F.Error>
|
||||
{{/if}}
|
||||
</Hds::Form::TextInput::Field>
|
||||
|
||||
{{#if (can 'save model' @model)}}
|
||||
<form.actions
|
||||
@enableEditText={{t 'actions.edit-form'}}
|
||||
@submitText={{t 'actions.save'}}
|
||||
@cancelText={{t 'actions.cancel'}}
|
||||
/>
|
||||
{{/if}}
|
||||
</Rose::Form>
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*/
|
||||
|
||||
import Component from '@glimmer/component';
|
||||
import { action } from '@ember/object';
|
||||
|
||||
export default class FormAliasComponent extends Component {
|
||||
//actions
|
||||
/**
|
||||
* Handles input changes
|
||||
*/
|
||||
@action
|
||||
handleHostIdChange({ target: { value } }) {
|
||||
if (value) {
|
||||
this.args.model.authorize_session_arguments = {
|
||||
host_id: value,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,61 @@
|
||||
*/
|
||||
|
||||
import Controller from '@ember/controller';
|
||||
import { inject as service } from '@ember/service';
|
||||
import { action } from '@ember/object';
|
||||
import { loading } from 'ember-loading';
|
||||
import { confirm } from 'core/decorators/confirm';
|
||||
import { notifySuccess, notifyError } from 'core/decorators/notify';
|
||||
|
||||
export default class ScopesScopeAliasesIndexController extends Controller {
|
||||
// =services
|
||||
@service can;
|
||||
@service router;
|
||||
// =actions
|
||||
|
||||
/**
|
||||
* Rollback changes on an alias.
|
||||
* @param {AliasModel} alias
|
||||
*/
|
||||
@action
|
||||
async cancel(alias) {
|
||||
const { isNew } = alias;
|
||||
alias.rollbackAttributes();
|
||||
if (isNew) await this.router.transitionTo('scopes.scope.aliases');
|
||||
}
|
||||
|
||||
/**
|
||||
* Save an alias in current scope.
|
||||
* @param {AliasModel} alias
|
||||
*/
|
||||
@action
|
||||
@loading
|
||||
@notifyError(({ message }) => message)
|
||||
@notifySuccess(({ isNew }) =>
|
||||
isNew ? 'notifications.create-success' : 'notifications.save-success',
|
||||
)
|
||||
async save(alias) {
|
||||
await alias.save();
|
||||
if (this.can.can('read model', alias)) {
|
||||
await this.router.transitionTo('scopes.scope.aliases.alias', alias);
|
||||
} else {
|
||||
await this.router.transitionTo('scopes.scope.aliases');
|
||||
}
|
||||
await this.router.refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an alias in current scope and redirect to index
|
||||
* @param {AliasModel} alias
|
||||
*/
|
||||
@action
|
||||
@loading
|
||||
@confirm('questions.delete-confirm')
|
||||
@notifyError(({ message }) => message, { catch: true })
|
||||
@notifySuccess('notifications.delete-success')
|
||||
async delete(alias) {
|
||||
await alias.destroyRecord();
|
||||
await this.router.replaceWith('scopes.scope.aliases');
|
||||
await this.router.refresh();
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
{{t 'resources.alias.title'}}
|
||||
{{! TODO: Add doc link for alias }}
|
||||
</h2>
|
||||
{{! TODO: Add desc for alias }}
|
||||
<p>{{t 'resources.alias.description'}}</p>
|
||||
</page.header>
|
||||
<page.actions>
|
||||
{{#if (can 'create model' this.scope collection='aliases')}}
|
||||
@@ -24,4 +24,36 @@
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</page.actions>
|
||||
<page.body>
|
||||
<Rose::Layout::Centered>
|
||||
<Rose::Message
|
||||
@title={{t 'resources.alias.messages.none.title'}}
|
||||
as |message|
|
||||
>
|
||||
<message.description>
|
||||
{{#if (can 'list model' this.scope collection='aliases')}}
|
||||
{{t 'resources.alias.messages.none.description'}}
|
||||
{{else if (can 'create model' this.scope collection='aliases')}}
|
||||
{{t
|
||||
'descriptions.create-but-not-list'
|
||||
resource=(t 'resources.alias.title_plural')
|
||||
}}
|
||||
{{else}}
|
||||
{{t
|
||||
'descriptions.neither-list-nor-create'
|
||||
resource=(t 'resources.alias.title_plural')
|
||||
}}
|
||||
{{/if}}
|
||||
</message.description>
|
||||
{{#if (can 'create model' this.scope collection='aliases')}}
|
||||
<Hds::Link::Standalone
|
||||
@icon='plus-circle'
|
||||
@iconPosition='leading'
|
||||
@route='scopes.scope.aliases.new'
|
||||
@text={{t 'resources.alias.messages.none.link'}}
|
||||
/>
|
||||
{{/if}}
|
||||
</Rose::Message>
|
||||
</Rose::Layout::Centered>
|
||||
</page.body>
|
||||
</Rose::Layout::Page>
|
||||
@@ -23,5 +23,11 @@
|
||||
{{! TODO: Add desc for alias }}
|
||||
|
||||
</page.header>
|
||||
|
||||
<page.body>
|
||||
<Form::Alias
|
||||
@model={{@model}}
|
||||
@submit={{fn this.aliases.save @model}}
|
||||
@cancel={{fn this.aliases.cancel @model}}
|
||||
/>
|
||||
</page.body>
|
||||
</Rose::Layout::Page>
|
||||
Reference in new issue
Block a user