From 0e0be3d91d99168470bd7036b53a3d0585ac460d Mon Sep 17 00:00:00 2001 From: SanjalKatiyar Date: Mon, 14 Oct 2024 14:17:05 +0530 Subject: [PATCH] Cleanup + Bug fixes --- locales/en/plugin__odf-console.json | 2 + .../object-service.tsx | 10 ++- .../components/resource-pages/list-page.tsx | 4 +- .../s3-browser/bucket-overview/PageTitle.tsx | 48 +++++++++++- .../buckets-list-page/bucketPagination.tsx | 23 +++++- .../s3-browser/objects-list/ObjectsList.tsx | 12 +++ .../objects-list/table-components.tsx | 12 ++- .../s3-browser/pagination-helper.tsx | 78 ++++++++++++++++--- packages/odf/constants/s3-browser.ts | 3 +- packages/shared/src/s3/commands.ts | 18 ++--- packages/shared/src/s3/types.ts | 26 +++---- plugins/odf/console-extensions.json | 6 ++ 12 files changed, 195 insertions(+), 47 deletions(-) diff --git a/locales/en/plugin__odf-console.json b/locales/en/plugin__odf-console.json index e9bb991cf..895aca955 100644 --- a/locales/en/plugin__odf-console.json +++ b/locales/en/plugin__odf-console.json @@ -1154,6 +1154,8 @@ "Share with presigned URL": "Share with presigned URL", "No objects found": "No objects found", "You do not have any objects in the bucket": "You do not have any objects in the bucket", + "many": "many", + "{{ fromCount }} - {{ toCount }} of {{ totalCount }}": "{{ fromCount }} - {{ toCount }} of {{ totalCount }}", "<0>The amount of storage allocated to the client cluster for usage.<1>Due to simultaneous usage by multiple client clusters, actual available storage may vary affecting your allocated storage quota.": "<0>The amount of storage allocated to the client cluster for usage.<1>Due to simultaneous usage by multiple client clusters, actual available storage may vary affecting your allocated storage quota.", "No storage clients found.": "No storage clients found.", "You do not have any storage clients connected to this Data Foundation provider cluster.": "You do not have any storage clients connected to this Data Foundation provider cluster.", diff --git a/packages/odf/components/object-service-nav-item/object-service.tsx b/packages/odf/components/object-service-nav-item/object-service.tsx index c06d40475..f8dfbec8f 100644 --- a/packages/odf/components/object-service-nav-item/object-service.tsx +++ b/packages/odf/components/object-service-nav-item/object-service.tsx @@ -16,6 +16,7 @@ import Tabs, { TabPage } from '@odf/shared/utils/Tabs'; import { useResolvedExtensions, NamespaceBar, + useFlag, } from '@openshift-console/dynamic-plugin-sdk'; import { Extension, @@ -28,6 +29,8 @@ import { useLocation, useNavigate, } from 'react-router-dom-v5-compat'; +import { BUCKETS_BASE_ROUTE } from '../../constants'; +import { MCG_STANDALONE } from '../../features'; const OBJECT_SERVICE_CONTEXT = 'odf-object-service'; const NAMESPACE_BAR_PATHS = [referenceForModel(NooBaaObjectBucketClaimModel)]; @@ -39,6 +42,8 @@ const ObjectServicePage: React.FC = () => { const { t } = useCustomTranslation(); const title = t('Object Storage'); + const isMCGStandalone = useFlag(MCG_STANDALONE); + const [extensions, isLoaded, error] = useResolvedExtensions( isObjectServiceTab as ExtensionTypeGuard ); @@ -60,12 +65,13 @@ const ObjectServicePage: React.FC = () => { React.useEffect(() => { if ( (location.pathname.endsWith('/odf/object-storage') || - location.pathname.endsWith('/odf/object-storage/')) && + location.pathname.endsWith('/odf/object-storage/') || + (!isMCGStandalone && location.pathname.includes(BUCKETS_BASE_ROUTE))) && !_.isEmpty(sortedPages) ) { navigate('/odf/object-storage/' + sortedPages[0].href, { replace: true }); } - }, [location.pathname, navigate, sortedPages]); + }, [location.pathname, navigate, sortedPages, isMCGStandalone]); const showNamespaceBar = NAMESPACE_BAR_PATHS.some((path) => location.pathname.includes(path) diff --git a/packages/odf/components/resource-pages/list-page.tsx b/packages/odf/components/resource-pages/list-page.tsx index eb0806df8..dd55df248 100644 --- a/packages/odf/components/resource-pages/list-page.tsx +++ b/packages/odf/components/resource-pages/list-page.tsx @@ -211,8 +211,8 @@ const GenericListPage: React.FC = ({ hideColumnManagement={true} /> = ({ +type BucketResourceStatusProps = { resourceStatus: string }; + +type FavoriteProps = { bucketName: string }; + +const BucketResourceStatus: React.FC = ({ resourceStatus, }) => ( @@ -25,6 +37,33 @@ const BucketResourceStatus: React.FC<{ resourceStatus: string }> = ({ ); +const Favorite: React.FC = ({ bucketName }) => { + const [favorites, setFavorites] = useUserSettingsLocalStorage( + BUCKET_BOOKMARKS_USER_SETTINGS_KEY, + true, + [] + ); + const isFavorite = favorites?.find((bucket) => bucket === bucketName); + + const onClick = () => { + if (isFavorite) + setFavorites((oldFavorites) => + oldFavorites.filter((bucket) => bucket === bucketName) + ); + else setFavorites((oldFavorites) => [...oldFavorites, bucketName]); + }; + + return ( + + ); +}; + export const PageTitle: React.FC = ({ bucketName, foldersPath, @@ -47,10 +86,11 @@ export const PageTitle: React.FC = ({ {!foldersPath ? bucketName : currentFolder} {!foldersPath && ( <> + {/* ToDo: Currently we only support MCG, make is configurable once RGW is supported as well */}