Merge pull request #13283 from influxdata/reborg-labels
feat(ui): make labels org centricpull/13287/head
commit
e9d53b35ac
|
@ -1,6 +1,5 @@
|
||||||
// Libraries
|
// Libraries
|
||||||
import React, {Component, ChangeEvent} from 'react'
|
import React, {Component, ChangeEvent} from 'react'
|
||||||
import {connect} from 'react-redux'
|
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
|
@ -15,22 +14,14 @@ import {EMPTY_LABEL} from 'src/configuration/constants/LabelColors'
|
||||||
|
|
||||||
// Decorators
|
// Decorators
|
||||||
import {ErrorHandling} from 'src/shared/decorators/errors'
|
import {ErrorHandling} from 'src/shared/decorators/errors'
|
||||||
import {AppState} from 'src/types'
|
|
||||||
|
|
||||||
interface OwnProps {
|
interface Props {
|
||||||
isVisible: boolean
|
isVisible: boolean
|
||||||
onDismiss: () => void
|
onDismiss: () => void
|
||||||
onCreateLabel: (label: ILabel) => void
|
onCreateLabel: (label: ILabel) => void
|
||||||
onNameValidation: (name: string) => string | null
|
onNameValidation: (name: string) => string | null
|
||||||
overrideDefaultName?: string
|
overrideDefaultName?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface StateProps {
|
|
||||||
orgID: string
|
|
||||||
}
|
|
||||||
|
|
||||||
type Props = OwnProps & StateProps
|
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
label: ILabel
|
label: ILabel
|
||||||
colorStatus: ComponentStatus
|
colorStatus: ComponentStatus
|
||||||
|
@ -102,7 +93,7 @@ class CreateLabelOverlay extends Component<Props, State> {
|
||||||
const {onCreateLabel, onDismiss} = this.props
|
const {onCreateLabel, onDismiss} = this.props
|
||||||
|
|
||||||
try {
|
try {
|
||||||
onCreateLabel({...this.state.label, orgID: this.props.orgID})
|
onCreateLabel(this.state.label)
|
||||||
// clear form on successful submit
|
// clear form on successful submit
|
||||||
this.resetForm()
|
this.resetForm()
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -147,10 +138,4 @@ class CreateLabelOverlay extends Component<Props, State> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mstp = (state: AppState) => {
|
export default CreateLabelOverlay
|
||||||
const {orgs} = state
|
|
||||||
|
|
||||||
return {orgID: _.get(orgs, '0.id', '')}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default connect<StateProps, {}, OwnProps>(mstp)(CreateLabelOverlay)
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import FilterList from 'src/shared/components/Filter'
|
||||||
import {createLabel, updateLabel, deleteLabel} from 'src/labels/actions'
|
import {createLabel, updateLabel, deleteLabel} from 'src/labels/actions'
|
||||||
|
|
||||||
// Selectors
|
// Selectors
|
||||||
import {viewableLabels} from 'src/labels/selectors'
|
import {viewableLabels, labelsInOrg} from 'src/labels/selectors'
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import {validateLabelUniqueness} from 'src/configuration/utils/labels'
|
import {validateLabelUniqueness} from 'src/configuration/utils/labels'
|
||||||
|
@ -169,8 +169,12 @@ class Labels extends PureComponent<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
const mstp = (state: AppState): StateProps => {
|
const mstp = (state: AppState): StateProps => {
|
||||||
|
const {
|
||||||
|
labels: {list},
|
||||||
|
orgs: {org},
|
||||||
|
} = state
|
||||||
return {
|
return {
|
||||||
labels: viewableLabels(state.labels.list),
|
labels: labelsInOrg(org.id, viewableLabels(list)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue