Allow run_as to be arbitrary string to support patterns and unknown users (#32779) (#33205)

This commit is contained in:
Brandon Kobel 2019-03-14 10:48:26 -07:00 committed by GitHub
parent a7e0743028
commit 2d1408f080
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View file

@ -115,6 +115,7 @@ exports[`it renders without crashing 1`] = `
isClearable={true}
isDisabled={false}
onChange={[Function]}
onCreateOption={[Function]}
options={Array []}
placeholder="Add a user…"
selectedOptions={Array []}

View file

@ -133,6 +133,7 @@ export class ElasticsearchPrivileges extends Component<Props, {}> {
isGroupLabelOption: false,
}))}
selectedOptions={this.props.role.elasticsearch.run_as.map(u => ({ label: u }))}
onCreateOption={this.onCreateRunAsOption}
onChange={this.onRunAsUserChange}
isDisabled={!this.props.editable}
/>
@ -231,4 +232,17 @@ export class ElasticsearchPrivileges extends Component<Props, {}> {
this.props.onChange(role);
};
public onCreateRunAsOption = (option: any) => {
const newRunAsUsers = this.props.role.elasticsearch.run_as.concat(option);
const role = {
...this.props.role,
elasticsearch: {
...this.props.role.elasticsearch,
run_as: newRunAsUsers,
},
};
this.props.onChange(role);
};
}