-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Feature Controls - Reserved Role Apps #30525
Changes from 66 commits
8ae173a
49b39ce
b36b1b2
34aee5a
b210249
0d67f4d
5e6e1ce
6708214
df12744
fb369ce
951ceb3
92e7e0b
3828811
a78bfe7
392819b
c0477ae
8649157
132e7f4
2912e7b
dbe36f6
2044ccd
1ef0d2c
46a023d
7fe8e30
03bb72c
cb19823
d9e38b9
e467f1b
d6031f3
908a364
c1634bb
5396c6f
13572f3
b250672
f3d8376
0693a06
71785e4
cd3b11a
c6a5570
b3a048e
6c28a1e
db19c22
50b5ddd
10bbc4e
f724694
fa44f66
1e4ca00
3a5033b
03ee483
0671209
b71cd27
c833a41
11ed79a
13f8831
3f75085
031d1fa
0b265c3
736712f
1a495fd
70a9ffc
b7ac747
92efdb0
7567c9a
8c124cb
d98c6ca
61ed5b1
accf3e8
6dbe5c2
5609563
1f3e709
a040191
2c5ab8f
773a308
951b4f5
5cdc103
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,14 +61,32 @@ export class FeatureTable extends Component<Props, {}> { | |
public render() { | ||
const { role, features, calculatedPrivileges, rankedFeaturePrivileges } = this.props; | ||
|
||
const items: TableRow[] = features.map(feature => ({ | ||
feature: { | ||
...feature, | ||
hasAnyPrivilegeAssigned: | ||
calculatedPrivileges.feature[feature.id].actualPrivilege !== NO_PRIVILEGE_VALUE, | ||
}, | ||
role, | ||
})); | ||
const items: TableRow[] = features | ||
.sort((feature1, feature2) => { | ||
if (feature1.reserved && !feature2.reserved) { | ||
return 1; | ||
} | ||
|
||
if (feature2.reserved && !feature1.reserved) { | ||
return -1; | ||
} | ||
|
||
return 0; | ||
}) | ||
.map(feature => { | ||
const calculatedFeaturePrivileges = calculatedPrivileges.feature[feature.id]; | ||
const hasAnyPrivilegeAssigned = Boolean( | ||
calculatedFeaturePrivileges && | ||
calculatedFeaturePrivileges.actualPrivilege !== NO_PRIVILEGE_VALUE | ||
); | ||
return { | ||
feature: { | ||
...feature, | ||
hasAnyPrivilegeAssigned, | ||
}, | ||
role, | ||
}; | ||
}); | ||
|
||
// TODO: This simply grabs the available privileges from the first feature we encounter. | ||
// As of now, features can have 'all' and 'read' as available privileges. Once that assumption breaks, | ||
|
@@ -147,13 +165,17 @@ export class FeatureTable extends Component<Props, {}> { | |
</span> | ||
), | ||
render: (roleEntry: Role, record: TableRow) => { | ||
const featureId = record.feature.id; | ||
const { id: featureId, reserved } = record.feature; | ||
|
||
if (reserved) { | ||
return <EuiText size={'s'}>{reserved.description}</EuiText>; | ||
} | ||
|
||
const featurePrivileges = this.props.kibanaPrivileges | ||
.getFeaturePrivileges() | ||
.getPrivileges(featureId); | ||
|
||
if (!featurePrivileges) { | ||
if (featurePrivileges.length === 0) { | ||
return null; | ||
} | ||
|
||
|
@@ -213,18 +235,32 @@ export class FeatureTable extends Component<Props, {}> { | |
return featurePrivileges; | ||
} | ||
|
||
return allowedPrivileges.feature[featureId].privileges; | ||
const allowedFeaturePrivileges = allowedPrivileges.feature[featureId]; | ||
if (allowedFeaturePrivileges == null) { | ||
throw new Error('Unable to get enabled feature privileges for a feature without privileges'); | ||
legrego marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
return allowedFeaturePrivileges.privileges; | ||
}; | ||
|
||
private getPrivilegeExplanation = (featureId: string): PrivilegeExplanation => { | ||
const { calculatedPrivileges } = this.props; | ||
const calculatedFeaturePrivileges = calculatedPrivileges.feature[featureId]; | ||
if (calculatedFeaturePrivileges == null) { | ||
throw new Error('Unable to get privilege explanation for a feature without privileges'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question here w/r/t throwing |
||
} | ||
|
||
return calculatedPrivileges.feature[featureId]; | ||
return calculatedFeaturePrivileges; | ||
}; | ||
|
||
private allowsNoneForPrivilegeAssignment = (featureId: string): boolean => { | ||
const { allowedPrivileges } = this.props; | ||
return allowedPrivileges.feature[featureId].canUnassign; | ||
const allowedFeaturePrivileges = allowedPrivileges.feature[featureId]; | ||
if (allowedFeaturePrivileges == null) { | ||
throw new Error('Unable to determine if none is allowed for a feature without privileges'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question here w/r/t throwing |
||
} | ||
|
||
return allowedFeaturePrivileges.canUnassign; | ||
}; | ||
|
||
private onChangeAllFeaturePrivileges = (privilege: string) => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: stray debug code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can probably remove this, I had CI not run from source during a run or two and forcing this in there made it work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unfortunately required at the moment to get CI to run from source, I've talked to Tyler and we're trying to track down where this bug is.