Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: Fix ember-can #12505

Merged
merged 4 commits into from
Mar 11, 2022
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
3 changes: 0 additions & 3 deletions ui/packages/consul-ui/app/abilities/license.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@ import BaseAbility from './base';
export default class LicenseAbility extends BaseAbility {
resource = 'operator';
segmented = false;
get is() {
return this.read;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BaseAbility from './base';

export default class ServiceAbility extends BaseAbility {
export default class ZerviceAbility extends BaseAbility {
resource = 'service';

get isLinkable() {
Expand Down
9 changes: 9 additions & 0 deletions ui/packages/consul-ui/app/helpers/can.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Helper from 'ember-can/helpers/can';

export default class extends Helper {
_addAbilityObserver(ability, propertyName) {
if(!this.isDestroyed && !this.isDestroying) {
super._addAbilityObserver(...arguments);
}
}
}
4 changes: 2 additions & 2 deletions ui/packages/consul-ui/app/helpers/is.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { get } from '@ember/object';

import { camelize } from '@ember/string';
export const is = (helper, [abilityString, model], properties) => {
let { abilityName, propertyName } = helper.can.parse(abilityString);
let ability = helper.can.abilityFor(abilityName, model, properties);
let { abilityName, propertyName } = helper.abilities.parse(abilityString);
let ability = helper.abilities.abilityFor(abilityName, model, properties);

if(typeof ability.getCharacteristicProperty === 'function') {
propertyName = ability.getCharacteristicProperty(propertyName);
Expand Down
4 changes: 2 additions & 2 deletions ui/packages/consul-ui/app/helpers/test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Helper from 'ember-can/helpers/can';
import { is } from 'consul-ui/helpers/is';
import Helper from './can';
import { is } from './is';

export default class extends Helper {
compute([abilityString, model], properties) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Service from 'ember-can/services/can';

export default class CanService extends Service {
export default class AbilitiesService extends Service {
parse(str) {
// It's nicer to talk about SSO but technically its part of the authMethod
// ability, we probably only need 'use SSO' but if we need more, reassess
// the `replace`
return super.parse(str.replace('use SSO', 'use authMethods'));
return super.parse(str.replace('use SSO', 'use authMethods').replace('service', 'zervice'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const REQUIRED_PERMISSIONS = [
];
export default class PermissionService extends RepositoryService {
@service('env') env;
@service('can') _can;
@service('abilities') _can;

// TODO: move this to the store, if we want it to use ember-data
// currently this overwrites an inherited permissions service (this service)
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/consul-ui/app/templates/dc/show.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ as |route|>
href=(href-to 'dc.show.health')
selected=(is-href 'dc.show.health')
)
(if (and (is 'license') (not (is 'hcp')))
(if (and (can 'read license') (not (is 'hcp')))
(hash
label=(compute (fn route.t 'license.title'))
href=(href-to 'dc.show.license')
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/consul-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"deepmerge": "^4.2.2",
"ember-assign-helper": "^0.3.0",
"ember-auto-import": "^1.5.3",
"ember-can": "^3.0.0",
"ember-can": "^4.1.0",
"ember-changeset-conditional-validations": "^0.6.0",
"ember-changeset-validations": "~3.9.0",
"ember-cli": "~3.20.2",
Expand Down
952 changes: 942 additions & 10 deletions ui/yarn.lock

Large diffs are not rendered by default.