Use isUserAuthorized helper
parent
1844f7185f
commit
6210b05c1d
|
@ -8,12 +8,12 @@ import TemplateControlDropdown from 'src/dashboards/components/TemplateControlDr
|
||||||
import {Template} from 'src/types/dashboard'
|
import {Template} from 'src/types/dashboard'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
meRole: string
|
||||||
|
isUsingAuth: boolean
|
||||||
templates: Template[]
|
templates: Template[]
|
||||||
isOpen: boolean
|
isOpen: boolean
|
||||||
onOpenTemplateManager: () => void
|
onOpenTemplateManager: () => void
|
||||||
onSelectTemplate: (id: string) => void
|
onSelectTemplate: (id: string) => void
|
||||||
meRole: string
|
|
||||||
isUsingAuth: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const TemplateControlBar: SFC<Props> = ({
|
const TemplateControlBar: SFC<Props> = ({
|
||||||
|
|
|
@ -2,9 +2,9 @@ import React, {SFC} from 'react'
|
||||||
|
|
||||||
import Dropdown from 'src/shared/components/Dropdown'
|
import Dropdown from 'src/shared/components/Dropdown'
|
||||||
import {calculateDropdownWidth} from 'src/dashboards/constants/templateControlBar'
|
import {calculateDropdownWidth} from 'src/dashboards/constants/templateControlBar'
|
||||||
|
import {isUserAuthorized, EDITOR_ROLE} from 'src/auth/Authorized'
|
||||||
import {Template} from 'src/types/dashboard'
|
import {Template} from 'src/types/dashboard'
|
||||||
|
|
||||||
export const VIEWER_ROLE = 'viewer'
|
|
||||||
interface Props {
|
interface Props {
|
||||||
template: Template
|
template: Template
|
||||||
meRole: string
|
meRole: string
|
||||||
|
@ -42,7 +42,7 @@ const TemplateControlDropdown: SFC<Props> = ({
|
||||||
menuClass="dropdown-astronaut"
|
menuClass="dropdown-astronaut"
|
||||||
useAutoComplete={true}
|
useAutoComplete={true}
|
||||||
selected={selectedItem.text}
|
selected={selectedItem.text}
|
||||||
disabled={isUsingAuth && (!meRole || meRole === VIEWER_ROLE)}
|
disabled={!isUsingAuth || !isUserAuthorized(meRole, EDITOR_ROLE)}
|
||||||
onChoose={onSelectTemplate(template.id)}
|
onChoose={onSelectTemplate(template.id)}
|
||||||
/>
|
/>
|
||||||
<label className="template-control--label">{template.tempVar}</label>
|
<label className="template-control--label">{template.tempVar}</label>
|
||||||
|
|
|
@ -13,6 +13,8 @@ const defaultProps = {
|
||||||
values: [{value: 'firstValue'}, {value: 'secondValue'}],
|
values: [{value: 'firstValue'}, {value: 'secondValue'}],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
meRole: 'EDITOR',
|
||||||
|
isUsingAuth: true,
|
||||||
onOpenTemplateManager: () => {},
|
onOpenTemplateManager: () => {},
|
||||||
onSelectTemplate: () => {},
|
onSelectTemplate: () => {},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue