-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bugfix, ui] Allow running jobs from a namespace-limited token (#13659)
* Allow running jobs from a namespace-limited token * qpNamespace cleanup * Looks like parse can deal with a * namespace * A little diff cleanup * Defensive destructuring * Removing accidental friendly-fire on can-scale * Testfix: Job run buttons from jobs index * Testfix: activeRegion job adapter string * Testfix: unit tests for job abilities correctly reflect the any-namespace rule * Testfix: job editor test looks for requests with namespace applied on plan
- Loading branch information
1 parent
596203c
commit 6d3e807
Showing
7 changed files
with
73 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import AbstractAbility from './abstract'; | ||
import { computed } from '@ember/object'; | ||
import { computed, get } from '@ember/object'; | ||
import { or } from '@ember/object/computed'; | ||
|
||
export default class Job extends AbstractAbility { | ||
|
@@ -9,7 +9,7 @@ export default class Job extends AbstractAbility { | |
@or( | ||
'bypassAuthorization', | ||
'selfTokenIsManagement', | ||
'policiesSupportRunning', | ||
'specificNamespaceSupportsRunning', | ||
'policiesSupportScaling' | ||
) | ||
canScale; | ||
|
@@ -27,8 +27,34 @@ export default class Job extends AbstractAbility { | |
) | ||
canDispatch; | ||
|
||
@computed('[email protected]') | ||
policyNamespacesIncludePermissions(policies = [], permissions = []) { | ||
// For each policy record, extract all policies of all namespaces | ||
const allNamespacePolicies = policies | ||
.toArray() | ||
.map((policy) => get(policy, 'rulesJSON.Namespaces')) | ||
.flat() | ||
.map((namespace = {}) => { | ||
return namespace.Capabilities; | ||
}) | ||
.flat() | ||
.compact(); | ||
|
||
// Check for requested permissions | ||
return allNamespacePolicies.some((policy) => { | ||
return permissions.includes(policy); | ||
}); | ||
} | ||
|
||
@computed('token.selfTokenPolicies.[]') | ||
get policiesSupportRunning() { | ||
return this.policyNamespacesIncludePermissions( | ||
this.token.selfTokenPolicies, | ||
['submit-job'] | ||
); | ||
} | ||
|
||
@computed('[email protected]') | ||
get specificNamespaceSupportsRunning() { | ||
return this.namespaceIncludesCapability('submit-job'); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters