From 4b421e2649d99b9e12b2836fb12c07dc596ad014 Mon Sep 17 00:00:00 2001 From: loganhz Date: Thu, 30 Nov 2017 14:52:21 +0800 Subject: [PATCH] Support FS Group policy --- .../form-fsgroup-policy/component.js | 57 +++++++++++++++++++ .../form-fsgroup-policy/template.hbs | 56 ++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 lib/global-admin/addon/components/form-fsgroup-policy/component.js create mode 100644 lib/global-admin/addon/components/form-fsgroup-policy/template.hbs diff --git a/lib/global-admin/addon/components/form-fsgroup-policy/component.js b/lib/global-admin/addon/components/form-fsgroup-policy/component.js new file mode 100644 index 000000000..e5a0d428a --- /dev/null +++ b/lib/global-admin/addon/components/form-fsgroup-policy/component.js @@ -0,0 +1,57 @@ +import Component from '@ember/component'; +import { inject as service } from '@ember/service'; +import layout from './template'; + +export default Component.extend({ + layout, + + classNames: ['accordion-wrapper'], + + authzStore: service('authz-store'), + + model: null, + + init() { + this._super(...arguments); + this.set('model.fsGroup', this.get('model.fsGroup') || this.get('authzStore').createRecord({ + type: 'fsGroupStrategyOptions', + rule: 'RunAsAny', + })); + }, + + actions: { + add: function() { + this.get('model.fsGroup.ranges').pushObject( + this.get('authzStore').createRecord({ + type: 'idRange', + min: 0, + max: 6, + }) + ); + }, + remove: function(obj) { + this.get('model.fsGroup.ranges').removeObject(obj); + }, + }, + + ruleDidChange: function() { + const rule = this.get('model.fsGroup.rule'); + if (rule === 'MustRunAs') { + this.set('model.fsGroup.ranges', []); + this.send('add'); + } else { + this.set('model.fsGroup.ranges', null); + } + }.observes('model.fsGroup.rule'), + + didReceiveAttrs() { + if (!this.get('expandFn')) { + this.set('expandFn', function (item) { + item.toggleProperty('expanded'); + }); + } + }, + + statusClass: null, + status: null, +}); diff --git a/lib/global-admin/addon/components/form-fsgroup-policy/template.hbs b/lib/global-admin/addon/components/form-fsgroup-policy/template.hbs new file mode 100644 index 000000000..23dc5ffe9 --- /dev/null +++ b/lib/global-admin/addon/components/form-fsgroup-policy/template.hbs @@ -0,0 +1,56 @@ +{{#accordion-list-item + title=(t 'formFsGroupPodSecurityPolicy.title') + detail=(t 'formFsGroupPodSecurityPolicy.detail') + status=status + statusClass=statusClass + expandAll=expandAll + expand=(action expandFn) +}} +
+
+ +
+
+ +
+
+ + {{#if (eq model.fsGroup.rule "MustRunAs")}} +
+
+ +
+ + {{#if (eq model.fsGroup.rule "MustRunAs")}} + + + + + + + + {{#each model.fsGroup.ranges as |range|}} + + + + + + + {{/each}} +
+ {{input class="form-control input-sm" type="number" value=range.min placeholder=(t 'formFsGroupPodSecurityPolicy.range.min.placeholder')}} + +

+
+ {{input class="form-control input-sm" type="number" value=range.max placeholder=(t 'formFsGroupPodSecurityPolicy.range.max.placeholder')}} + + +
+ {{/if}} +
+ {{/if}} + +{{/accordion-list-item}}