From 7f09467a0dd7b177ce632bd05b016ce319655ee6 Mon Sep 17 00:00:00 2001 From: Caleb Pollman Date: Thu, 7 Nov 2024 09:39:11 -0800 Subject: [PATCH] fix(storage-browser): move LOCATION_DETAIL_VIEW_HEADERS to constants file (#6022) --- .../constants.ts | 10 ++++++++ .../getFileRowContent.ts | 6 +++-- .../getFolderRowContent.ts | 2 +- .../getLocationDetailViewTableData.ts | 23 ++----------------- .../getLocationDetailViewTableData/types.ts | 15 ++++++++++++ 5 files changed, 32 insertions(+), 24 deletions(-) create mode 100644 packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/constants.ts create mode 100644 packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/types.ts diff --git a/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/constants.ts b/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/constants.ts new file mode 100644 index 00000000000..c61327d023d --- /dev/null +++ b/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/constants.ts @@ -0,0 +1,10 @@ +import { LocationDetailViewHeaders } from './types'; + +export const LOCATION_DETAIL_VIEW_HEADERS: LocationDetailViewHeaders = [ + { key: 'checkbox', type: 'text', content: { text: '' } }, + { key: 'name', type: 'sort', content: { label: 'Name' } }, + { key: 'type', type: 'sort', content: { label: 'Type' } }, + { key: 'last-modified', type: 'sort', content: { label: 'Last Modified' } }, + { key: 'size', type: 'sort', content: { label: 'Size' } }, + { key: 'download', type: 'text', content: { text: '' } }, +]; diff --git a/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getFileRowContent.ts b/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getFileRowContent.ts index c9f3a808c6b..b2e5b1d466b 100644 --- a/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getFileRowContent.ts +++ b/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getFileRowContent.ts @@ -1,9 +1,11 @@ +import { humanFileSize } from '@aws-amplify/ui'; + import { DataTableProps } from '../../../composables/DataTable'; import { LocationData } from '../../../actions'; -import { LOCATION_DETAIL_VIEW_HEADERS } from './getLocationDetailViewTableData'; -import { humanFileSize } from '@aws-amplify/ui'; import { displayText } from '../../../displayText/en'; +import { LOCATION_DETAIL_VIEW_HEADERS } from './constants'; + export const getFileRowContent = ({ currentLocation, currentPath, diff --git a/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getFolderRowContent.ts b/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getFolderRowContent.ts index 1eede4ca725..e6809607c15 100644 --- a/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getFolderRowContent.ts +++ b/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getFolderRowContent.ts @@ -1,5 +1,5 @@ import { DataTableProps } from '../../../composables/DataTable'; -import { LOCATION_DETAIL_VIEW_HEADERS } from './getLocationDetailViewTableData'; +import { LOCATION_DETAIL_VIEW_HEADERS } from './constants'; export const getFolderRowContent = ({ itemSubPath, diff --git a/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getLocationDetailViewTableData.ts b/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getLocationDetailViewTableData.ts index 2ccf13bc2d2..26a6f3e9dc3 100644 --- a/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getLocationDetailViewTableData.ts +++ b/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getLocationDetailViewTableData.ts @@ -1,31 +1,12 @@ -import { WithKey } from '../../../components/types'; import { DataTableProps } from '../../../composables/DataTable'; import { LocationData } from '../../../actions'; -import { LocationItemData } from '../../../../../../dist/types/components/StorageBrowser/actions'; +import { LocationItemData } from '../../../actions/handlers'; import { getFileRowContent } from './getFileRowContent'; import { getFolderRowContent } from './getFolderRowContent'; import { displayText } from '../../../displayText/en'; import { FileData } from '../../../actions/handlers'; -type HeaderKeys = - | 'checkbox' - | 'name' - | 'type' - | 'last-modified' - | 'size' - | 'download'; - -export const LOCATION_DETAIL_VIEW_HEADERS: WithKey< - DataTableProps['headers'][number], - HeaderKeys ->[] = [ - { key: 'checkbox', type: 'text', content: { text: '' } }, - { key: 'name', type: 'sort', content: { label: 'Name' } }, - { key: 'type', type: 'sort', content: { label: 'Type' } }, - { key: 'last-modified', type: 'sort', content: { label: 'Last Modified' } }, - { key: 'size', type: 'sort', content: { label: 'Size' } }, - { key: 'download', type: 'text', content: { text: '' } }, -]; +import { LOCATION_DETAIL_VIEW_HEADERS } from './constants'; export const getLocationDetailViewTableData = ({ areAllFilesSelected, diff --git a/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/types.ts b/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/types.ts new file mode 100644 index 00000000000..adcee7dc2db --- /dev/null +++ b/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/types.ts @@ -0,0 +1,15 @@ +import { DataTableProps } from '../../../composables/DataTable'; +import { WithKey } from '../../../components/types'; + +export type HeaderKeys = + | 'checkbox' + | 'name' + | 'type' + | 'last-modified' + | 'size' + | 'download'; + +export type LocationDetailViewHeaders = WithKey< + DataTableProps['headers'][number], + HeaderKeys +>[];