mirror of https://github.com/rancher/ui.git
refactor cru-registry ns save logic
Not sure this every put registry secrets into the desired namespace. The `namespaceId` was never set on the primaryResource by the namespace components, rather those components worked on a namespace object. Ive gotten rid of `namespaceId` and refactored to use the namespace object in its place. rancher/rancher#26813
This commit is contained in:
parent
d0d790681a
commit
a436bcc828
|
|
@ -7,6 +7,8 @@ import { PRESETS_BY_NAME } from 'ui/models/dockercredential';
|
||||||
import { inject as service } from '@ember/service'
|
import { inject as service } from '@ember/service'
|
||||||
import { isEmpty } from '@ember/utils';
|
import { isEmpty } from '@ember/utils';
|
||||||
|
|
||||||
|
const TEMP_NAMESPACE_ID = '__TEMP__';
|
||||||
|
|
||||||
export default Component.extend(ViewNewEdit, OptionallyNamespaced, {
|
export default Component.extend(ViewNewEdit, OptionallyNamespaced, {
|
||||||
globalStore: service(),
|
globalStore: service(),
|
||||||
clusterStore: service(),
|
clusterStore: service(),
|
||||||
|
|
@ -82,16 +84,15 @@ export default Component.extend(ViewNewEdit, OptionallyNamespaced, {
|
||||||
hostname: window.location.host,
|
hostname: window.location.host,
|
||||||
|
|
||||||
willSave() {
|
willSave() {
|
||||||
let pr = get(this, 'primaryResource');
|
const {
|
||||||
|
namespace: { id: nsId },
|
||||||
|
primaryResource: pr,
|
||||||
|
} = this;
|
||||||
|
|
||||||
// Namespace is required, but doesn't exist yet... so lie to the validator
|
set(pr, 'namespaceId', nsId ? nsId : TEMP_NAMESPACE_ID);
|
||||||
let nsId = get(pr, 'namespaceId');
|
|
||||||
|
|
||||||
set(pr, 'namespaceId', '__TEMP__');
|
|
||||||
let ok = this.validate();
|
let ok = this.validate();
|
||||||
|
|
||||||
set(pr, 'namespaceId', nsId);
|
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -111,13 +112,11 @@ export default Component.extend(ViewNewEdit, OptionallyNamespaced, {
|
||||||
doSave() {
|
doSave() {
|
||||||
let self = this;
|
let self = this;
|
||||||
let sup = self._super;
|
let sup = self._super;
|
||||||
const currentProjectsNamespace = get(this, 'clusterStore').all('namespace').findBy('projectId', get(this, 'scopeService.currentProject.id'));
|
const { primaryResource: { namespaceId } } = this;
|
||||||
|
|
||||||
if (isEmpty(currentProjectsNamespace)) {
|
if (isEmpty(namespaceId) || namespaceId === TEMP_NAMESPACE_ID) {
|
||||||
return this.namespacePromise().then(() => sup.apply(self, arguments));
|
return this.namespacePromise().then(() => sup.apply(self, arguments));
|
||||||
} else {
|
} else {
|
||||||
set(this, 'namespace', currentProjectsNamespace);
|
|
||||||
|
|
||||||
return sup.apply(self, arguments);
|
return sup.apply(self, arguments);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue