Skip to content

Commit

Permalink
Merge pull request #4029 from dlabrecq/remove-feature-flags
Browse files Browse the repository at this point in the history
Remove unused Unleash flags
  • Loading branch information
dlabrecq authored Sep 20, 2024
2 parents 247769b + 91e8cab commit 8dbfa65
Show file tree
Hide file tree
Showing 24 changed files with 103 additions and 217 deletions.
24 changes: 0 additions & 24 deletions src/components/featureToggle/featureToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ export const enum FeatureToggle {
finsights = 'cost-management.ui.finsights', // RHEL support for FINsights https://issues.redhat.com/browse/COST-3306
ibm = 'cost-management.ui.ibm', // IBM https://issues.redhat.com/browse/COST-935
ocpCloudGroupBys = 'cost-management.ui.ocp-cloud-group-bys', // https://issues.redhat.com/browse/COST-5514
ocpCloudNetworking = 'cost-management.ui.ocp-cloud-networking', // https://issues.redhat.com/browse/COST-4781
ocpProjectStorage = 'cost-management.ui.ocp-project-storage', // https://issues.redhat.com/browse/COST-4856
ros = 'cost-management.ui.ros', // ROS support https://issues.redhat.com/browse/COST-3477
}

const useIsToggleEnabled = (toggle: FeatureToggle) => {
Expand Down Expand Up @@ -50,18 +47,6 @@ export const useIsOcpCloudGroupBysToggleEnabled = () => {
return useIsToggleEnabled(FeatureToggle.ocpCloudGroupBys);
};

export const useIsOcpCloudNetworkingToggleEnabled = () => {
return useIsToggleEnabled(FeatureToggle.ocpCloudNetworking);
};

export const useIsOcpProjectStorageToggleEnabled = () => {
return useIsToggleEnabled(FeatureToggle.ocpProjectStorage);
};

export const useIsRosToggleEnabled = () => {
return useIsToggleEnabled(FeatureToggle.ros);
};

// The FeatureToggle component saves feature toggles in store for places where Unleash hooks not available
export const useFeatureToggle = () => {
const dispatch = useDispatch();
Expand All @@ -74,9 +59,6 @@ export const useFeatureToggle = () => {
const isFinsightsToggleEnabled = useIsFinsightsToggleEnabled();
const isIbmToggleEnabled = useIsIbmToggleEnabled();
const isOcpCloudGroupBysToggleEnabled = useIsOcpCloudGroupBysToggleEnabled();
const isOcpCloudNetworkingToggleEnabled = useIsOcpCloudNetworkingToggleEnabled();
const isOcpProjectStorageToggleEnabled = useIsOcpProjectStorageToggleEnabled();
const isRosToggleEnabled = useIsRosToggleEnabled();

const fetchUser = callback => {
auth.getUser().then(user => {
Expand All @@ -95,9 +77,6 @@ export const useFeatureToggle = () => {
isFinsightsToggleEnabled,
isIbmToggleEnabled,
isOcpCloudGroupBysToggleEnabled,
isOcpCloudNetworkingToggleEnabled,
isOcpProjectStorageToggleEnabled,
isRosToggleEnabled,
})
);
if (isDebugToggleEnabled) {
Expand All @@ -112,9 +91,6 @@ export const useFeatureToggle = () => {
isFinsightsToggleEnabled,
isIbmToggleEnabled,
isOcpCloudGroupBysToggleEnabled,
isOcpCloudNetworkingToggleEnabled,
isOcpProjectStorageToggleEnabled,
isRosToggleEnabled,
]);
};

Expand Down
5 changes: 1 addition & 4 deletions src/components/permissions/permissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ interface PermissionsOwnProps extends ChromeComponentProps {
interface PermissionsStateProps {
isFinsightsToggleEnabled?: boolean;
isIbmToggleEnabled?: boolean;
isRosToggleEnabled?: boolean;
userAccess: UserAccess;
userAccessError: AxiosError;
userAccessFetchStatus: FetchStatus;
Expand All @@ -48,7 +47,6 @@ const PermissionsBase: React.FC<PermissionsProps> = ({
// chrome,
isFinsightsToggleEnabled,
isIbmToggleEnabled,
isRosToggleEnabled,
userAccess,
userAccessError,
userAccessFetchStatus,
Expand All @@ -66,7 +64,7 @@ const PermissionsBase: React.FC<PermissionsProps> = ({
const oci = hasOciAccess(userAccess);
const ocp = hasOcpAccess(userAccess);
const rhel = isFinsightsToggleEnabled && hasRhelAccess(userAccess);
const ros = isRosToggleEnabled && hasRosAccess(userAccess);
const ros = hasRosAccess(userAccess);
const settings = costModel || hasSettingsAccess(userAccess);

switch (pathname) {
Expand Down Expand Up @@ -135,7 +133,6 @@ const mapStateToProps = createMapStateToProps<PermissionsOwnProps, PermissionsSt
return {
isFinsightsToggleEnabled: FeatureToggleSelectors.selectIsFinsightsToggleEnabled(state),
isIbmToggleEnabled: FeatureToggleSelectors.selectIsIbmToggleEnabled(state),
isRosToggleEnabled: FeatureToggleSelectors.selectIsRosToggleEnabled(state),
userAccess,
userAccessError,
userAccessFetchStatus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,10 @@ exports[`null previous and current reports are handled 1`] = `
vector-effect="non-scaling-stroke"
width="79.2"
x="0"
y="57"
y="67"
/>
<path
d="M 7.84, 73.156
d="M 7.84, 83.156
h12.32
v-4.312
h-12.32
Expand All @@ -349,7 +349,7 @@ exports[`null previous and current reports are handled 1`] = `
style="fill: #8bc1f7;"
/>
<path
d="M 47.44, 73.156
d="M 47.44, 83.156
h12.320000000000007
v-4.312
h-12.320000000000007
Expand All @@ -363,7 +363,7 @@ exports[`null previous and current reports are handled 1`] = `
dx="0"
id="exampleCostChart-legend-ChartLabel-0"
x="30.8"
y="75.97"
y="85.97"
>
<tspan
dx="0"
Expand All @@ -380,7 +380,7 @@ exports[`null previous and current reports are handled 1`] = `
dx="0"
id="exampleCostChart-legend-ChartLabel-1"
x="70.39999999999999"
y="75.97"
y="85.97"
>
<tspan
dx="0"
Expand Down Expand Up @@ -705,10 +705,10 @@ exports[`reports are formatted to datums 1`] = `
vector-effect="non-scaling-stroke"
width="79.2"
x="0"
y="57"
y="67"
/>
<path
d="M 7.84, 73.156
d="M 7.84, 83.156
h12.32
v-4.312
h-12.32
Expand All @@ -718,7 +718,7 @@ exports[`reports are formatted to datums 1`] = `
style="fill: #8bc1f7;"
/>
<path
d="M 47.44, 73.156
d="M 47.44, 83.156
h12.320000000000007
v-4.312
h-12.320000000000007
Expand All @@ -732,7 +732,7 @@ exports[`reports are formatted to datums 1`] = `
dx="0"
id="exampleCostChart-legend-ChartLabel-0"
x="30.8"
y="75.97"
y="85.97"
>
<tspan
dx="0"
Expand All @@ -749,7 +749,7 @@ exports[`reports are formatted to datums 1`] = `
dx="0"
id="exampleCostChart-legend-ChartLabel-1"
x="70.39999999999999"
y="75.97"
y="85.97"
>
<tspan
dx="0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,12 @@ class HistoricalCostChartBase extends React.Component<HistoricalCostChartProps,
series.map((s, index) => {
return this.getChart(s, index);
})}
<ChartAxis label={xAxisLabel} style={chartStyles.xAxis} tickValues={[1, midDate, endDate]} />
<ChartAxis
label={xAxisLabel}
style={chartStyles.xAxis}
tickValues={[1, midDate, endDate]}
fixAxisLabelHeight
/>
<ChartAxis dependentAxis label={yAxisLabel} style={chartStyles.yAxis} />
</Chart>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,12 @@ class HistoricalUsageChartBase extends React.Component<HistoricalUsageChartProps
series.map((s, index) => {
return this.getChart(s, index);
})}
<ChartAxis label={xAxisLabel} style={chartStyles.xAxis} tickValues={[1, midDate, endDate]} />
<ChartAxis
label={xAxisLabel}
style={chartStyles.xAxis}
tickValues={[1, midDate, endDate]}
fixAxisLabelHeight
/>
<ChartAxis dependentAxis label={yAxisLabel} style={chartStyles.yAxis} />
</Chart>
</div>
Expand Down
4 changes: 1 addition & 3 deletions src/routes/details/components/breakdown/breakdownBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export interface BreakdownStateProps {
instancesComponent?: React.ReactNode;
isAwsEc2InstancesToggleEnabled?: boolean;
isOptimizationsTab?: boolean;
isRosToggleEnabled?: boolean;
optimizationsBadgeComponent?: React.ReactNode;
optimizationsComponent?: React.ReactNode;
providers?: Providers;
Expand Down Expand Up @@ -136,7 +135,6 @@ class BreakdownBase extends React.Component<BreakdownProps, BreakdownState> {
historicalDataComponent,
instancesComponent,
isAwsEc2InstancesToggleEnabled,
isRosToggleEnabled,
optimizationsComponent,
} = this.props;

Expand All @@ -159,7 +157,7 @@ class BreakdownBase extends React.Component<BreakdownProps, BreakdownState> {
tab: BreakdownTab.instances,
});
}
if (optimizationsComponent && isRosToggleEnabled) {
if (optimizationsComponent) {
availableTabs.push({
contentRef: React.createRef(),
showBadge: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ interface CostOverviewOwnProps {
}

export interface CostOverviewStateProps {
isOcpProjectStorageToggleEnabled?: boolean;
selectWidgets?: Record<number, any>;
title?: string;
widgets: number[];
Expand Down Expand Up @@ -358,8 +357,6 @@ class CostOverviewsBase extends React.Component<CostOverviewProps, any> {

// Returns rendered widget based on type
private renderWidget(widget: CostOverviewWidget) {
const { isOcpProjectStorageToggleEnabled } = this.props;

switch (widget.type) {
case CostOverviewWidgetType.cluster:
return this.getClusterCard(widget);
Expand All @@ -374,9 +371,6 @@ class CostOverviewsBase extends React.Component<CostOverviewProps, any> {
case CostOverviewWidgetType.pvc:
return this.getPvcChart(widget);
case CostOverviewWidgetType.reportSummary:
if (widget.reportType === ReportType.volume && !isOcpProjectStorageToggleEnabled) {
return null;
}
return this.getReportSummaryCard(widget);
case CostOverviewWidgetType.volumeUsage:
return this.getVolumeUsageChart(widget);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ interface HistoricalDataOwnProps {
}

export interface HistoricalDataStateProps {
isOcpCloudNetworkingToggleEnabled?: boolean;
isOcpProjectStorageToggleEnabled?: boolean;
selectWidgets?: Record<number, any>;
widgets: number[];
}
Expand Down Expand Up @@ -190,7 +188,7 @@ class HistoricalDatasBase extends React.Component<HistoricalDataProps, any> {

// Returns rendered widget based on type
private renderWidget(widgetId: number) {
const { isOcpCloudNetworkingToggleEnabled, isOcpProjectStorageToggleEnabled, selectWidgets } = this.props;
const { selectWidgets } = this.props;

const widget = selectWidgets[widgetId];
let result = null;
Expand All @@ -200,7 +198,7 @@ class HistoricalDatasBase extends React.Component<HistoricalDataProps, any> {
result = this.getCostChart(widget);
break;
case HistoricalDataWidgetType.network:
result = isOcpCloudNetworkingToggleEnabled ? this.getNetworkChart(widget) : null;
result = this.getNetworkChart(widget);
break;
case HistoricalDataWidgetType.trend:
result = this.getTrendChart(widget);
Expand All @@ -209,7 +207,7 @@ class HistoricalDatasBase extends React.Component<HistoricalDataProps, any> {
result = this.getUsageChart(widget);
break;
case HistoricalDataWidgetType.volume:
result = isOcpProjectStorageToggleEnabled ? this.getVolumeChart(widget) : null;
result = this.getVolumeChart(widget);
break;
}
return result !== null ? <GridItem key={`widget-${widgetId}`}>{result}</GridItem> : null;
Expand Down
2 changes: 0 additions & 2 deletions src/routes/details/ocpBreakdown/costOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ import type { CostOverviewStateProps } from 'routes/details/components/costOverv
import { CostOverviewBase } from 'routes/details/components/costOverview';
import { ocpCostOverviewSelectors } from 'store/breakdown/costOverview/ocpCostOverview';
import { createMapStateToProps } from 'store/common';
import { FeatureToggleSelectors } from 'store/featureToggle';

interface OcpCostOverviewOwnProps {
title?: string;
}

const mapStateToProps = createMapStateToProps<OcpCostOverviewOwnProps, CostOverviewStateProps>((state, { title }) => {
return {
isOcpProjectStorageToggleEnabled: FeatureToggleSelectors.selectIsOcpProjectStorageToggleEnabled(state),
selectWidgets: ocpCostOverviewSelectors.selectWidgets(state),
widgets: ocpCostOverviewSelectors.selectCurrentWidgets(state),
title,
Expand Down
3 changes: 0 additions & 3 deletions src/routes/details/ocpBreakdown/historicalData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { HistoricalDataStateProps } from 'routes/details/components/histori
import { HistoricalDataBase } from 'routes/details/components/historicalData';
import { ocpHistoricalDataSelectors } from 'store/breakdown/historicalData/ocpHistoricalData';
import { createMapStateToProps } from 'store/common';
import { FeatureToggleSelectors } from 'store/featureToggle';

interface OcpHistoricalDataOwnProps {
// TBD...
Expand All @@ -12,8 +11,6 @@ interface OcpHistoricalDataOwnProps {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const mapStateToProps = createMapStateToProps<OcpHistoricalDataOwnProps, HistoricalDataStateProps>((state, props) => {
return {
isOcpCloudNetworkingToggleEnabled: FeatureToggleSelectors.selectIsOcpCloudNetworkingToggleEnabled(state),
isOcpProjectStorageToggleEnabled: FeatureToggleSelectors.selectIsOcpProjectStorageToggleEnabled(state),
selectWidgets: ocpHistoricalDataSelectors.selectWidgets(state),
widgets: ocpHistoricalDataSelectors.selectCurrentWidgets(state),
};
Expand Down
2 changes: 0 additions & 2 deletions src/routes/details/ocpBreakdown/ocpBreakdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { getGroupById, getGroupByValue } from 'routes/utils/groupBy';
import { filterProviders } from 'routes/utils/providers';
import { getQueryState } from 'routes/utils/queryState';
import { createMapStateToProps } from 'store/common';
import { FeatureToggleSelectors } from 'store/featureToggle';
import { providersQuery, providersSelectors } from 'store/providers';
import { reportActions, reportSelectors } from 'store/reports';
import { uiActions } from 'store/ui';
Expand Down Expand Up @@ -125,7 +124,6 @@ const mapStateToProps = createMapStateToProps<OcpBreakdownOwnProps, BreakdownSta
<HistoricalData costDistribution={costDistribution} currency={currency} groupBy={groupBy} />
),
isOptimizationsTab: queryFromRoute.optimizationsTab !== undefined,
isRosToggleEnabled: FeatureToggleSelectors.selectIsRosToggleEnabled(state),
optimizationsComponent: groupBy === 'project' && groupByValue !== '*' ? <Optimizations /> : undefined,
providers: filterProviders(providers, ProviderType.ocp),
providersFetchStatus,
Expand Down
8 changes: 3 additions & 5 deletions src/routes/details/ocpDetails/detailsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ interface DetailsTableOwnProps extends RouterComponentProps, WrappedComponentPro
hiddenColumns?: Set<string>;
isAllSelected?: boolean;
isLoading?: boolean;
isRosToggleEnabled?: boolean;
onSelect(items: ComputedReportItem[], isSelected: boolean);
onSort(sortType: string, isSortAscending: boolean);
orderBy?: any;
Expand Down Expand Up @@ -100,7 +99,6 @@ class DetailsTableBase extends React.Component<DetailsTableProps, DetailsTableSt
hiddenColumns,
intl,
isAllSelected,
isRosToggleEnabled,
query,
report,
router,
Expand Down Expand Up @@ -133,7 +131,7 @@ class DetailsTableBase extends React.Component<DetailsTableProps, DetailsTableSt
name: '', // Default & Overhead column
},
{
hidden: !(isGroupByProject && isRosToggleEnabled),
hidden: !isGroupByProject,
name: intl.formatMessage(messages.optimizations),
},
{
Expand Down Expand Up @@ -174,7 +172,7 @@ class DetailsTableBase extends React.Component<DetailsTableProps, DetailsTableSt
name: '', // Default & Overhead column
},
{
hidden: !(isGroupByProject && isRosToggleEnabled),
hidden: !isGroupByProject,
name: intl.formatMessage(messages.optimizations),
},
{
Expand Down Expand Up @@ -304,7 +302,7 @@ class DetailsTableBase extends React.Component<DetailsTableProps, DetailsTableSt
),
},
{
hidden: !(isGroupByProject && isRosToggleEnabled),
hidden: !isGroupByProject,
value: !isPlatformProject && !isDisabled && (
<AsyncComponent
scope="costManagementMfe"
Expand Down
Loading

0 comments on commit 8dbfa65

Please sign in to comment.