Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 73 additions & 20 deletions app/components/form-scoped-roles/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,71 @@ export default Component.extend(NewOrEdit,{
admin: null,
principal: null,

init() {
this._super(...arguments);

let dfu = get(this, 'defaultUser');
let model = {
type: `${get(this, 'type')}RoleTemplateBinding`,
};

set(model, `${get(this, 'type')}Id`, get(this, `model.${get(this, 'type')}.id`))

setProperties(this, {
primaryResource: this.make(model),
defaultUser: dfu,
stdUser: `${get(this, 'type')}-member`,
admin: `${get(this, 'type')}-owner`,
cTyped: get(this, 'type').capitalize(),
});
},

showAdmin: computed('[email protected]', 'mode', function() {
const id = `${get(this, 'type')}-owner`;
const role = get(this, 'model.roles').findBy('id', id);

if ( get(this, 'mode') === id ) {
return true;
}

if ( role && get(role,'locked') !== true ) {
return true;
}

return false;
}),

showStdUser: computed('[email protected]', 'mode', function() {
const id = `${get(this, 'type')}-member`;
const role = get(this, 'model.roles').findBy('id', id);

if ( get(this, 'mode') === id ) {
return true;
}

if ( role && get(role,'locked') !== true ) {
return true;
}

return false;
}),

showReadOnly: computed('[email protected]', 'mode', function() {
const id = 'read-only';
const role = get(this, 'model.roles').findBy('id', id);

if ( get(this, 'mode') === id ) {
return true;
}

if ( role && get(role,'locked') !== true ) {
return true;
}

return false;
}),


baseRoles: computed(function () {
return [
`${get(this, 'type')}-admin`,
Expand All @@ -32,6 +97,7 @@ export default Component.extend(NewOrEdit,{
'read-only'
];
}),

userRoles: computed('model.roles.[]', function() {
let roles = get(this, 'model.roles');
let current = get(this, 'defaultUser').get(`${get(this, 'type')}RoleBindings`);
Expand Down Expand Up @@ -82,7 +148,13 @@ export default Component.extend(NewOrEdit,{
} else if (editing && current.length > 1){
mode = CUSTOM;
} else {
mode = `${get(this, 'type')}-member`;
const id = `${get(this, 'type')}-member`;
const role = get(this, 'model.roles').findBy('id', id);
if ( role && get(role, 'locked') !== true ) {
mode = `${get(this, 'type')}-member`;
} else {
mode = CUSTOM;
}
}

return mode;
Expand All @@ -103,25 +175,6 @@ export default Component.extend(NewOrEdit,{
},
}),

init() {
this._super(...arguments);

let dfu = get(this, 'defaultUser');
let model = {
type: `${get(this, 'type')}RoleTemplateBinding`,
};

set(model, `${get(this, 'type')}Id`, get(this, `model.${get(this, 'type')}.id`))

setProperties(this, {
primaryResource: this.make(model),
defaultUser: dfu,
stdUser: `${get(this, 'type')}-member`,
admin: `${get(this, 'type')}-owner`,
cTyped: get(this, 'type').capitalize()
});
},

make(role) {
return get(this, 'globalStore').createRecord(role);
},
Expand Down
33 changes: 20 additions & 13 deletions app/components/form-scoped-roles/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,33 @@
expandOnInit=true
showExpand=false
}}
<div class="radio">
<label>
{{radio-button selection=mode value=admin}} {{t 'formScopedRoles.mode.admin.label'}}
<p class="help-block">{{t 'formScopedRoles.mode.admin.detail' type=cTyped}}</p>
</label>
</div>
<div class="radio">
<label>
{{radio-button selection=mode value=stdUser}} {{t 'formScopedRoles.mode.user.label'}}
<p class="help-block">{{t 'formScopedRoles.mode.user.detail' type=cTyped}}</p>
</label>
</div>
{{#if (eq type 'project')}}
{{#if showAdmin}}
<div class="radio">
<label>
{{radio-button selection=mode value=admin}} {{t 'formScopedRoles.mode.admin.label'}}
<p class="help-block">{{t 'formScopedRoles.mode.admin.detail' type=cTyped}}</p>
</label>
</div>
{{/if}}

{{#if showStdUser}}
<div class="radio">
<label>
{{radio-button selection=mode value=stdUser}} {{t 'formScopedRoles.mode.user.label'}}
<p class="help-block">{{t 'formScopedRoles.mode.user.detail' type=cTyped}}</p>
</label>
</div>
{{/if}}

{{#if (and showReadOnly (eq type 'project'))}}
<div class="radio">
<label>
{{radio-button selection=mode value="read-only"}} {{t 'formScopedRoles.mode.readOnly.label'}}
<p class="help-block">{{t 'formScopedRoles.mode.readOnly.detail' type=cTyped}}</p>
</label>
</div>
{{/if}}

{{#each userRoles as |role| }}
<div class="radio">
<label>
Expand Down
42 changes: 23 additions & 19 deletions lib/shared/addon/components/project-member-row/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ const BASIC_ROLES = [
{
label: 'Owner',
value: 'owner',
typePrefix: true,
},
{
label: 'Member',
value: 'member',
typePrefix: true,
},
{
label: 'Read Only',
Expand All @@ -23,6 +25,7 @@ const BASIC_ROLES = [
{
label: 'Custom',
value: 'custom',
virtual: true,
},
];

Expand Down Expand Up @@ -178,45 +181,46 @@ export default Component.extend({
}),

choices: computed('roles.[]', 'pageType', function() {
let pt = get(this, 'pageType');
const pt = get(this, 'pageType');
const allRoles = get(this, 'globalStore').all('roleTemplate');

let neuRoles = BASIC_ROLES.map((r) => {

let val = '';

if ( r.value.indexOf('custom') >= 0 ) {
val = 'custom';

} else {
if (r.value === 'read-only') {
val = r.value;
} else {
val = `${pt}-${r.value}`;
const id = (r.typePrefix ? `${pt}-${r.value}` : r.value);
const rt = allRoles.findBy('id', id )

// If it's a real entry (i.e. not "custom")
if ( !r.virtual ) {
// And there's no corresponding role, or there is one but it's locked
if (!rt || get(rt, 'locked') === true) {
// And it's not the currently selected role
if ( id !== get(this, 'roleTemplateId') ) {
// Hide this entry (return nothing instead of a row)
return;
}
}
}

return {
label: r.label,
value: val,
value: id,
};

});

if (pt) {
if ( pt ) {
let customRoles = get(this, 'customRoles').map( r => {
if (r.id !== 'read-only') {
if (r.id === 'read-only') {
return;
} else {
return {
label: r.name,
value: r.id
}
} else {
return;
}
});

neuRoles = neuRoles.concat(customRoles);

return neuRoles;
return neuRoles.filter(x => !!x);
}

return neuRoles;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ui",
"version": "2.0.44",
"version": "2.0.45",
"private": true,
"directories": {
"doc": "doc",
Expand Down
24 changes: 20 additions & 4 deletions scripts/build-static
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ if ( [[ $TAG -eq 1 ]] || [[ $UPLOAD -ne 0 ]] ) && [[ "${BRANCH}" != "master" ]];
fi
fi

REMOTE=$(git config --get remote.origin.url)
if [[ $TAG -eq 1 ]] && [[ ! "${REMOTE}" =~ .*rancher/ui.* ]]; then
echo "You can only tag when origin is the main rancher/ui repo (you are on '${REMOTE}')."
if [[ $FORCE -ne 1 ]]; then
exit 1;
fi
fi

if [[ "${FORCE_VERSION}" != "" ]]; then
VERSION=${FORCE_VERSION}
else
Expand All @@ -153,6 +161,14 @@ if [[ $LATEST -eq 1 ]]; then
FINGERPRINT="no"
fi

EXISTING=$(git tag -l "v${VERSION}")
if [[ $TAG -eq 1 ]] && [[ "${EXISTING}" = "v${VERSION}" ]]; then
echo "There is already an existing tag v${VERSION}"
if [[ $FORCE -ne 1 ]]; then
exit 1;
fi
fi

BUILD_PAR="dist/static"
BUILD_DIR="${BUILD_PAR}/${VERSION}"
BUILD_TGZ="${BUILD_PAR}/${VERSION}.tar.gz"
Expand Down Expand Up @@ -197,10 +213,10 @@ UI_MODE="${MODE}" FINGERPRINT="${FINGERPRINT}" RANCHER="" CATALOG="" BASE_ASSETS
# Create a file containing the version
echo "${PKG_VERSION}" > ${BUILD_DIR}/VERSION.txt

#if [[ $TAG -eq 1 ]]; then
#runCmd git tag v${VERSION}
#runCmd git push --tags
#fi
if [[ $TAG -eq 1 ]]; then
runCmd git tag v${VERSION}
runCmd git push --tags
fi

# Upload asset, either from laptop or from CI pipeline
if [[ -n "$UPLOAD" ]]; then
Expand Down