Skip to content

Commit 2331571

Browse files
[ui-storagebrowser] refactor storage browser and folder structure (#3914)
[ui-storagebrowser] refactor storage browser and folder structure
1 parent d16de72 commit 2331571

29 files changed

+237
-237
lines changed

apps/filebrowser/src/filebrowser/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ def content_summary(request):
656656
replication_factor = request.fs.stats(path)['replication']
657657

658658
content_summary.summary.update({'replication': replication_factor})
659-
response['summary'] = content_summary.summary
659+
response = content_summary.summary
660660
except Exception:
661661
return HttpResponse(f'Failed to fetch content summary for path: {path}', status=500)
662662

desktop/core/src/desktop/js/apps/storageBrowser/FileChooserModal/FileChooserModal.tsx

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import useDebounce from '../../../utils/useDebounce';
2828
import useLoadData from '../../../utils/hooks/useLoadData';
2929

3030
import { ListDirectory } from '../../../reactComponents/FileChooser/types';
31-
import { VIEWFILES_API_URl } from '../../../reactComponents/FileChooser/api';
32-
import PathBrowser from '../../../reactComponents/FileChooser/PathBrowser/PathBrowser';
31+
import { LIST_DIRECTORY_API_URL } from '../../../reactComponents/FileChooser/api';
32+
import PathBrowser from '../../../reactComponents/PathBrowser/PathBrowser';
3333

3434
import './FileChooserModal.scss';
3535

@@ -66,16 +66,14 @@ const FileChooserModal = ({
6666
setDestPath(sourcePath);
6767
}, [sourcePath]);
6868

69-
const { data: filesData, loading } = useLoadData<ListDirectory>(
70-
`${VIEWFILES_API_URl}${destPath}`,
71-
{
72-
params: {
73-
pagesize: '1000',
74-
filter: searchTerm
75-
},
76-
skip: destPath === '' || destPath === undefined
77-
}
78-
);
69+
const { data: filesData, loading } = useLoadData<ListDirectory>(LIST_DIRECTORY_API_URL, {
70+
params: {
71+
path: destPath,
72+
pagesize: '1000',
73+
filter: searchTerm
74+
},
75+
skip: destPath === '' || destPath === undefined || !showModal
76+
});
7977

8078
const tableData: FileChooserTableData[] = useMemo(() => {
8179
if (!filesData?.files) {
@@ -139,9 +137,7 @@ const FileChooserModal = ({
139137
okText={submitText}
140138
title={title}
141139
open={showModal}
142-
onCancel={() => {
143-
onClose();
144-
}}
140+
onCancel={onClose}
145141
onOk={() => {
146142
onSubmit(destPath);
147143
onClose();
@@ -169,7 +165,7 @@ const FileChooserModal = ({
169165
<Spin spinning={loading}>
170166
<Table
171167
className="hue-filechooser-modal__table"
172-
dataSource={tableData?.slice(2)}
168+
dataSource={tableData}
173169
pagination={false}
174170
columns={getColumns(tableData[0] ?? {})}
175171
rowKey={(record, index) => record.path + index}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
// limitations under the License.
1616

1717
@use 'variables' as vars;
18-
@import '../../../components/styles/mixins';
18+
@use 'mixins';
1919

2020
.hue-storage-browser.antd.cuix {
21-
@include fillAbsolute;
22-
@include flexRowLayout;
21+
@include mixins.fillAbsolute;
22+
@include mixins.flexRowLayout;
2323

2424
height: 100%;
2525

@@ -50,4 +50,4 @@
5050
}
5151
}
5252
}
53-
}
53+
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ import { Tabs, Spin } from 'antd';
1919

2020
import DataBrowserIcon from '@cloudera/cuix-core/icons/react/DataBrowserIcon';
2121

22-
import { i18nReact } from '../../../utils/i18nReact';
23-
import CommonHeader from '../../../reactComponents/CommonHeader/CommonHeader';
24-
import StorageBrowserTabContent from './StorageBrowserTabContents/StorageBrowserTabContent';
25-
import { ApiFileSystem, FILESYSTEMS_API_URL } from '../../../reactComponents/FileChooser/api';
22+
import { i18nReact } from '../../utils/i18nReact';
23+
import CommonHeader from '../../reactComponents/CommonHeader/CommonHeader';
24+
import StorageBrowserTab from './StorageBrowserTab/StorageBrowserTab';
25+
import { ApiFileSystem, FILESYSTEMS_API_URL } from '../../reactComponents/FileChooser/api';
2626

2727
import './StorageBrowserPage.scss';
28-
import useLoadData from '../../../utils/hooks/useLoadData';
28+
import useLoadData from '../../utils/hooks/useLoadData';
2929

3030
const StorageBrowserPage = (): JSX.Element => {
3131
const { t } = i18nReact.useTranslation();
@@ -42,7 +42,7 @@ const StorageBrowserPage = (): JSX.Element => {
4242
items={fileSystems?.map(system => ({
4343
label: system.file_system.toUpperCase(),
4444
key: system.file_system + '_tab',
45-
children: <StorageBrowserTabContent homeDir={system.user_home_directory} />
45+
children: <StorageBrowserTab homeDir={system.user_home_directory} />
4646
}))}
4747
/>
4848
</Spin>
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
// See the License for the specific language governing permissions and
1515
// limitations under the License.
1616
@use 'variables' as vars;
17-
@use 'mixins';
1817

1918
.antd.cuix {
2019
.hue-storage-browser-tab-content {
@@ -51,4 +50,4 @@
5150
flex: 0 0 auto;
5251
font-weight: 600;
5352
}
54-
}
53+
}
Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@
1717
import React, { useState } from 'react';
1818
import { Spin } from 'antd';
1919

20-
import { i18nReact } from '../../../../utils/i18nReact';
20+
import { i18nReact } from '../../../utils/i18nReact';
2121
import BucketIcon from '@cloudera/cuix-core/icons/react/BucketIcon';
2222

23-
import PathBrowser from '../../../../reactComponents/FileChooser/PathBrowser/PathBrowser';
24-
import StorageBrowserTable from '../StorageBrowserTable/StorageBrowserTable';
25-
import { FILE_STATS_API_URL } from '../../../../reactComponents/FileChooser/api';
26-
import { BrowserViewType, FileStats } from '../../../../reactComponents/FileChooser/types';
27-
import useLoadData from '../../../../utils/hooks/useLoadData';
23+
import PathBrowser from '../../../reactComponents/PathBrowser/PathBrowser';
24+
import StorageDirectoryPage from '../StorageDirectoryPage/StorageDirectoryPage';
25+
import { FILE_STATS_API_URL } from '../../../reactComponents/FileChooser/api';
26+
import { BrowserViewType, FileStats } from '../../../reactComponents/FileChooser/types';
27+
import useLoadData from '../../../utils/hooks/useLoadData';
2828

29-
import './StorageBrowserTabContent.scss';
30-
import StorageFilePage from '../../StorageFilePage/StorageFilePage';
29+
import './StorageBrowserTab.scss';
30+
import StorageFilePage from '../StorageFilePage/StorageFilePage';
3131

32-
interface StorageBrowserTabContentProps {
32+
interface StorageBrowserTabProps {
3333
homeDir: string;
3434
testId?: string;
3535
}
@@ -38,10 +38,7 @@ const defaultProps = {
3838
testId: 'hue-storage-browser-tab-content'
3939
};
4040

41-
const StorageBrowserTabContent = ({
42-
homeDir,
43-
testId
44-
}: StorageBrowserTabContentProps): JSX.Element => {
41+
const StorageBrowserTab = ({ homeDir, testId }: StorageBrowserTabProps): JSX.Element => {
4542
const [filePath, setFilePath] = useState<string>(homeDir);
4643
const fileName = filePath?.split('/')?.pop() ?? '';
4744

@@ -76,7 +73,7 @@ const StorageBrowserTabContent = ({
7673
/>
7774
</div>
7875
{fileStats?.type === BrowserViewType.dir && (
79-
<StorageBrowserTable fileStats={fileStats} onFilePathChange={setFilePath} />
76+
<StorageDirectoryPage fileStats={fileStats} onFilePathChange={setFilePath} />
8077
)}
8178
{fileStats?.type === BrowserViewType.file && (
8279
<StorageFilePage fileName={fileName} fileStats={fileStats} />
@@ -86,6 +83,6 @@ const StorageBrowserTabContent = ({
8683
);
8784
};
8885

89-
StorageBrowserTabContent.defaultProps = defaultProps;
86+
StorageBrowserTab.defaultProps = defaultProps;
9087

91-
export default StorageBrowserTabContent;
88+
export default StorageBrowserTab;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// See the License for the specific language governing permissions and
1515
// limitations under the License.
1616
@use 'mixins';
17-
@use 'variables' as vars;
17+
1818
$action-dropdown-width: 214px;
1919

2020
.hue-storage-browser__table-actions-dropdown {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import DuplicateIcon from '@cloudera/cuix-core/icons/react/DuplicateIcon';
2525
import CopyClipboardIcon from '@cloudera/cuix-core/icons/react/CopyClipboardIcon';
2626

2727
import { i18nReact } from '../../../../utils/i18nReact';
28-
import { StorageBrowserTableData } from '../../../../reactComponents/FileChooser/types';
2928
import {
3029
isHDFS,
3130
isOFS,
@@ -49,15 +48,16 @@ import {
4948
import huePubSub from '../../../../utils/huePubSub';
5049
import useSaveData from '../../../../utils/hooks/useSaveData';
5150

52-
import SummaryModal from '../../SummaryModal/SummaryModal';
51+
import SummaryModal from '../SummaryModal/SummaryModal';
5352
import InputModal from '../../InputModal/InputModal';
5453
import FileChooserModal from '../../FileChooserModal/FileChooserModal';
5554

5655
import './StorageBrowserActions.scss';
56+
import { StorageDirectoryTableData } from '../../../../reactComponents/FileChooser/types';
5757

5858
interface StorageBrowserRowActionsProps {
5959
currentPath: string;
60-
selectedFiles: StorageBrowserTableData[];
60+
selectedFiles: StorageDirectoryTableData[];
6161
onSuccessfulAction: () => void;
6262
setLoadingFiles: (value: boolean) => void;
6363
}

0 commit comments

Comments
 (0)