UI: Namespace area fixes (#19799)
This commit is contained in:
parent
59d3f5110d
commit
b7049eb3fc
|
@ -0,0 +1,3 @@
|
|||
```release-note:bug
|
||||
ui: Fix bad link to namespace when namespace name includes `.`
|
||||
```
|
|
@ -5,28 +5,28 @@
|
|||
|
||||
import ApplicationAdapter from './application';
|
||||
|
||||
export default ApplicationAdapter.extend({
|
||||
export default class NamespaceAdapter extends ApplicationAdapter {
|
||||
pathForType() {
|
||||
return 'namespaces';
|
||||
},
|
||||
}
|
||||
urlForFindAll(modelName, snapshot) {
|
||||
if (snapshot.adapterOptions && snapshot.adapterOptions.forUser) {
|
||||
return `/${this.urlPrefix()}/internal/ui/namespaces`;
|
||||
}
|
||||
return `/${this.urlPrefix()}/namespaces?list=true`;
|
||||
},
|
||||
}
|
||||
|
||||
urlForCreateRecord(modelName, snapshot) {
|
||||
const id = snapshot.attr('path');
|
||||
return this.buildURL(modelName, id);
|
||||
},
|
||||
}
|
||||
|
||||
createRecord(store, type, snapshot) {
|
||||
const id = snapshot.attr('path');
|
||||
return this._super(...arguments).then(() => {
|
||||
return super.createRecord(...arguments).then(() => {
|
||||
return { id };
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
findAll(store, type, sinceToken, snapshot) {
|
||||
if (snapshot.adapterOptions && typeof snapshot.adapterOptions.namespace !== 'undefined') {
|
||||
|
@ -34,9 +34,9 @@ export default ApplicationAdapter.extend({
|
|||
namespace: snapshot.adapterOptions.namespace,
|
||||
});
|
||||
}
|
||||
return this._super(...arguments);
|
||||
},
|
||||
return super.findAll(...arguments);
|
||||
}
|
||||
query() {
|
||||
return this.ajax(`/${this.urlPrefix()}/namespaces?list=true`);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,10 +16,13 @@ export default Component.extend({
|
|||
//public api
|
||||
targetNamespace: null,
|
||||
showLastSegment: false,
|
||||
// set to true if targetNamespace is passed in unmodified
|
||||
// otherwise, this assumes it is parsed as in namespace-picker
|
||||
unparsed: false,
|
||||
|
||||
normalizedNamespace: computed('targetNamespace', function () {
|
||||
const ns = this.targetNamespace;
|
||||
return (ns || '').replace(/\.+/g, '/').replace(/☃/g, '.');
|
||||
normalizedNamespace: computed('targetNamespace', 'unparsed', function () {
|
||||
const ns = this.targetNamespace || '';
|
||||
return this.unparsed ? ns : ns.replace(/\.+/g, '/').replace(/☃/g, '.');
|
||||
}),
|
||||
|
||||
namespaceDisplay: computed('normalizedNamespace', 'showLastSegment', function () {
|
||||
|
|
|
@ -4,21 +4,21 @@
|
|||
*/
|
||||
|
||||
import Model, { attr } from '@ember-data/model';
|
||||
import { computed } from '@ember/object';
|
||||
import { expandAttributeMeta } from 'vault/utils/field-to-attrs';
|
||||
import { withExpandedAttributes } from 'vault/decorators/model-expanded-attributes';
|
||||
|
||||
export default Model.extend({
|
||||
path: attr('string', {
|
||||
@withExpandedAttributes()
|
||||
export default class NamespaceModel extends Model {
|
||||
@attr('string', {
|
||||
validationAttr: 'pathIsValid',
|
||||
invalidMessage: 'You have entered and invalid path please only include letters, numbers, -, ., and _.',
|
||||
}),
|
||||
pathIsValid: computed('path', function () {
|
||||
})
|
||||
path;
|
||||
|
||||
get pathIsValid() {
|
||||
return this.path && this.path.match(/^[\w\d-.]+$/g);
|
||||
}),
|
||||
description: attr('string', {
|
||||
editType: 'textarea',
|
||||
}),
|
||||
fields: computed(function () {
|
||||
return expandAttributeMeta(this, ['path']);
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
get fields() {
|
||||
return ['path'].map((f) => this.allByKey[f]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,11 @@
|
|||
|
||||
import ApplicationSerializer from './application';
|
||||
|
||||
export default ApplicationSerializer.extend({
|
||||
export default class NamespaceSerializer extends ApplicationSerializer {
|
||||
attrs = {
|
||||
path: { serialize: false },
|
||||
};
|
||||
|
||||
normalizeList(payload) {
|
||||
const data = payload.data.keys
|
||||
? payload.data.keys.map((key) => ({
|
||||
|
@ -16,7 +20,7 @@ export default ApplicationSerializer.extend({
|
|||
: payload.data;
|
||||
|
||||
return data;
|
||||
},
|
||||
}
|
||||
|
||||
normalizeResponse(store, primaryModelClass, payload, id, requestType) {
|
||||
const nullResponses = ['deleteRecord', 'createRecord'];
|
||||
|
@ -24,6 +28,6 @@ export default ApplicationSerializer.extend({
|
|||
const normalizedPayload = nullResponses.includes(requestType)
|
||||
? { id: cid, path: cid }
|
||||
: this.normalizeList(payload);
|
||||
return this._super(store, primaryModelClass, normalizedPayload, id, requestType);
|
||||
},
|
||||
});
|
||||
return super.normalizeResponse(store, primaryModelClass, normalizedPayload, id, requestType);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
{{#let (concat this.currentNamespace (if this.currentNamespace "/") list.item.id) as |targetNamespace|}}
|
||||
{{#if (includes targetNamespace this.accessibleNamespaces)}}
|
||||
<li class="action">
|
||||
<NamespaceLink @targetNamespace={{targetNamespace}} @class="is-block">
|
||||
<NamespaceLink @targetNamespace={{targetNamespace}} @unparsed={{true}} @class="is-block">
|
||||
Switch to Namespace
|
||||
</NamespaceLink>
|
||||
</li>
|
||||
|
|
Loading…
Reference in New Issue