Skip to content

Commit 02c2b2d

Browse files
[ui-storagebrowser] change label of HDFS root from / to hdfs (#4069)
1 parent 9f9a4f1 commit 02c2b2d

File tree

19 files changed

+158
-94
lines changed

19 files changed

+158
-94
lines changed

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,7 @@ const FileChooserModal = ({
146146
>
147147
<div className="hue-filechooser-modal__body">
148148
<div className="hue-filechooser-modal__path-browser-panel">
149-
<PathBrowser
150-
filePath={destPath}
151-
onFilepathChange={setDestPath}
152-
seperator={'/'}
153-
showIcon={false}
154-
/>
149+
<PathBrowser filePath={destPath} onFilepathChange={setDestPath} showIcon={false} />
155150
</div>
156151
<Input
157152
className="hue-filechooser-modal__search"

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ import { BorderlessButton } from 'cuix/dist/components/Button';
3232
import StorageFilePage from '../StorageFilePage/StorageFilePage';
3333
import changeURL from '../../../utils/url/changeURL';
3434
import LoadingErrorWrapper from '../../../reactComponents/LoadingErrorWrapper/LoadingErrorWrapper';
35-
import { getFileSystemAndPath } from '../../../reactComponents/PathBrowser/PathBrowser.util';
35+
import {
36+
getLastDirOrFileNameFromPath,
37+
getFileSystemAndPath
38+
} from '../../../reactComponents/PathBrowser/PathBrowser.util';
3639
import { inTrash } from '../../../utils/storageBrowserUtils';
3740

3841
import './StorageBrowserTab.scss';
@@ -55,8 +58,7 @@ const StorageBrowserTab = ({ fileSystem, testId }: StorageBrowserTabProps): JSX.
5558
urlFileSystem === fileSystem.name ? urlFilePath : fileSystem.userHomeDirectory;
5659

5760
const [filePath, setFilePath] = useState<string>(initialFilePath);
58-
const fileName =
59-
filePath.split('/').pop() !== '' ? (filePath.split('/').pop() ?? '') : filePath.split('://')[0];
61+
const fileName = getLastDirOrFileNameFromPath(filePath);
6062

6163
const { t } = i18nReact.useTranslation();
6264

@@ -188,12 +190,7 @@ const StorageBrowserTab = ({ fileSystem, testId }: StorageBrowserTabProps): JSX.
188190
className="hue-storage-browser-tab__path-browser-container"
189191
data-testid={`${testId}-path-browser-panel`}
190192
>
191-
<PathBrowser
192-
filePath={filePath}
193-
onFilepathChange={setFilePath}
194-
seperator={'/'}
195-
showIcon={false}
196-
/>
193+
<PathBrowser filePath={filePath} onFilepathChange={setFilePath} />
197194
</div>
198195
{fileStats?.type === BrowserViewType.dir && !isLoading && (
199196
<StorageDirectoryPage
@@ -204,7 +201,7 @@ const StorageBrowserTab = ({ fileSystem, testId }: StorageBrowserTabProps): JSX.
204201
/>
205202
)}
206203
{fileStats?.type === BrowserViewType.file && !isLoading && (
207-
<StorageFilePage fileName={fileName} fileStats={fileStats} onReload={reloadData} />
204+
<StorageFilePage fileStats={fileStats} onReload={reloadData} />
208205
)}
209206
</div>
210207
</LoadingErrorWrapper>

desktop/core/src/desktop/js/apps/storageBrowser/StorageDirectoryPage/StorageDirectoryActions/FileAndFolder/ChangeOwnerAndGroupModal/ChangeOwnerAndGroupModal.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ import Modal from 'cuix/dist/components/Modal';
1919
import { i18nReact } from '../../../../../../utils/i18nReact';
2020
import useSaveData from '../../../../../../utils/hooks/useSaveData/useSaveData';
2121
import { Checkbox, Input, Select } from 'antd';
22-
import { ListDirectory, StorageDirectoryTableData } from '../../../../types';
22+
import { HDFSFileSystemConfig, StorageDirectoryTableData } from '../../../../types';
2323
import { BULK_CHANGE_OWNER_API_URL } from '../../../../api';
2424
import './ChangeOwnerAndGroupModal.scss';
2525

2626
interface ChangeOwnerAndGroupModalProps {
27-
superUser?: ListDirectory['superuser'];
28-
superGroup?: ListDirectory['supergroup'];
29-
users?: ListDirectory['users'];
30-
groups?: ListDirectory['groups'];
27+
superUser?: HDFSFileSystemConfig['superuser'];
28+
superGroup?: HDFSFileSystemConfig['supergroup'];
29+
users?: HDFSFileSystemConfig['users'];
30+
groups?: HDFSFileSystemConfig['groups'];
3131
isOpen?: boolean;
3232
files: StorageDirectoryTableData[];
3333
setLoading: (value: boolean) => void;
@@ -37,7 +37,9 @@ interface ChangeOwnerAndGroupModalProps {
3737
}
3838

3939
const OTHERS_KEY = 'others';
40-
const getDropdownOptions = (entity: ListDirectory['users'] | ListDirectory['groups']) => {
40+
const getDropdownOptions = (
41+
entity: HDFSFileSystemConfig['users'] | HDFSFileSystemConfig['groups']
42+
) => {
4143
return [...entity, OTHERS_KEY].map(user => ({
4244
value: user,
4345
label: user

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import PaginatedTable, {
4848
SortOrder,
4949
ColumnProps
5050
} from '../../../reactComponents/PaginatedTable/PaginatedTable';
51+
import { getLastDirOrFileNameFromPath } from '../../../reactComponents/PathBrowser/PathBrowser.util';
5152

5253
interface StorageDirectoryPageProps {
5354
fileStats: FileStats;
@@ -110,7 +111,7 @@ const StorageDirectoryPage = ({
110111
}
111112

112113
return filesData?.files?.map(file => ({
113-
name: file.path.split('/').pop() ?? '',
114+
name: getLastDirOrFileNameFromPath(file.path),
114115
size: file.type === BrowserViewType.file ? formatBytes(file.size) : '',
115116
user: file.user,
116117
group: file.group,

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,16 @@ import useLoadData from '../../../utils/hooks/useLoadData/useLoadData';
3333
import { getLastKnownConfig } from '../../../config/hueConfig';
3434
import LoadingErrorWrapper from '../../../reactComponents/LoadingErrorWrapper/LoadingErrorWrapper';
3535
import { inTrash } from '../../../utils/storageBrowserUtils';
36+
import { getLastDirOrFileNameFromPath } from '../../../reactComponents/PathBrowser/PathBrowser.util';
3637

3738
interface StorageFilePageProps {
3839
onReload: () => void;
39-
fileName: string;
4040
fileStats: FileStats;
4141
}
4242

43-
const StorageFilePage = ({ fileName, fileStats, onReload }: StorageFilePageProps): JSX.Element => {
43+
const StorageFilePage = ({ fileStats, onReload }: StorageFilePageProps): JSX.Element => {
4444
const config = getLastKnownConfig();
45+
const fileName = getLastDirOrFileNameFromPath(fileStats.path);
4546
const fileType = getFileType(fileName);
4647

4748
const { t } = i18nReact.useTranslation();
@@ -54,11 +55,7 @@ const StorageFilePage = ({ fileName, fileStats, onReload }: StorageFilePageProps
5455

5556
const { loading: isSaving, save } = useSaveData(SAVE_FILE_API_URL);
5657

57-
const {
58-
data: fileData,
59-
loading: loadingPreview,
60-
error: errorPreview
61-
} = useLoadData<FilePreview>(FILE_PREVIEW_API_URL, {
58+
const { data, loading, error } = useLoadData<FilePreview>(FILE_PREVIEW_API_URL, {
6259
params: {
6360
path: fileStats.path,
6461
offset: pageOffset,
@@ -80,7 +77,7 @@ const StorageFilePage = ({ fileName, fileStats, onReload }: StorageFilePageProps
8077

8178
const handleCancel = () => {
8279
setIsEditing(false);
83-
setFileContent(fileData?.contents);
80+
setFileContent(data?.contents);
8481
};
8582

8683
const handleSave = () => {
@@ -126,7 +123,7 @@ const StorageFilePage = ({ fileName, fileStats, onReload }: StorageFilePageProps
126123

127124
const errorConfig = [
128125
{
129-
enabled: !!errorPreview,
126+
enabled: !!error,
130127
message: t('An error occurred while fetching file content for path "{{path}}".', {
131128
path: fileStats.path
132129
}),
@@ -151,7 +148,7 @@ const StorageFilePage = ({ fileName, fileStats, onReload }: StorageFilePageProps
151148
))}
152149
</div>
153150

154-
<LoadingErrorWrapper loading={loadingPreview || isSaving} errors={errorConfig}>
151+
<LoadingErrorWrapper loading={loading || isSaving} errors={errorConfig} hideChildren>
155152
<div className="preview">
156153
<div className="preview__title-bar">
157154
{t('Content')}
@@ -171,7 +168,7 @@ const StorageFilePage = ({ fileName, fileStats, onReload }: StorageFilePageProps
171168
data-testid="preview--save--button"
172169
data-event=""
173170
onClick={handleSave}
174-
disabled={fileContent === fileData?.contents}
171+
disabled={fileContent === data?.contents}
175172
>
176173
{t('Save')}
177174
</PrimaryButton>

desktop/core/src/desktop/js/reactComponents/FileChooser/FileChooserModal/FileChooserModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ const FileChooserModal: React.FC<FileProps> = ({ show, onCancel, title, okText }
104104
<PathBrowser
105105
filePath={filePath}
106106
onFilepathChange={setFilePath}
107-
seperator={'>'}
107+
separator={'>'}
108108
showIcon={true}
109109
/>
110110
)}

desktop/core/src/desktop/js/reactComponents/LoadingErrorWrapper/LoadingErrorWrapper.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,10 @@
2222
align-items: center;
2323
gap: 16px;
2424
}
25+
26+
.antd.cuix {
27+
.loading-error-wrapper__spinner {
28+
// this overrides the max-height: 400px in antd library
29+
max-height: 100% !important;
30+
}
31+
}

desktop/core/src/desktop/js/reactComponents/LoadingErrorWrapper/LoadingErrorWrapper.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('LoadingErrorWrapper', () => {
1515
<LoadingErrorWrapper {...defaultProps} loading={true} />
1616
);
1717

18-
expect(getAllByTestId('loading-error-wrapper__sppiner')).toHaveLength(2);
18+
expect(getAllByTestId('loading-error-wrapper__spinner')).toHaveLength(2);
1919
expect(queryByText('Children Content')).toBeInTheDocument();
2020
});
2121

desktop/core/src/desktop/js/reactComponents/LoadingErrorWrapper/LoadingErrorWrapper.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,23 @@ interface LoadingErrorWrapperProps {
3030
loading: boolean;
3131
errors: WrapperError[];
3232
children: React.ReactNode;
33+
hideChildren?: boolean;
3334
}
3435

3536
const LoadingErrorWrapper = ({
3637
loading,
3738
errors,
38-
children
39+
children,
40+
hideChildren = false
3941
}: LoadingErrorWrapperProps): JSX.Element => {
4042
if (loading) {
41-
// TODO: discuss in UI meeting, if we need to render children while loading
42-
// Initial thoughts:
43-
// -- On first render -> hide children
44-
// -- On re-render -> render children
4543
return (
46-
<Spin spinning={loading} data-testid="loading-error-wrapper__sppiner">
47-
{children}
44+
<Spin
45+
spinning={loading}
46+
data-testid="loading-error-wrapper__spinner"
47+
className="loading-error-wrapper__spinner"
48+
>
49+
{hideChildren === false && children}
4850
</Spin>
4951
);
5052
}

desktop/core/src/desktop/js/reactComponents/PathBrowser/Breadcrumb/Breadcrumb.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import React from 'react';
1818

19-
import OverflowingItem from '../OverflowingItem';
19+
import OverflowingItem from '../OverflowingItem/OverflowingItem';
2020
import './Breadcrumb.scss';
2121

2222
interface BreadcrumbProps {

desktop/core/src/desktop/js/reactComponents/PathBrowser/PathBrowser.scss

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ $icon-height: 24px;
2525
display: contents;
2626

2727
.hue-path-browser__file-system-icon {
28-
object-fit: cover;
29-
width: $icon-width;
30-
height: $icon-height;
31-
margin: 0 vars.$fluidx-spacing-xs;
28+
margin-right: vars.$fluidx-spacing-xs;
29+
30+
svg {
31+
vertical-align: middle;
32+
width: $icon-width;
33+
height: $icon-height;
34+
35+
}
3236
}
3337
}
3438

@@ -55,7 +59,7 @@ $icon-height: 24px;
5559
}
5660
}
5761

58-
.hue-path-browser__breadcrumb-seperator {
62+
.hue-path-browser__breadcrumb-separator {
5963
display: flex;
6064
justify-content: center;
6165
align-items: center;

desktop/core/src/desktop/js/reactComponents/PathBrowser/PathBrowser.test.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,31 @@ describe('Pathbrowser', () => {
3030
const mockFilePath = 'abfs://test/folder';
3131
const mockLongFilePath = 'abfs://path/to/nested1/nested2/nested3/folder';
3232
describe('Pathbrowser breadcrumbs', () => {
33-
it('should render the specified seperator to seperate the breadcrumbs', () => {
33+
it('should render the specified separator to separate the breadcrumbs', () => {
3434
render(
3535
<PathBrowser
3636
filePath={mockFilePath}
3737
onFilepathChange={onFilepathChangeMock}
38-
seperator={'%'}
38+
separator={'%'}
3939
showIcon
4040
/>
4141
);
42-
const seperator = screen.getAllByText('%');
43-
expect(seperator).not.toBeNull();
42+
const separator = screen.getAllByText('%');
43+
expect(separator).not.toBeNull();
4444
});
4545

46-
it('should not render a different seperator than specified to seperate the breadcrumbs', () => {
46+
it('should not render a different separator than specified to separate the breadcrumbs', () => {
4747
render(
4848
<PathBrowser
4949
testId="pathbroswer"
5050
filePath={mockFilePath}
5151
onFilepathChange={onFilepathChangeMock}
52-
seperator={'%'}
52+
separator={'%'}
5353
showIcon
5454
/>
5555
);
5656
screen
57-
.getAllByTestId('pathbroswer-breadcrumb-seperator')
57+
.getAllByTestId('pathbroswer-breadcrumb-separator')
5858
.slice(1)
5959
.forEach(element => {
6060
expect(element).toBeVisible();
@@ -67,7 +67,7 @@ describe('Pathbrowser', () => {
6767
<PathBrowser
6868
filePath={mockFilePath}
6969
onFilepathChange={onFilepathChangeMock}
70-
seperator={'/'}
70+
separator={'/'}
7171
showIcon
7272
/>
7373
);
@@ -79,7 +79,7 @@ describe('Pathbrowser', () => {
7979
<PathBrowser
8080
onFilepathChange={onFilepathChangeMock}
8181
filePath={mockLongFilePath}
82-
seperator={'/'}
82+
separator={'/'}
8383
showIcon
8484
/>
8585
);
@@ -92,7 +92,7 @@ describe('Pathbrowser', () => {
9292
<PathBrowser
9393
onFilepathChange={onFilepathChangeMock}
9494
filePath={mockLongFilePath}
95-
seperator={'/'}
95+
separator={'/'}
9696
showIcon
9797
/>
9898
);
@@ -109,7 +109,7 @@ describe('Pathbrowser', () => {
109109
<PathBrowser
110110
onFilepathChange={onFilepathChangeMock}
111111
filePath={mockFilePath}
112-
seperator={'/'}
112+
separator={'/'}
113113
showIcon={false}
114114
/>
115115
);
@@ -124,7 +124,7 @@ describe('Pathbrowser', () => {
124124
<PathBrowser
125125
onFilepathChange={onFilepathChangeMock}
126126
filePath={mockFilePath}
127-
seperator={'/'}
127+
separator={'/'}
128128
showIcon
129129
/>
130130
);
@@ -137,7 +137,7 @@ describe('Pathbrowser', () => {
137137
<PathBrowser
138138
onFilepathChange={onFilepathChangeMock}
139139
filePath={mockFilePath}
140-
seperator={'/'}
140+
separator={'/'}
141141
showIcon={false}
142142
/>
143143
);
@@ -152,7 +152,7 @@ describe('Pathbrowser', () => {
152152
<PathBrowser
153153
onFilepathChange={onFilepathChangeMock}
154154
filePath={mockFilePath}
155-
seperator={'/'}
155+
separator={'/'}
156156
showIcon
157157
/>
158158
);
@@ -165,7 +165,7 @@ describe('Pathbrowser', () => {
165165
<PathBrowser
166166
onFilepathChange={onFilepathChangeMock}
167167
filePath={mockFilePath}
168-
seperator={'/'}
168+
separator={'/'}
169169
showIcon
170170
/>
171171
);

0 commit comments

Comments
 (0)