From 693fc5cb8fe25cfcf8a52350c70ff54bf7178d54 Mon Sep 17 00:00:00 2001 From: loganhz Date: Thu, 20 Sep 2018 16:51:04 +0800 Subject: [PATCH] hasOnwer check https://github.com/rancher/rancher/issues/15475 --- .../addon/components/form-members/component.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/shared/addon/components/form-members/component.js b/lib/shared/addon/components/form-members/component.js index 35cdf7660..ac4410a19 100644 --- a/lib/shared/addon/components/form-members/component.js +++ b/lib/shared/addon/components/form-members/component.js @@ -175,7 +175,7 @@ export default Component.extend({ } }); - if (get(this, 'isNew') || this.hasOwner()) { + if (get(this, 'isNew') || this.useCustomizedOwner() || this.hasOwner()) { return PromiseAll(add.map((x) => x.save())).then(() => { return PromiseAll(update.map((x) => x.save())).then(() => { return PromiseAll(remove.map((x) => x.delete())).then(() => { @@ -196,6 +196,19 @@ export default Component.extend({ } }, + useCustomizedOwner() { + const roles = get(this, 'roles') || []; + const context = get(this, 'primaryResource.type'); + const ownerRole = roles.findBy('id', `${ context }-owner`); + const defaultRoles = roles.filterBy(`${ context }CreatorDefault`, true); + + if ( ownerRole && !get(ownerRole, 'locked') && get(ownerRole, `${ context }CreatorDefault`) && get(defaultRoles, 'length') === 1 ){ + return false; + } else { + return true; + } + }, + hasOwner() { let memberArray = get(this, 'memberArray'); let matches = [];