-
Notifications
You must be signed in to change notification settings - Fork 900
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(core): reactify pipelineRoles component (#7104)
- Loading branch information
Jammy Louie
committed
Jun 11, 2019
1 parent
be14551
commit a3e678e
Showing
6 changed files
with
61 additions
and
48 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
app/scripts/modules/core/src/pipeline/config/triggers/PipelineRoles.tsx
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import * as React from 'react'; | ||
import Select, { Option } from 'react-select'; | ||
|
||
import { AuthenticationService } from 'core/authentication'; | ||
import { HelpField } from 'core/help'; | ||
|
||
const { useState, useEffect } = React; | ||
|
||
export interface IPipelineRolesConfigProps { | ||
roles: any[]; | ||
updateRoles: (roles: string[]) => void; | ||
} | ||
|
||
export const PipelineRoles = (props: IPipelineRolesConfigProps) => { | ||
const [allowedRoles, setAllowedRoles] = useState([]); | ||
|
||
useEffect(() => { | ||
setAllowedRoles(AuthenticationService.getAuthenticatedUser().roles); | ||
}, []); | ||
|
||
const onAllowedRolesChanged = (options: Array<Option<string>>) => { | ||
const roles = options.map(o => o.value); | ||
props.updateRoles(roles); | ||
}; | ||
|
||
return ( | ||
<div className="form-group row"> | ||
<div className="col-md-10"> | ||
<div className="row"> | ||
<label className="col-md-3 sm-label-right"> | ||
<span>Permissions </span> | ||
<HelpField id="pipeline.config.roles.help" /> | ||
</label> | ||
<div className="col-md-9"> | ||
<Select | ||
multi={true} | ||
onChange={onAllowedRolesChanged} | ||
options={allowedRoles.map(a => ({ label: a, value: a }))} | ||
value={props.roles || []} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
45 changes: 0 additions & 45 deletions
45
app/scripts/modules/core/src/pipeline/config/triggers/pipelineRoles.component.ts
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
app/scripts/modules/core/src/pipeline/config/triggers/pipelineRoles.module.ts
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { module } from 'angular'; | ||
import { react2angular } from 'react2angular'; | ||
|
||
import { PipelineRoles } from './PipelineRoles'; | ||
|
||
export const PIPELINE_ROLES = 'spinnaker.core.pipeline.roles.component'; | ||
module(PIPELINE_ROLES, []).component('pipelineRoles', react2angular(PipelineRoles, ['roles', 'updateRoles'])); |
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