Skip to content

Commit c52e48c

Browse files
Merge pull request #15715 from TheRealJon/CONSOLE-4729
CONSOLE-4729,CONSOLE-4823: Enable OLMv1 Tech Preview
2 parents 05437cb + 5292d41 commit c52e48c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+529
-1237
lines changed

cmd/bridge/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ func main() {
358358
NodeOperatingSystems: nodeOperatingSystems,
359359
K8sMode: *fK8sMode,
360360
CopiedCSVsDisabled: *fCopiedCSVsDisabled,
361+
TechPreview: *fTechPreview,
361362
Capabilities: capabilities,
362363
}
363364

frontend/@types/console/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ declare interface Window {
7171
nodeOperatingSystems: string[];
7272
hubConsoleURL: string;
7373
k8sMode: string;
74+
techPreview: boolean;
7475
capabilities: {
7576
name: string;
7677
visibility: { state: 'Enabled' | 'Disabled' };

frontend/packages/console-app/console-extensions.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,9 @@
10221022
"group": "operators.coreos.com"
10231023
},
10241024
"startsWith": ["operators.coreos.com", "clusterserviceversions"]
1025+
},
1026+
"flags": {
1027+
"disallowed": ["OLMV1_ENABLED"]
10251028
}
10261029
},
10271030
{
@@ -2587,6 +2590,12 @@
25872590
"provider": { "$codeRef": "defaultProvider.useDefaultActionsProvider" }
25882591
}
25892592
},
2593+
{
2594+
"type": "console.flag/hookProvider",
2595+
"properties": {
2596+
"handler": { "$codeRef": "useTechPreviewFlagProvider" }
2597+
}
2598+
},
25902599
{
25912600
"type": "console.navigation/href",
25922601
"properties": {

frontend/packages/console-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
"consolePluginBackendDetail": "src/components/console-operator/ConsolePluginBackendDetail.tsx",
8080
"consolePluginProxyDetail": "src/components/console-operator/ConsolePluginProxyDetail.tsx",
8181
"getConsoleOperatorConfigFlag": "src/hooks/useCanGetConsoleOperatorConfig.ts",
82+
"useTechPreviewFlagProvider": "src/hooks/useTechPreviewFlagProvider.ts",
8283
"usePerspectivesAvailable": "src/components/user-preferences/perspective/usePerspectivesAvailable.ts",
8384
"defaultProvider": "src/actions/providers/default-provider.ts",
8485
"OperatorStatus": "src/components/dashboards-page/OperatorStatus.tsx",

frontend/packages/console-app/src/consts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const FLAG_DEVELOPER_PERSPECTIVE = 'DEVELOPER_PERSPECTIVE';
88
export const ACM_PERSPECTIVE_ID = 'acm';
99
export const ADMIN_PERSPECTIVE_ID = 'admin';
1010
export const FLAG_CAN_GET_CONSOLE_OPERATOR_CONFIG = 'CAN_GET_CONSOLE_OPERATOR_CONFIG';
11+
export const FLAG_TECH_PREVIEW = 'TECH_PREVIEW';
1112

1213
export const FAVORITES_CONFIG_MAP_KEY = 'console.favorites';
1314
export const FAVORITES_LOCAL_STORAGE_KEY = `${STORAGE_PREFIX}/favorites`;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { SetFeatureFlag } from '@console/dynamic-plugin-sdk/src/extensions/feature-flags';
2+
import { FLAG_TECH_PREVIEW } from '../consts';
3+
4+
type UseTechPreviewFlagProvider = (setFeatureFlag: SetFeatureFlag) => void;
5+
const useTechPreviewFlagProvider: UseTechPreviewFlagProvider = (setFeatureFlag) => {
6+
setFeatureFlag(FLAG_TECH_PREVIEW, !!window.SERVER_FLAGS.techPreview);
7+
};
8+
9+
export default useTechPreviewFlagProvider;

frontend/packages/console-shared/src/components/catalog/CatalogController.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@ import * as React from 'react';
22
import * as _ from 'lodash';
33
import { useTranslation } from 'react-i18next';
44
import { useLocation } from 'react-router-dom-v5-compat';
5+
import { FLAG_TECH_PREVIEW } from '@console/app/src/consts';
56
import { ResolvedExtension, CatalogItemType, CatalogCategory } from '@console/dynamic-plugin-sdk';
67
import { CatalogItem } from '@console/dynamic-plugin-sdk/src/extensions';
78
import { removeQueryArgument, setQueryArgument } from '@console/internal/components/utils/router';
89
import { skeletonCatalog } from '@console/internal/components/utils/skeleton-catalog';
910
import { StatusBox } from '@console/internal/components/utils/status-box';
11+
import OLMv1Alert from '@console/operator-lifecycle-manager-v1/src/components/OLMv1Alert';
12+
import { FLAG_OLMV1_ENABLED } from '@console/operator-lifecycle-manager-v1/src/const';
1013
import { DocumentTitle } from '@console/shared/src/components/document-title/DocumentTitle';
1114
import { PageHeading } from '@console/shared/src/components/heading/PageHeading';
15+
import { useFlag } from '../../hooks/flag';
1216
import { useQueryParams } from '../../hooks/useQueryParams';
1317
import PageBody from '../layout/PageBody';
1418
import CatalogView from './catalog-view/CatalogView';
@@ -50,6 +54,11 @@ const CatalogController: React.FC<CatalogControllerProps> = ({
5054
const { pathname } = useLocation();
5155
const queryParams = useQueryParams();
5256
const [disabledSubCatalogs] = useGetAllDisabledSubCatalogs();
57+
const techPreviewEnabled = useFlag(FLAG_TECH_PREVIEW);
58+
const olmv1Enabled = useFlag(FLAG_OLMV1_ENABLED);
59+
60+
// TODO(CONSOLE-4823): Remove this hard-coded alert when OLMv1 GAs
61+
const showOLMv1Alert = techPreviewEnabled && olmv1Enabled && type === 'operator';
5362

5463
const typeExtension: ResolvedExtension<CatalogItemType> = React.useMemo(
5564
() => catalogExtensions?.find((extension) => extension.properties.type === type),
@@ -183,6 +192,12 @@ const CatalogController: React.FC<CatalogControllerProps> = ({
183192
breadcrumbs={type ? breadcrumbs : null}
184193
helpText={getCatalogTypeDescription()}
185194
/>
195+
{/* TODO(CONSOLE-4823): Remove this hard-coded alert when OLMv1 GAs */}
196+
{showOLMv1Alert && (
197+
<div className="pf-v6-u-mx-md">
198+
<OLMv1Alert />
199+
</div>
200+
)}
186201
<StatusBox
187202
skeleton={skeletonCatalog}
188203
data={items}

frontend/packages/console-shared/src/components/catalog/catalog-view/CatalogCategories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const CatalogCategories: React.FC<CatalogCategoriesProp> = ({
2828
selectedCategoryID: string,
2929
toplevelCategory: boolean,
3030
) => {
31-
if (!categorizedIds[category.id]) return null;
31+
if (!category || !categorizedIds[category.id]) return null;
3232

3333
const { id, label, subcategories } = category;
3434
const active = id === selectedCategory;

frontend/packages/console-shared/src/components/catalog/catalog-view/CatalogToolbar.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
import { forwardRef } from 'react';
1+
import { forwardRef, Suspense } from 'react';
22
import { Flex, FlexItem, SearchInput } from '@patternfly/react-core';
33
import * as _ from 'lodash';
44
import { useTranslation } from 'react-i18next';
5+
import { FLAG_TECH_PREVIEW } from '@console/app/src/consts';
56
import { ConsoleSelect } from '@console/internal/components/utils/console-select';
6-
import { useDebounceCallback } from '@console/shared/src/hooks/debounce';
7+
// TODO(CONSOLE-4823): Remove this hard-coded component when OLMv1 GAs
8+
import { OLMv1Switch } from '@console/operator-lifecycle-manager-v1/src/components/OLMv1Switch';
9+
import { useDebounceCallback, useFlag } from '@console/shared/src/hooks';
710
import { NO_GROUPING } from '../utils/category-utils';
811
import { CatalogSortOrder, CatalogStringMap } from '../utils/types';
912
import CatalogPageHeader from './CatalogPageHeader';
@@ -18,6 +21,7 @@ type CatalogToolbarProps = {
1821
sortOrder: CatalogSortOrder;
1922
groupings: CatalogStringMap;
2023
activeGrouping: string;
24+
catalogType?: string;
2125
onGroupingChange: (grouping: string) => void;
2226
onSearchKeywordChange: (searchKeyword: string) => void;
2327
onSortOrderChange: (sortOrder: CatalogSortOrder) => void;
@@ -32,13 +36,18 @@ const CatalogToolbar = forwardRef<HTMLInputElement, CatalogToolbarProps>(
3236
sortOrder,
3337
groupings,
3438
activeGrouping,
39+
catalogType,
3540
onGroupingChange,
3641
onSearchKeywordChange,
3742
onSortOrderChange,
3843
},
3944
inputRef,
4045
) => {
4146
const { t } = useTranslation();
47+
const techPreviewEnabled = useFlag(FLAG_TECH_PREVIEW);
48+
49+
// TODO(CONSOLE-4823): Remove this hard-coded toggle when OLMv1 GAs
50+
const showOLMv1Toggle = techPreviewEnabled && catalogType === 'operator';
4251

4352
const catalogSortItems = {
4453
[CatalogSortOrder.RELEVANCE]: t('console-shared~Relevance'),
@@ -94,6 +103,14 @@ const CatalogToolbar = forwardRef<HTMLInputElement, CatalogToolbarProps>(
94103
/>
95104
</FlexItem>
96105
)}
106+
{/* TODO(CONSOLE-4823): Remove this hard-coded toggle when OLMv1 GAs */}
107+
{showOLMv1Toggle && (
108+
<FlexItem>
109+
<Suspense fallback={null}>
110+
<OLMv1Switch />
111+
</Suspense>
112+
</FlexItem>
113+
)}
97114
</Flex>
98115
<CatalogPageNumItems>
99116
{t('console-shared~{{totalItems}} items', { totalItems })}

frontend/packages/console-shared/src/components/catalog/catalog-view/CatalogView.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ const CatalogView: React.FC<CatalogViewProps> = ({
118118
}
119119
}, [catalogType, items.length]);
120120

121-
const handleCategoryChange = (categoryId) => {
121+
const handleCategoryChange = (categoryId: string) => {
122122
updateURLParams(CatalogQueryParams.CATEGORY, categoryId);
123123
};
124124

@@ -154,8 +154,8 @@ const CatalogView: React.FC<CatalogViewProps> = ({
154154
const allCategory = { id: ALL_CATEGORY, label: t('console-shared~All items') };
155155
const otherCategory = { id: OTHER_CATEGORY, label: t('console-shared~Other') };
156156
const sortedCategories = (categories ?? [])
157-
.filter((cat) => cat.id !== ALL_CATEGORY && cat.id !== OTHER_CATEGORY)
158-
.sort((a, b) => a.label.localeCompare(b.label));
157+
.filter((cat) => cat && cat.id !== ALL_CATEGORY && cat.id !== OTHER_CATEGORY)
158+
.sort((a, b) => (a.label ?? '').localeCompare(b.label ?? '') ?? 0);
159159
return [allCategory, ...sortedCategories, otherCategory];
160160
}, [categories, t]);
161161

@@ -341,6 +341,7 @@ const CatalogView: React.FC<CatalogViewProps> = ({
341341
sortOrder={sortOrder}
342342
groupings={groupings}
343343
activeGrouping={activeGrouping}
344+
catalogType={catalogType}
344345
onGroupingChange={handleGroupingChange}
345346
onSortOrderChange={handleSortOrderChange}
346347
onSearchKeywordChange={handleSearchKeywordChange}

0 commit comments

Comments
 (0)