From c192c89a48560e81a9f1e28df9b814d9a5abc35d Mon Sep 17 00:00:00 2001 From: dlpzx Date: Thu, 5 Dec 2024 12:02:22 +0100 Subject: [PATCH] Implement printUnauthorized utility for FE --- .../src/modules/S3_Datasets/components/DatasetFolders.js | 8 ++++---- .../src/modules/S3_Datasets/components/DatasetTables.js | 9 +++++---- frontend/src/utils/helpers/emptyPrintUnauthorized.js | 5 +++++ frontend/src/utils/helpers/index.js | 1 + 4 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 frontend/src/utils/helpers/emptyPrintUnauthorized.js diff --git a/frontend/src/modules/S3_Datasets/components/DatasetFolders.js b/frontend/src/modules/S3_Datasets/components/DatasetFolders.js index 32d40ead8..ab5e4a446 100644 --- a/frontend/src/modules/S3_Datasets/components/DatasetFolders.js +++ b/frontend/src/modules/S3_Datasets/components/DatasetFolders.js @@ -37,6 +37,7 @@ import { } from 'design'; import { SET_ERROR, useDispatch } from 'globalErrors'; import { deleteDatasetStorageLocation, useClient } from 'services'; +import { emptyPrintUnauthorized } from 'utils'; import { listDatasetStorageLocations } from '../services'; import { FolderCreateModal } from './FolderCreateModal'; @@ -224,10 +225,9 @@ export const DatasetFolders = (props) => { - {`s3://${ - folder.restricted?.S3BucketName || - 'UNAUTHORIZED_INFO' - }/${folder.S3Prefix}`} + {`s3://${emptyPrintUnauthorized( + folder.restricted?.S3BucketName + )}/${folder.S3Prefix}`} {folder.description} diff --git a/frontend/src/modules/S3_Datasets/components/DatasetTables.js b/frontend/src/modules/S3_Datasets/components/DatasetTables.js index cf7a94183..32f7774cc 100644 --- a/frontend/src/modules/S3_Datasets/components/DatasetTables.js +++ b/frontend/src/modules/S3_Datasets/components/DatasetTables.js @@ -40,7 +40,7 @@ import { listDatasetTables, deleteDatasetTable, useClient } from 'services'; import { syncTables } from '../services'; import { DatasetStartCrawlerModal } from './DatasetStartCrawlerModal'; -import { isFeatureEnabled } from 'utils'; +import { emptyPrintUnauthorized, isFeatureEnabled } from 'utils'; export const DatasetTables = (props) => { const { dataset, isAdmin } = props; @@ -261,11 +261,12 @@ export const DatasetTables = (props) => { - {table.restricted?.GlueDatabaseName || - 'UNAUTHORIZED_INFO'} + {emptyPrintUnauthorized( + table.restricted?.GlueDatabaseName + )} - {table.restricted?.S3Prefix || 'UNAUTHORIZED_INFO'} + {emptyPrintUnauthorized(table.restricted?.S3Prefix)} {isAdmin && ( diff --git a/frontend/src/utils/helpers/emptyPrintUnauthorized.js b/frontend/src/utils/helpers/emptyPrintUnauthorized.js new file mode 100644 index 000000000..b80d33c29 --- /dev/null +++ b/frontend/src/utils/helpers/emptyPrintUnauthorized.js @@ -0,0 +1,5 @@ +function emptyPrintUnauthorized(param) { + return param ? param : 'UNAUTHORIZED_INFO'; +} + +export { emptyPrintUnauthorized }; diff --git a/frontend/src/utils/helpers/index.js b/frontend/src/utils/helpers/index.js index 5eec0fd36..b00b552f5 100644 --- a/frontend/src/utils/helpers/index.js +++ b/frontend/src/utils/helpers/index.js @@ -1,5 +1,6 @@ export * from './bytesToSize'; export * from './dayjs'; +export * from './emptyPrintUnauthorized'; export * from './listToTree'; export * from './moduleUtils'; export * from './linkMarkup';