Skip to content

Commit

Permalink
edit ember-can to add additional attribute for namespace
Browse files Browse the repository at this point in the history
We wanted the ability to get our namespace from query params
in order to do this, we're using additional attributes via
ember-can to set a bound property directly from our
handlebar file. This sets us up better in the event that
the namespace filter changes on the UI because our handlebar
file will be aware of the change, whereas our ability may not
update as the namespace filter updates.
  • Loading branch information
ChaiWithJai committed Jul 13, 2021
1 parent f453e48 commit d8bef7b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 0 additions & 4 deletions ui/app/abilities/abstract.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ export default class Abstract extends Ability {
@not('token.aclEnabled') bypassAuthorization;
@equal('token.selfToken.type', 'management') selfTokenIsManagement;

// Pass in a namespace to `can` or `cannot` calls to override
// https://github.com/minutebase/ember-can#additional-attributes
namespace = 'default';

get _namespace() {
if (!this.namespace) return 'default';
if (typeof this.namespace === 'string') return this.namespace;
Expand Down
4 changes: 2 additions & 2 deletions ui/app/templates/jobs/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</div>
{{#if (media "isMobile")}}
<div class="toolbar-item is-right-aligned">
{{#if (can "run job")}}
{{#if (can "run job" namespace=this.qpNamespace)}}
<LinkTo @route="jobs.run" data-test-run-job class="button is-primary">Run Job</LinkTo>
{{else}}
<button
Expand Down Expand Up @@ -66,7 +66,7 @@
</div>
{{#if (not (media "isMobile"))}}
<div class="toolbar-item is-right-aligned">
{{#if (can "run job")}}
{{#if (can "run job" namespace=this.qpNamespace)}}
<LinkTo @route="jobs.run" data-test-run-job class="button is-primary">Run Job</LinkTo>
{{else}}
<button
Expand Down

0 comments on commit d8bef7b

Please sign in to comment.