diff --git a/ui/src/alerting/components/AlertHistoryIndex.tsx b/ui/src/alerting/components/AlertHistoryIndex.tsx index a357bbd9ab..82bb62ad5e 100644 --- a/ui/src/alerting/components/AlertHistoryIndex.tsx +++ b/ui/src/alerting/components/AlertHistoryIndex.tsx @@ -24,7 +24,7 @@ import { // Types import {AlertHistoryType} from 'src/types' -import GetResources, {ResourceTypes} from 'src/shared/components/GetResources' +import GetResources, {ResourceType} from 'src/shared/components/GetResources' interface Props { params: {orgID: string} @@ -45,9 +45,9 @@ const AlertHistoryIndex: FC = ({params: {orgID}}) => { historyType === 'statuses' ? STATUS_FIELDS : NOTIFICATION_FIELDS return ( - - - + + + {props => ( = ({ - + = ({ - + - + - + diff --git a/ui/src/alerting/components/CheckTableField.tsx b/ui/src/alerting/components/CheckTableField.tsx index 75d1661272..e970344cad 100644 --- a/ui/src/alerting/components/CheckTableField.tsx +++ b/ui/src/alerting/components/CheckTableField.tsx @@ -5,12 +5,10 @@ import {connect} from 'react-redux' // Utils import {formatOrgRoute} from 'src/shared/utils/formatOrgRoute' - -// Selectors -import {getCheckIDs} from 'src/alerting/reducers/checks' +import {getResourceIDs} from 'src/alerting/selectors' // Types -import {StatusRow, NotificationRow, AppState} from 'src/types' +import {StatusRow, NotificationRow, AppState, ResourceType} from 'src/types' interface OwnProps { row: StatusRow | NotificationRow @@ -41,7 +39,7 @@ const CheckTableField: FC = ({row: {checkName, checkID}, checkIDs}) => { const mstp = (state: AppState) => { return { - checkIDs: getCheckIDs(state.checks), + checkIDs: getResourceIDs(state, ResourceType.Checks), } } diff --git a/ui/src/alerting/components/NotificationEndpointTableField.tsx b/ui/src/alerting/components/NotificationEndpointTableField.tsx index 281e05d0d5..5c6f8aeca6 100644 --- a/ui/src/alerting/components/NotificationEndpointTableField.tsx +++ b/ui/src/alerting/components/NotificationEndpointTableField.tsx @@ -3,14 +3,12 @@ import React, {FC} from 'react' import {Link} from 'react-router' import {connect} from 'react-redux' -// Reducers -import {getEndpointIDs} from 'src/alerting/reducers/notifications/endpoints' - // Utils import {formatOrgRoute} from 'src/shared/utils/formatOrgRoute' +import {getResourceIDs} from 'src/alerting/selectors' // Types -import {NotificationRow, AppState} from 'src/types' +import {NotificationRow, AppState, ResourceType} from 'src/types' interface OwnProps { row: NotificationRow @@ -45,7 +43,7 @@ const NotificationEndpointTableField: FC = ({ const mstp = (state: AppState) => { return { - endpointIDs: getEndpointIDs(state.endpoints), + endpointIDs: getResourceIDs(state, ResourceType.NotificationEndpoints), } } diff --git a/ui/src/alerting/components/NotificationRuleTableField.tsx b/ui/src/alerting/components/NotificationRuleTableField.tsx index 116de8798a..04fbe35471 100644 --- a/ui/src/alerting/components/NotificationRuleTableField.tsx +++ b/ui/src/alerting/components/NotificationRuleTableField.tsx @@ -5,12 +5,10 @@ import {connect} from 'react-redux' // Utils import {formatOrgRoute} from 'src/shared/utils/formatOrgRoute' - -// Selectors -import {getRuleIDs} from 'src/alerting/reducers/notifications/rules' +import {getResourceIDs} from 'src/alerting/selectors' // Types -import {NotificationRow, AppState} from 'src/types' +import {NotificationRow, AppState, ResourceType} from 'src/types' interface OwnProps { row: NotificationRow @@ -36,6 +34,7 @@ const NotificationRuleTableField: FC = ({ ) } + const href = formatOrgRoute(`/alerting/rules/${notificationRuleID}/edit`) return {notificationRuleName} @@ -43,7 +42,7 @@ const NotificationRuleTableField: FC = ({ const mstp = (state: AppState) => { return { - ruleIDs: getRuleIDs(state.rules), + ruleIDs: getResourceIDs(state, ResourceType.NotificationRules), } } export default connect(mstp)(NotificationRuleTableField) diff --git a/ui/src/alerting/reducers/checks.ts b/ui/src/alerting/reducers/checks.ts index cbd318219a..da2eb2eb9e 100644 --- a/ui/src/alerting/reducers/checks.ts +++ b/ui/src/alerting/reducers/checks.ts @@ -66,7 +66,3 @@ export default ( return } }) - -export const getCheckIDs = (state: ChecksState): {[x: string]: boolean} => { - return state.list.reduce((acc, check) => ({...acc, [check.id]: true}), {}) -} diff --git a/ui/src/alerting/reducers/notifications/endpoints.ts b/ui/src/alerting/reducers/notifications/endpoints.ts index 61b47b2fce..0faed7a445 100644 --- a/ui/src/alerting/reducers/notifications/endpoints.ts +++ b/ui/src/alerting/reducers/notifications/endpoints.ts @@ -75,12 +75,3 @@ export default ( } } }) - -export const getEndpointIDs = ( - state: NotificationEndpointsState -): {[x: string]: boolean} => { - return state.list.reduce( - (acc, endpoint) => ({...acc, [endpoint.id]: true}), - {} - ) -} diff --git a/ui/src/alerting/reducers/notifications/rules.ts b/ui/src/alerting/reducers/notifications/rules.ts index 98970b286f..ceec1aca12 100644 --- a/ui/src/alerting/reducers/notifications/rules.ts +++ b/ui/src/alerting/reducers/notifications/rules.ts @@ -75,9 +75,3 @@ export default ( return } }) - -export const getRuleIDs = ( - state: NotificationRulesState -): {[x: string]: boolean} => { - return state.list.reduce((acc, rule) => ({...acc, [rule.id]: true}), {}) -} diff --git a/ui/src/alerting/selectors/index.ts b/ui/src/alerting/selectors/index.ts index b0b73dce3c..bf48b2d190 100644 --- a/ui/src/alerting/selectors/index.ts +++ b/ui/src/alerting/selectors/index.ts @@ -1,6 +1,16 @@ -import {AppState, Check} from 'src/types' +import {AppState, Check, ResourceType} from 'src/types' export const getCheck = (state: AppState, id: string): Check => { const checksList = state.checks.list return checksList.find(c => c.id === id) } + +export const getResourceIDs = ( + state: AppState, + resource: ResourceType +): {[x: string]: boolean} => { + return state[resource].list.reduce( + (acc, endpoint) => ({...acc, [endpoint.id]: true}), + {} + ) +} diff --git a/ui/src/authorizations/components/BucketsTokenOverlay.tsx b/ui/src/authorizations/components/BucketsTokenOverlay.tsx index 61b0fce28e..10ab171782 100644 --- a/ui/src/authorizations/components/BucketsTokenOverlay.tsx +++ b/ui/src/authorizations/components/BucketsTokenOverlay.tsx @@ -19,7 +19,7 @@ import { Form, } from '@influxdata/clockface' import BucketsSelector from 'src/authorizations/components/BucketsSelector' -import GetResources, {ResourceTypes} from 'src/shared/components/GetResources' +import GetResources, {ResourceType} from 'src/shared/components/GetResources' // Utils import { @@ -99,7 +99,7 @@ class BucketsTokenOverlay extends PureComponent { /> - + { - + diff --git a/ui/src/buckets/containers/BucketsIndex.tsx b/ui/src/buckets/containers/BucketsIndex.tsx index 19d0653eec..9f52446ad5 100644 --- a/ui/src/buckets/containers/BucketsIndex.tsx +++ b/ui/src/buckets/containers/BucketsIndex.tsx @@ -7,7 +7,7 @@ import {ErrorHandling} from 'src/shared/decorators/errors' import LoadDataTabbedPage from 'src/settings/components/LoadDataTabbedPage' import LoadDataHeader from 'src/settings/components/LoadDataHeader' import BucketsTab from 'src/buckets/components/BucketsTab' -import GetResources, {ResourceTypes} from 'src/shared/components/GetResources' +import GetResources, {ResourceType} from 'src/shared/components/GetResources' import GetAssetLimits from 'src/cloud/components/GetAssetLimits' import LimitChecker from 'src/cloud/components/LimitChecker' import RateLimitAlert from 'src/cloud/components/RateLimitAlert' @@ -58,8 +58,8 @@ class BucketsIndex extends Component { )} - - + + diff --git a/ui/src/dashboards/components/dashboard_index/DashboardsIndex.tsx b/ui/src/dashboards/components/dashboard_index/DashboardsIndex.tsx index 4f18d05b64..be0d644c05 100644 --- a/ui/src/dashboards/components/dashboard_index/DashboardsIndex.tsx +++ b/ui/src/dashboards/components/dashboard_index/DashboardsIndex.tsx @@ -13,7 +13,7 @@ import SearchWidget from 'src/shared/components/search_widget/SearchWidget' import AddResourceDropdown from 'src/shared/components/AddResourceDropdown' import PageTitleWithOrg from 'src/shared/components/PageTitleWithOrg' import GetAssetLimits from 'src/cloud/components/GetAssetLimits' -import GetResources, {ResourceTypes} from 'src/shared/components/GetResources' +import GetResources, {ResourceType} from 'src/shared/components/GetResources' import AssetLimitAlert from 'src/cloud/components/AssetLimitAlert' // Utils @@ -93,8 +93,8 @@ class DashboardIndex extends PureComponent { - - + + { return ( {children} - + diff --git a/ui/src/dataExplorer/components/DeleteDataOverlay.tsx b/ui/src/dataExplorer/components/DeleteDataOverlay.tsx index c3560985bd..55d3dffd78 100644 --- a/ui/src/dataExplorer/components/DeleteDataOverlay.tsx +++ b/ui/src/dataExplorer/components/DeleteDataOverlay.tsx @@ -7,7 +7,7 @@ import {get} from 'lodash' // Components import DeleteDataForm from 'src/shared/components/DeleteDataForm/DeleteDataForm' -import GetResources, {ResourceTypes} from 'src/shared/components/GetResources' +import GetResources, {ResourceType} from 'src/shared/components/GetResources' // Utils import {getActiveTimeMachine, getActiveQuery} from 'src/timeMachine/selectors' @@ -46,7 +46,7 @@ const DeleteDataOverlay: FunctionComponent = ({ - + { - + diff --git a/ui/src/me/components/Resources.tsx b/ui/src/me/components/Resources.tsx index 3ae805ead5..32a58ce806 100644 --- a/ui/src/me/components/Resources.tsx +++ b/ui/src/me/components/Resources.tsx @@ -16,7 +16,7 @@ import VersionInfo from 'src/shared/components/VersionInfo' // Types import {AppState} from 'src/types' -import GetResources, {ResourceTypes} from 'src/shared/components/GetResources' +import GetResources, {ResourceType} from 'src/shared/components/GetResources' interface Props { me: AppState['me'] @@ -42,7 +42,7 @@ class ResourceLists extends PureComponent { Dashboards - + diff --git a/ui/src/members/components/AddMembersOverlay.tsx b/ui/src/members/components/AddMembersOverlay.tsx index 112f4858b4..8038f88253 100644 --- a/ui/src/members/components/AddMembersOverlay.tsx +++ b/ui/src/members/components/AddMembersOverlay.tsx @@ -15,7 +15,7 @@ import {getUsers, addNewMember} from 'src/members/actions' import {UsersMap} from 'src/members/reducers' import {User} from '@influxdata/influx' import {AppState, RemoteDataState} from 'src/types' -import GetResources, {ResourceTypes} from 'src/shared/components/GetResources' +import GetResources, {ResourceType} from 'src/shared/components/GetResources' interface StateProps { status: RemoteDataState @@ -51,7 +51,7 @@ class AddMembersOverlay extends PureComponent { const {selectedUserIDs, searchTerm, selectedMembers} = this.state return ( - + diff --git a/ui/src/members/containers/MembersIndex.tsx b/ui/src/members/containers/MembersIndex.tsx index 876048e4ee..8794729d9f 100644 --- a/ui/src/members/containers/MembersIndex.tsx +++ b/ui/src/members/containers/MembersIndex.tsx @@ -7,7 +7,7 @@ import {ErrorHandling} from 'src/shared/decorators/errors' import SettingsTabbedPage from 'src/settings/components/SettingsTabbedPage' import SettingsHeader from 'src/settings/components/SettingsHeader' import {Page} from '@influxdata/clockface' -import GetResources, {ResourceTypes} from 'src/shared/components/GetResources' +import GetResources, {ResourceType} from 'src/shared/components/GetResources' import Members from 'src/members/components/Members' // Utils @@ -36,7 +36,7 @@ class MembersIndex extends Component { - + diff --git a/ui/src/scrapers/containers/ScrapersIndex.tsx b/ui/src/scrapers/containers/ScrapersIndex.tsx index b9df478e23..6377f69a89 100644 --- a/ui/src/scrapers/containers/ScrapersIndex.tsx +++ b/ui/src/scrapers/containers/ScrapersIndex.tsx @@ -6,7 +6,7 @@ import {connect} from 'react-redux' import {Page} from '@influxdata/clockface' import LoadDataHeader from 'src/settings/components/LoadDataHeader' import LoadDataTabbedPage from 'src/settings/components/LoadDataTabbedPage' -import GetResources, {ResourceTypes} from 'src/shared/components/GetResources' +import GetResources, {ResourceType} from 'src/shared/components/GetResources' import Scrapers from 'src/scrapers/components/Scrapers' // Utils @@ -32,8 +32,8 @@ class ScrapersIndex extends Component { - - + + diff --git a/ui/src/shared/components/GetResources.tsx b/ui/src/shared/components/GetResources.tsx index 66e10d382b..aa1db35903 100644 --- a/ui/src/shared/components/GetResources.tsx +++ b/ui/src/shared/components/GetResources.tsx @@ -77,12 +77,12 @@ interface DispatchProps { } interface PassedProps { - resource: ResourceTypes + resource: ResourceType } type Props = StateProps & DispatchProps & PassedProps -export enum ResourceTypes { +export enum ResourceType { Labels = 'labels', Buckets = 'buckets', Telegrafs = 'telegrafs', @@ -103,59 +103,59 @@ export enum ResourceTypes { class GetResources extends PureComponent { public async componentDidMount() { switch (this.props.resource) { - case ResourceTypes.Dashboards: { + case ResourceType.Dashboards: { return await this.props.getDashboards() } - case ResourceTypes.Labels: { + case ResourceType.Labels: { return await this.props.getLabels() } - case ResourceTypes.Buckets: { + case ResourceType.Buckets: { return await this.props.getBuckets() } - case ResourceTypes.Telegrafs: { + case ResourceType.Telegrafs: { return await this.props.getTelegrafs() } - case ResourceTypes.Scrapers: { + case ResourceType.Scrapers: { return await this.props.getScrapers() } - case ResourceTypes.Variables: { + case ResourceType.Variables: { return await this.props.getVariables() } - case ResourceTypes.Tasks: { + case ResourceType.Tasks: { return await this.props.getTasks() } - case ResourceTypes.Authorizations: { + case ResourceType.Authorizations: { return await this.props.getAuthorizations() } - case ResourceTypes.Templates: { + case ResourceType.Templates: { return await this.props.getTemplates() } - case ResourceTypes.Members: { + case ResourceType.Members: { return await this.props.getMembers() } - case ResourceTypes.Users: { + case ResourceType.Users: { return await this.props.getUsers() } - case ResourceTypes.Checks: { + case ResourceType.Checks: { return await this.props.getChecks() } - case ResourceTypes.NotificationRules: { + case ResourceType.NotificationRules: { return await this.props.getNotificationRules() } - case ResourceTypes.NotificationEndpoints: { + case ResourceType.NotificationEndpoints: { return await this.props.getEndpoints() } diff --git a/ui/src/tasks/components/TaskForm.tsx b/ui/src/tasks/components/TaskForm.tsx index 21f939d7e1..5e5c5e465d 100644 --- a/ui/src/tasks/components/TaskForm.tsx +++ b/ui/src/tasks/components/TaskForm.tsx @@ -6,7 +6,7 @@ import React, {PureComponent, ChangeEvent} from 'react' import {Form, Radio, Input, Button, FlexBox, Grid} from '@influxdata/clockface' import TaskScheduleFormField from 'src/tasks/components/TaskScheduleFormField' import TaskOptionsBucketDropdown from 'src/tasks/components/TasksOptionsBucketDropdown' -import GetResources, {ResourceTypes} from 'src/shared/components/GetResources' +import GetResources, {ResourceType} from 'src/shared/components/GetResources' // Types import { @@ -140,7 +140,7 @@ export default class TaskForm extends PureComponent { {isInOverlay && ( - + + { limitStatus={limitStatus} /> - - + + { widthSM={Columns.Eight} widthMD={Columns.Ten} > - + searchTerm={searchTerm} searchKeys={['plugins.0.config.bucket', 'labels[].name']} diff --git a/ui/src/telegrafs/components/TelegrafInstructionsOverlay.tsx b/ui/src/telegrafs/components/TelegrafInstructionsOverlay.tsx index 5807d2d13e..4015972411 100644 --- a/ui/src/telegrafs/components/TelegrafInstructionsOverlay.tsx +++ b/ui/src/telegrafs/components/TelegrafInstructionsOverlay.tsx @@ -8,7 +8,7 @@ import {withRouter, WithRouterProps} from 'react-router' import {ErrorHandling} from 'src/shared/decorators/errors' import WizardOverlay from 'src/clockface/components/wizard/WizardOverlay' import TelegrafInstructions from 'src/dataLoaders/components/verifyStep/TelegrafInstructions' -import GetResources, {ResourceTypes} from 'src/shared/components/GetResources' +import GetResources, {ResourceType} from 'src/shared/components/GetResources' // Constants import {TOKEN_LABEL} from 'src/labels/constants' @@ -30,7 +30,7 @@ export class TelegrafInstructionsOverlay extends PureComponent< > { public render() { return ( - + { )} - - + + diff --git a/ui/src/templates/components/TemplatesPage.tsx b/ui/src/templates/components/TemplatesPage.tsx index e441b90847..30c2ba0146 100644 --- a/ui/src/templates/components/TemplatesPage.tsx +++ b/ui/src/templates/components/TemplatesPage.tsx @@ -9,7 +9,7 @@ import TemplatesList from 'src/templates/components/TemplatesList' import StaticTemplatesList from 'src/templates/components/StaticTemplatesList' import {ErrorHandling} from 'src/shared/decorators/errors' import SearchWidget from 'src/shared/components/search_widget/SearchWidget' -import GetResources, {ResourceTypes} from 'src/shared/components/GetResources' +import GetResources, {ResourceType} from 'src/shared/components/GetResources' import SettingsTabbedPageHeader from 'src/settings/components/SettingsTabbedPageHeader' // Types @@ -154,7 +154,7 @@ class TemplatesPage extends PureComponent { if (activeTab === 'user-templates') { return ( - + searchTerm={searchTerm} searchKeys={['meta.name', 'labels[].name']} diff --git a/ui/src/templates/components/createFromTemplateOverlay/CreateFromTemplateOverlay.tsx b/ui/src/templates/components/createFromTemplateOverlay/CreateFromTemplateOverlay.tsx index 4875cee15e..bb1796ab76 100644 --- a/ui/src/templates/components/createFromTemplateOverlay/CreateFromTemplateOverlay.tsx +++ b/ui/src/templates/components/createFromTemplateOverlay/CreateFromTemplateOverlay.tsx @@ -31,7 +31,7 @@ import { RemoteDataState, DashboardTemplate, } from 'src/types' -import GetResources, {ResourceTypes} from 'src/shared/components/GetResources' +import GetResources, {ResourceType} from 'src/shared/components/GetResources' interface StateProps { templates: TemplateSummary[] @@ -67,7 +67,7 @@ class DashboardImportFromTemplateOverlay extends PureComponent< render() { return ( - + { - + diff --git a/ui/src/types/index.ts b/ui/src/types/index.ts index c9844ea19c..22adc16a3c 100644 --- a/ui/src/types/index.ts +++ b/ui/src/types/index.ts @@ -33,3 +33,4 @@ export * from './timeZones' export * from './alerting' export * from './auth' export * from './cloud' +export {ResourceType} from 'src/shared/components/GetResources' diff --git a/ui/src/variables/components/CreateVariableOverlay.tsx b/ui/src/variables/components/CreateVariableOverlay.tsx index 030948555d..202554a452 100644 --- a/ui/src/variables/components/CreateVariableOverlay.tsx +++ b/ui/src/variables/components/CreateVariableOverlay.tsx @@ -12,7 +12,7 @@ import {createVariable} from 'src/variables/actions' // Components import {Overlay} from '@influxdata/clockface' import VariableForm from 'src/variables/components/VariableForm' -import GetResources, {ResourceTypes} from 'src/shared/components/GetResources' +import GetResources, {ResourceType} from 'src/shared/components/GetResources' // Types import {AppState} from 'src/types' @@ -33,7 +33,7 @@ class CreateVariableOverlay extends PureComponent { const {onCreateVariable, variables} = this.props return ( - + { onSelectNew={this.handleOpenCreateOverlay} /> - + searchTerm={searchTerm} searchKeys={['name', 'labels[].name']} diff --git a/ui/src/variables/containers/VariablesIndex.tsx b/ui/src/variables/containers/VariablesIndex.tsx index 16e6fb6747..699e61c9f0 100644 --- a/ui/src/variables/containers/VariablesIndex.tsx +++ b/ui/src/variables/containers/VariablesIndex.tsx @@ -8,7 +8,7 @@ import SettingsTabbedPage from 'src/settings/components/SettingsTabbedPage' import SettingsHeader from 'src/settings/components/SettingsHeader' import {Page} from '@influxdata/clockface' import VariablesTab from 'src/variables/components/VariablesTab' -import GetResources, {ResourceTypes} from 'src/shared/components/GetResources' +import GetResources, {ResourceType} from 'src/shared/components/GetResources' // Utils import {pageTitleSuffixer} from 'src/shared/utils/pageTitles' @@ -30,7 +30,7 @@ class VariablesIndex extends Component { - +