Skip to content

Commit d083e75

Browse files
authored
chore: Update available features (#3977)
* update available features * add another feature as enum * use enum instead of string in other places * clean code * remove unncessary new line
1 parent b6149db commit d083e75

28 files changed

+98
-48
lines changed

src/components/App/useLoginWithKubeconfigID.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ import {
1212
} from 'state/utils/getClustersInfo';
1313
import { TFunction } from 'i18next';
1414
import { useFeature } from 'hooks/useFeature';
15-
import { ConfigFeature } from 'state/types';
15+
import {
16+
ClusterStorage,
17+
ConfigFeature,
18+
configFeaturesNames,
19+
} from 'state/types';
1620
import { removePreviousPath } from 'state/useAfterInitHook';
1721
import { configurationAtom } from 'state/configuration/configurationAtom';
18-
import { ClusterStorage } from 'state/types';
1922
import {
2023
KubeConfigMultipleState,
2124
multipleContexts,
@@ -155,7 +158,9 @@ const loadKubeconfigIdCluster = async (
155158
export type KubeconfigIdHandleState = 'not started' | 'loading' | 'done';
156159

157160
export function useLoginWithKubeconfigID() {
158-
const kubeconfigIdFeature = useFeature<KubeconfigIdFeature>('KUBECONFIG_ID');
161+
const kubeconfigIdFeature = useFeature<KubeconfigIdFeature>(
162+
configFeaturesNames.KUBECONFIG_ID,
163+
);
159164
const configuration = useRecoilValue(configurationAtom);
160165
const clusters = useRecoilValue(clustersState);
161166
const [contextsState, setContextsState] = useRecoilState(multipleContexts);
@@ -238,7 +243,9 @@ export function useLoginWithKubeconfigID() {
238243
}
239244

240245
export function useLoadDefaultKubeconfigId() {
241-
const kubeconfigIdFeature = useFeature<KubeconfigIdFeature>('KUBECONFIG_ID')!;
246+
const kubeconfigIdFeature = useFeature<KubeconfigIdFeature>(
247+
configFeaturesNames.KUBECONFIG_ID,
248+
)!;
242249
const clusters = useRecoilValue(clustersState);
243250
const { t } = useTranslation();
244251
const clusterInfo = useClustersInfo();

src/components/BusolaExtensions/BusolaExtensionDetails.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@ import { useUrl } from 'hooks/useUrl';
2020
import {
2121
formatCurrentVersion,
2222
getLatestVersion,
23+
getMigrationFunctions,
2324
getSupportedVersions,
2425
migrateToLatest,
25-
getMigrationFunctions,
2626
} from '../../components/Extensibility/migration';
2727
import { SectionEditor } from './SectionEditor';
2828

2929
import { BusolaExtensionEdit } from './BusolaExtensionEdit';
3030
import { SECTIONS } from './helpers';
3131
import { EXTENSION_VERSION_LABEL } from './constants';
3232
import { UI5Panel } from 'shared/components/UI5Panel/UI5Panel';
33+
import { configFeaturesNames } from 'state/types';
3334

3435
export function BusolaExtensionDetails({ name, namespace }) {
3536
const { t } = useTranslation();
@@ -125,7 +126,9 @@ export function BusolaExtensionDetails({ name, namespace }) {
125126

126127
const ExtensibilityVersion = configmap => {
127128
const { t } = useTranslation();
128-
const { isEnabled: isExtensibilityEnabled } = useFeature('EXTENSIBILITY');
129+
const { isEnabled: isExtensibilityEnabled } = useFeature(
130+
configFeaturesNames.EXTENSIBILITY,
131+
);
129132
const hasExtensibilityLabel =
130133
configmap?.metadata?.labels &&
131134
configmap?.metadata?.labels['busola.io/extension'] === 'resource';

src/components/Clusters/views/ClusterList.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ import { EmptyListComponent } from 'shared/components/EmptyListComponent/EmptyLi
3030
import { columnLayoutState } from 'state/columnLayoutAtom';
3131
import { showKymaCompanionState } from 'state/companion/showKymaCompanionAtom';
3232
import { Link } from 'shared/components/Link/Link';
33+
import { configFeaturesNames } from 'state/types';
3334

3435
function ClusterList() {
35-
const gardenerLoginFeature = useFeature('GARDENER_LOGIN');
36-
const kubeconfigIdFeature = useFeature('KUBECONFIG_ID');
36+
const gardenerLoginFeature = useFeature(configFeaturesNames.GARDENER_LOGIN);
37+
const kubeconfigIdFeature = useFeature(configFeaturesNames.KUBECONFIG_ID);
3738
const loadDefaultKubeconfigId = useLoadDefaultKubeconfigId();
3839

3940
const clustersInfo = useClustersInfo();

src/components/Clusters/views/ClusterOverview/ClusterDetails.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ import ResourceDetailsCard from 'shared/components/ResourceDetails/ResourceDetai
1313
import ClusterModulesCard from './ClusterModulesCard';
1414
import { ClusterStorageType } from '../ClusterStorageType';
1515
import { EMPTY_TEXT_PLACEHOLDER } from 'shared/constants';
16+
import { configFeaturesNames } from 'state/types';
1617

1718
const GardenerProvider = () => {
1819
const { t } = useTranslation();
19-
const showGardenerMetadata = useFeature('SHOW_GARDENER_METADATA')?.isEnabled;
20+
const showGardenerMetadata = useFeature(
21+
configFeaturesNames.SHOW_GARDENER_METADATA,
22+
)?.isEnabled;
2023

2124
const provider = useGetGardenerProvider({
2225
skip: !showGardenerMetadata,

src/components/Clusters/views/ClusterOverview/ClusterOverview.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@ import BannerCarousel from 'components/Extensibility/components/FeaturedCard/Ban
2222
import { columnLayoutState } from 'state/columnLayoutAtom';
2323

2424
import './ClusterOverview.scss';
25+
import { configFeaturesNames } from 'state/types';
2526

2627
const Injections = React.lazy(() =>
2728
import('../../../Extensibility/ExtensibilityInjections'),
2829
);
2930

3031
export function ClusterOverview() {
3132
const { t } = useTranslation();
32-
const clusterValidation = useFeature('CLUSTER_VALIDATION');
33+
const clusterValidation = useFeature(configFeaturesNames.CLUSTER_VALIDATION);
3334
const clustersInfo = useClustersInfo();
3435
const currentCluster = clustersInfo?.currentCluster;
3536
const notification = useNotification();

src/components/Clusters/views/ClusterOverview/useGetVersions.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import { useTranslation } from 'react-i18next';
22
import { useGet } from 'shared/hooks/BackendAPI/useGet';
33
import { getErrorMessage } from 'shared/utils/helpers';
44
import { useFeature } from 'hooks/useFeature';
5+
import { configFeaturesNames } from 'state/types';
56

67
export function useGetVersions() {
78
const { t } = useTranslation();
8-
const showKymaVersion = useFeature('SHOW_KYMA_VERSION')?.isEnabled;
9+
const showKymaVersion = useFeature(configFeaturesNames.SHOW_KYMA_VERSION)
10+
?.isEnabled;
911

1012
const {
1113
data: k8sVersion,

src/components/Extensibility/ExtensibilityList.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { createPortal } from 'react-dom';
2828
import YamlUploadDialog from 'resources/Namespaces/YamlUpload/YamlUploadDialog';
2929

3030
import '../../web-components/eventListenerTracker';
31+
import { configFeaturesNames } from 'state/types';
3132

3233
export const ExtensibilityListCore = ({
3334
resMetaData,
@@ -149,7 +150,7 @@ const ExtensibilityList = ({ overrideResMetadata, ...props }) => {
149150
const resMetaData = overrideResMetadata || defaultResMetadata;
150151
const { urlPath, defaultPlaceholder } = resMetaData?.general ?? {};
151152
const { isEnabled: isExtensibilityCustomComponentsEnabled } = useFeature(
152-
'EXTENSIBILITY_CUSTOM_COMPONENTS',
153+
configFeaturesNames.EXTENSIBILITY_CUSTOM_COMPONENTS,
153154
);
154155

155156
useEffect(() => {

src/components/Extensibility/components/Wizard.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ import { useGetTranslation } from 'components/Extensibility/helpers';
99
import { useTranslation } from 'react-i18next';
1010
import { useEventListener } from 'hooks/useEventListener';
1111
import { createPortal } from 'react-dom';
12+
import { configFeaturesNames } from 'state/types';
1213

1314
export function Wizard({ value, structure, singleRootResource }) {
1415
const { t: tExt } = useGetTranslation();
1516
const { t } = useTranslation();
1617
const [showWizard, setShowWizard] = useState(false);
17-
const { isEnabled: isWizardEnabled } = useFeature('EXTENSIBILITY_WIZARD');
18+
const { isEnabled: isWizardEnabled } = useFeature(
19+
configFeaturesNames.EXTENSIBILITY_WIZARD,
20+
);
1821
const wizardName = structure?.wizard || '';
1922

2023
const handleCloseWithEscape = e => {

src/components/Gardener/GardenerLogin.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { KubeconfigOIDCAuth } from 'types';
88
import { GardenerLoginFeature } from './GardenerLoginFeature';
99
import { useGardenerLogin } from './useGardenerLoginFunction';
1010
import { parseOIDCparams } from 'components/Clusters/components/oidc-params';
11+
import { configFeaturesNames } from 'state/types';
1112

1213
export default function GardenerLogin() {
1314
const [token, setToken] = useState('');
@@ -16,7 +17,9 @@ export default function GardenerLogin() {
1617

1718
const { t } = useTranslation();
1819

19-
const gardenerFeature = useFeature<GardenerLoginFeature>('GARDENER_LOGIN');
20+
const gardenerFeature = useFeature<GardenerLoginFeature>(
21+
configFeaturesNames.GARDENER_LOGIN,
22+
);
2023
const navigate = useNavigate();
2124
const performGardenerLogin = useGardenerLogin(setReport);
2225

src/components/Gardener/useMakeGardenerLoginRoute.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { useFeature } from 'hooks/useFeature';
22
import React from 'react';
33
import { Route } from 'react-router';
4+
import { configFeaturesNames } from 'state/types';
45

56
const GardenerLogin = React.lazy(() => import('./GardenerLogin'));
67

78
export function useMakeGardenerLoginRoute() {
8-
const gardenerLoginFeature = useFeature('GARDENER_LOGIN');
9+
const gardenerLoginFeature = useFeature(configFeaturesNames.GARDENER_LOGIN);
910

1011
return () => {
1112
if (gardenerLoginFeature.isEnabled) {

0 commit comments

Comments
 (0)