From 2a177a9a3480f170f132063610871ab6428dd292 Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Mon, 23 Jan 2023 15:17:03 +0100 Subject: [PATCH] change(ui) - card option disable ee, card type text changes --- .../BreakdownOfLoadedResources.tsx | 2 +- .../PredefinedWidgets/CPULoad/CPULoad.tsx | 2 +- .../MetricTypeDropdown/MetricTypeDropdown.tsx | 34 ++++-- .../CustomDropdownOption.tsx | 44 +++---- frontend/app/constants/card.ts | 110 +++++++----------- 5 files changed, 94 insertions(+), 98 deletions(-) diff --git a/frontend/app/components/Dashboard/Widgets/PredefinedWidgets/BreakdownOfLoadedResources/BreakdownOfLoadedResources.tsx b/frontend/app/components/Dashboard/Widgets/PredefinedWidgets/BreakdownOfLoadedResources/BreakdownOfLoadedResources.tsx index 35cd05063..f28f81fff 100644 --- a/frontend/app/components/Dashboard/Widgets/PredefinedWidgets/BreakdownOfLoadedResources/BreakdownOfLoadedResources.tsx +++ b/frontend/app/components/Dashboard/Widgets/PredefinedWidgets/BreakdownOfLoadedResources/BreakdownOfLoadedResources.tsx @@ -19,7 +19,7 @@ function BreakdownOfLoadedResources(props: Props) { diff --git a/frontend/app/components/Dashboard/components/WidgetForm/components/MetricTypeDropdown/MetricTypeDropdown.tsx b/frontend/app/components/Dashboard/components/WidgetForm/components/MetricTypeDropdown/MetricTypeDropdown.tsx index c85389529..060c9c580 100644 --- a/frontend/app/components/Dashboard/components/WidgetForm/components/MetricTypeDropdown/MetricTypeDropdown.tsx +++ b/frontend/app/components/Dashboard/components/WidgetForm/components/MetricTypeDropdown/MetricTypeDropdown.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { DROPDOWN_OPTIONS, Option } from 'App/constants/card'; +import { DROPDOWN_OPTIONS, INSIGHTS, Option } from 'App/constants/card'; import Select from 'Shared/Select'; import { components } from 'react-select'; import CustomDropdownOption from 'Shared/CustomDropdownOption'; @@ -7,25 +7,34 @@ import { observer } from 'mobx-react-lite'; import { useStore } from 'App/mstore'; import withLocationHandlers from 'HOCs/withLocationHandlers'; import { Icon } from 'UI'; -interface Options { - label: string; - icon: string; - value: string; - description: string; -} +import { connect } from 'react-redux'; interface Props { query: Record any>; onSelect: (arg: any) => void; + isEnterprise?: boolean; } function MetricTypeDropdown(props: Props) { + const { isEnterprise } = props; const { metricStore } = useStore(); const metric: any = metricStore.instance; + const options = React.useMemo(() => { + return DROPDOWN_OPTIONS.map((option: any) => { + return { + ...option, + disabled: !isEnterprise && option.value === INSIGHTS, + }; + }); + }, []); + React.useEffect(() => { const queryCardType = props.query.get('type'); - if (queryCardType && DROPDOWN_OPTIONS.length > 0 && metric.metricType) { - const type: Option = DROPDOWN_OPTIONS.find((i) => i.value === queryCardType) as Option; + if (queryCardType && options.length > 0 && metric.metricType) { + const type: Option = options.find((i) => i.value === queryCardType) as Option; + if (type.disabled) { + return; + } setTimeout(() => onChange(type.value), 0); } }, []); @@ -38,7 +47,8 @@ function MetricTypeDropdown(props: Props) {