Merge branch 'main' into chore-update-to-plugin
This commit is contained in:
10 files changed
+136
-27
No files matched your search
@@ -39,11 +39,6 @@ export default class GeneratedHostCatalogModel extends BaseModel {
|
||||
})
|
||||
disabled;
|
||||
|
||||
@attr({
|
||||
description: 'Attributes specific to the catalog type',
|
||||
})
|
||||
attributes;
|
||||
|
||||
@attr('number', {
|
||||
description: 'Current version number of this resource.',
|
||||
})
|
||||
|
||||
@@ -234,11 +234,13 @@ export default class ApplicationSerializer extends RESTSerializer {
|
||||
*/
|
||||
normalizeNestedAttributes(typeClass, hash) {
|
||||
typeClass.attributes.forEach((attribute) => {
|
||||
const { isNestedAttribute } = attribute.options;
|
||||
const attributeValue = hash.attributes?.[attribute.name];
|
||||
if (isNestedAttribute && typeof attributeValue != 'undefined') {
|
||||
hash[attribute.name] = attributeValue;
|
||||
}
|
||||
const {
|
||||
name,
|
||||
options: { isNestedAttribute },
|
||||
} = attribute;
|
||||
const value = hash.attributes?.[name];
|
||||
const isUndefined = value === undefined;
|
||||
if (isNestedAttribute && !isUndefined) hash[name] = value;
|
||||
});
|
||||
return hash;
|
||||
}
|
||||
@@ -261,15 +263,8 @@ export default class ApplicationSerializer extends RESTSerializer {
|
||||
name,
|
||||
options: { isNestedSecret },
|
||||
} = attribute;
|
||||
const attributeValue = hash.secrets?.[name];
|
||||
|
||||
// FIXME: This could be improved
|
||||
if (isNestedSecret) {
|
||||
hash[name] = null;
|
||||
if (typeof attributeValue != 'undefined') {
|
||||
hash[name] = attributeValue;
|
||||
}
|
||||
}
|
||||
const value = hash.secrets?.[name];
|
||||
if (isNestedSecret) hash[name] = value || null;
|
||||
});
|
||||
return hash;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import ApplicationSerializer from './application';
|
||||
import { copy } from 'ember-copy';
|
||||
|
||||
const fieldsByType = {
|
||||
aws: [
|
||||
@@ -57,11 +56,4 @@ export default class HostCatalogSerializer extends ApplicationSerializer {
|
||||
delete serialized.secrets;
|
||||
return serialized;
|
||||
}
|
||||
|
||||
normalize(typeClass, hash, ...rest) {
|
||||
let normalizedHash = copy(hash, true);
|
||||
const normalized = super.normalize(typeClass, normalizedHash, ...rest);
|
||||
delete normalized.data.attributes.attributes;
|
||||
return normalized;
|
||||
}
|
||||
}
|
||||
@@ -78,6 +78,75 @@
|
||||
<Rose::Form::Fieldset>
|
||||
<:title>{{t 'form.provider.filter.label'}}</:title>
|
||||
<:description>{{t 'form.provider.filter.help'}}</:description>
|
||||
<:body>
|
||||
{{#if @model.errors.filters}}
|
||||
<Rose::Form::Errors as |errors|>
|
||||
{{#each @model.errors.filters as |error|}}
|
||||
<errors.message>{{error.message}}</errors.message>
|
||||
{{/each}}
|
||||
</Rose::Form::Errors>
|
||||
{{/if}}
|
||||
<Rose::Table @style='condensed' as |table|>
|
||||
<table.header as |header|>
|
||||
<header.row @hidden={{true}} as |row|>
|
||||
<row.headerCell>{{t 'titles.value'}}</row.headerCell>
|
||||
<row.headerCell />
|
||||
</header.row>
|
||||
</table.header>
|
||||
<table.body as |body|>
|
||||
{{#each @model.filters as |filter i|}}
|
||||
<body.row as |row|>
|
||||
<row.cell>
|
||||
<form.input
|
||||
@type='text'
|
||||
@value={{filter.value}}
|
||||
@error={{@model.errors.filters}}
|
||||
@contextual={{true}}
|
||||
as |field|
|
||||
>
|
||||
<field.field />
|
||||
</form.input>
|
||||
</row.cell>
|
||||
<row.cell @shrink={{true}}>
|
||||
<Rose::Button
|
||||
@style='warning'
|
||||
@iconOnly='flight-icons/svg/trash-16'
|
||||
title={{t 'actions.remove'}}
|
||||
@disabled={{if
|
||||
@model.isNew
|
||||
false
|
||||
(if form.isEditable false true)
|
||||
}}
|
||||
{{on 'click' (fn @removeItemByIndex 'filters' i)}}
|
||||
>
|
||||
{{t 'actions.remove'}}
|
||||
</Rose::Button>
|
||||
</row.cell>
|
||||
</body.row>
|
||||
{{/each}}
|
||||
|
||||
<body.row as |row|>
|
||||
<row.cell>
|
||||
<form.input @type='text' @value={{@model.filter}} />
|
||||
</row.cell>
|
||||
<row.cell @shrink={{true}}>
|
||||
<Rose::Button
|
||||
@style='secondary'
|
||||
title={{t 'actions.add'}}
|
||||
@disabled={{if
|
||||
@model.isNew
|
||||
false
|
||||
(if form.isEditable false true)
|
||||
}}
|
||||
{{on 'click' (fn @addStringItem 'filters' @model.filter)}}
|
||||
>
|
||||
{{t 'actions.add'}}
|
||||
</Rose::Button>
|
||||
</row.cell>
|
||||
</body.row>
|
||||
</table.body>
|
||||
</Rose::Table>
|
||||
</:body>
|
||||
</Rose::Form::Fieldset>
|
||||
|
||||
{{#if (can 'save model' @model)}}
|
||||
|
||||
@@ -78,6 +78,7 @@
|
||||
<form.textarea
|
||||
@name='filter'
|
||||
@type='filter'
|
||||
@value={{@model.filter}}
|
||||
@label={{t 'form.provider.filter.label'}}
|
||||
@helperText={{t 'form.provider.filter.help'}}
|
||||
@linkText={{t 'form.provider.filter.link-text'}}
|
||||
|
||||
@@ -3,4 +3,6 @@
|
||||
model=@model
|
||||
submit=@submit
|
||||
cancel=@cancel
|
||||
removeItemByIndex=@removeItemByIndex
|
||||
addStringItem=@addStringItem
|
||||
}}
|
||||
@@ -1,4 +1,5 @@
|
||||
import Route from '@ember/routing/route';
|
||||
import { action } from '@ember/object';
|
||||
|
||||
export default class ScopesScopeHostCatalogsHostCatalogHostSetsHostSetRoute extends Route {
|
||||
// =methods
|
||||
@@ -49,4 +50,30 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsHostSetRoute exte
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a string item to array `property` on the passed `filter`.
|
||||
|
||||
* @param {hostSetModel} hostSet
|
||||
* @param {string} property
|
||||
* @param {string} value
|
||||
*/
|
||||
@action
|
||||
async addStringItem(hostSet, property, value) {
|
||||
const array = hostSet.get(property);
|
||||
array.addObject({ value });
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an item from array `property` at `index` on the
|
||||
* passed `hostSet`.
|
||||
* @param {hostSetModel} hostSet
|
||||
* @param {string} property
|
||||
* @param {number} index
|
||||
*/
|
||||
@action
|
||||
async removeItemByIndex(hostSet, property, index) {
|
||||
const array = hostSet.get(property);
|
||||
array.removeAt(index);
|
||||
}
|
||||
}
|
||||
@@ -63,4 +63,28 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsNewRoute extends
|
||||
async changeType(type) {
|
||||
await this.router.replaceWith({ queryParams: { type } });
|
||||
}
|
||||
/**
|
||||
* Adds a string item to array `property` on the passed `filter`.
|
||||
|
||||
* @param {hostSetModel} hostSet
|
||||
* @param {string} property
|
||||
* @param {string} value
|
||||
*/
|
||||
@action
|
||||
async addStringItem(hostSet, property, value) {
|
||||
const array = hostSet.get(property);
|
||||
array.addObject({ value });
|
||||
}
|
||||
/**
|
||||
* Removes an item from array `property` at `index` on the
|
||||
* passed `hostSet`.
|
||||
* @param {hostSetModel} hostSet
|
||||
* @param {string} property
|
||||
* @param {number} index
|
||||
*/
|
||||
@action
|
||||
async removeItemByIndex(hostSet, property, index) {
|
||||
const array = hostSet.get(property);
|
||||
array.removeAt(index);
|
||||
}
|
||||
}
|
||||
+2
@@ -2,4 +2,6 @@
|
||||
@model={{@model}}
|
||||
@submit={{route-action 'save' @model}}
|
||||
@cancel={{route-action 'cancel' @model}}
|
||||
@removeItemByIndex={{route-action 'removeItemByIndex' @model}}
|
||||
@addStringItem={{route-action 'addStringItem' @model}}
|
||||
/>
|
||||
@@ -5,4 +5,6 @@
|
||||
@submit={{route-action 'save' @model}}
|
||||
@cancel={{route-action 'cancel' @model}}
|
||||
@changeType={{route-action 'changeType' @model.type}}
|
||||
@removeItemByIndex={{route-action 'removeItemByIndex' @model}}
|
||||
@addStringItem={{route-action 'addStringItem' @model}}
|
||||
/>
|
||||
Reference in new issue
Block a user