select refactor fixes

pull/14500/head
Torkel Ödegaard 7 years ago
parent ae76ddcc3b
commit cb7ffb4415
  1. 1
      public/app/core/components/PermissionList/AddPermission.tsx
  2. 3
      public/app/core/components/PermissionList/DisabledPermissionListItem.tsx
  3. 3
      public/app/core/components/PermissionList/PermissionListItem.tsx
  4. 2
      public/app/core/components/Select/DataSourcePicker.tsx
  5. 2
      public/app/core/components/Select/Select.tsx
  6. 20
      public/app/core/components/Select/TeamPicker.tsx

@ -122,6 +122,7 @@ class AddPermissions extends Component<Props, NewDashboardAclItem> {
<div className="gf-form">
<Select
isSearchable={false}
options={dashboardPermissionLevels}
onChange={this.onPermissionChanged}
className="gf-form-select-box__control--menu-right"

@ -9,6 +9,7 @@ export interface Props {
export default class DisabledPermissionListItem extends Component<Props, any> {
render() {
const { item } = this.props;
const currentPermissionLevel = dashboardPermissionLevels.find(dp => dp.value === item.permission);
return (
<tr className="gf-form-disabled">
@ -28,7 +29,7 @@ export default class DisabledPermissionListItem extends Component<Props, any> {
onChange={() => {}}
isDisabled={true}
className="gf-form-select-box__control--menu-right"
value={item.permission}
value={currentPermissionLevel}
/>
</div>
</td>

@ -50,6 +50,7 @@ export default class PermissionsListItem extends PureComponent<Props> {
render() {
const { item, folderInfo } = this.props;
const inheritedFromRoot = item.dashboardId === -1 && !item.inherited;
const currentPermissionLevel = dashboardPermissionLevels.find(dp => dp.value === item.permission);
return (
<tr className={setClassNameHelper(item.inherited)}>
@ -80,7 +81,7 @@ export default class PermissionsListItem extends PureComponent<Props> {
onChange={this.onPermissionChanged}
isDisabled={item.inherited}
className="gf-form-select-box__control--menu-right"
value={item.permission}
value={currentPermissionLevel}
/>
</div>
</td>

@ -51,8 +51,8 @@ export class DataSourcePicker extends PureComponent<Props> {
<div className="gf-form-inline">
<Select
isMulti={false}
backspaceRemovesValue={false}
isClearable={false}
backspaceRemovesValue={false}
onChange={this.onChange}
options={options}
autoFocus={autoFocus}

@ -25,7 +25,7 @@ interface CommonProps {
onChange: (item: SelectOptionItem) => {} | void;
placeholder?: string;
width?: number;
value?: any;
value?: SelectOptionItem;
className?: string;
components: object;
isDisabled?: boolean;

@ -1,11 +1,7 @@
import React, { Component } from 'react';
import AsyncSelect from 'react-select/lib/Async';
import PickerOption from './PickerOption';
import { AsyncSelect } from './Select';
import { debounce } from 'lodash';
import { getBackendSrv } from 'app/core/services/backend_srv';
import ResetStyles from './ResetStyles';
import IndicatorsContainer from './IndicatorsContainer';
import NoOptionsMessage from './NoOptionsMessage';
export interface Team {
id: number;
@ -45,6 +41,7 @@ export class TeamPicker extends Component<Props, State> {
const teams = result.teams.map(team => {
return {
id: team.id,
value: team.id,
label: team.name,
name: team.name,
imgUrl: team.avatarUrl,
@ -62,24 +59,13 @@ export class TeamPicker extends Component<Props, State> {
return (
<div className="user-picker">
<AsyncSelect
classNamePrefix={`gf-form-select-box`}
isMulti={false}
isLoading={isLoading}
defaultOptions={true}
loadOptions={this.debouncedSearch}
onChange={onSelected}
className={`gf-form-input gf-form-input--form-dropdown ${className || ''}`}
styles={ResetStyles}
components={{
Option: PickerOption,
IndicatorsContainer,
NoOptionsMessage,
}}
className={className}
placeholder="Select a team"
loadingMessage={() => 'Loading...'}
noOptionsMessage={() => 'No teams found'}
getOptionValue={i => i.id}
getOptionLabel={i => i.label}
/>
</div>
);

Loading…
Cancel
Save