Skip to content

[ui-storageBrowser] Implement storage browser actions #3877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Dec 12, 2024

Conversation

nidhibhatg
Copy link
Collaborator

@nidhibhatg nidhibhatg commented Nov 4, 2024

What changes were proposed in this pull request?

  • Improvements on content summary
  • Update create new files based on new public api
  • Update create new folders based on new public api
  • Update rename to use useSaveData hook
  • Implement UI for set replication
  • Added tests for set replication action
  • Improve storage browser actions using useMemo
  • Implement UI for copy action in storage browser
  • Implement UI for move action in storage browser
  • Minor UI improvements

How was this patch tested?

  • Unit tests
  • Manually

Please review Hue Contributing Guide before opening a pull request.

Copy link
Collaborator

@bjornalm bjornalm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, I have only looked at the FileChooserModal so far, but I think we need some refactoring to get better code reusability and modularity.

type: string;
}

const FileChooserModal = ({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like discussed on slack. The name is misleading if the only purpose is to let the user choose a destination path.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nidhibhatg Why not use the existing FileChooserModal that's under reactComponents/FileChooser? Could be extended to only show folders and limited to one FS.

return (
<Modal
cancelText={cancelText}
className="hue-filechooser-modal cuix antd"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need the cuix antd classes here?

);

const getColumns = (file: FileChooserTableData) => {
const columns: ColumnProps<FileChooserTableData>[] = [];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we not duplicating a lot this behaviour from the StorageBrowserTable.tsx?

In my opinion the StorageBrowserTable.tsx should be more modular, e.g. the actual table in it should be reusable component. I would see if it was possible to create a reusable and configurable "FilesystemTable" that could be used by different components (like this one) instead of duplicating this code. We will also need an actual "file picker" (for the importer and other places) which also needs a "FilesystemTable" to display the files and folders.

Copy link
Collaborator

@ramprasadagarwal ramprasadagarwal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏🏼 Great PR, mentioned few minor changes.


.antd.cuix {
.hue-filechooser-modal__body{
height:350px;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please run the lining script to fix all the lint issues?

jest.clearAllMocks();
});

test('renders the modal with basic props', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see two patterns for writing tests,

  1. test starts with it('should : majority of the code base follows this (occurs 6167 times across 214 files)
  2. test starts with test(': in recent times we are following this (occurs 189 times across 22 files)

Are we free to choose any of the above or we are migrating from one pattern to another?

My recommendation would be to stick to 1, as it is bit more readable when reading a code and already majority of codebase following it?

@bjornalm @JohanAhlen your thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My vote is for "it('should" since that helps thinking about the actual functionality

{ source_path: selectedFile, destination_path: value },
{
onSuccess: () => {
setLoadingFiles(false);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the loading state exposed by useSaveData?

setLoadingFiles(false);
onSuccessfulAction();
},
onError: () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onError also send error as an argument.

onSuccess: onSuccessfulAction,
onError: (renameError: Error) => huePubSub.publish('hue.error', renameError)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same can be done for remaining save api calls on this page

return false;
}
const selectedFile = selectedFiles[0];
return (isHDFS(selectedFile.path) || isOFS(selectedFile.path)) && selectedFile.type === 'file';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an enum BrowserViewType which can be used to selectedFile.type === BrowserViewType.file

enum can be found at desktop/core/src/desktop/js/reactComponents/FileChooser/types.ts

@@ -140,7 +295,8 @@ const StorageBrowserActions = ({
items: getActions(),
className: 'hue-storage-browser__table-actions-menu'
}}
trigger={['click', 'hover']}
trigger={['click']}
disabled={getActions().length === 0 ? true : false}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disabled={getActions().length === 0} should be sufficient

return false;
}, [selectedFiles]);

const getActions = useCallback(() => {
Copy link
Collaborator

@ramprasadagarwal ramprasadagarwal Dec 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be used as a variable by converting to useMemo?

initialValue={selectedFiles[0]?.name}
/>
<InputModal
title={'Setting Replication factor for: ' + selectedFile}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

title={t('Setting Replication factor for: {{selectedFile}}', {selectedFile})

onClose={() => setShowCopyModal(false)}
onSubmit={handleCopy}
showModal={showCopyModal}
title="Copy to"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use i18n translation here?
Same for other remaining places

{ path: filePath, name: folderName },
{
onSuccess: () => refetchData(),
onError: () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we handle error in same way as stated earlier?

Copy link
Collaborator

@ramprasadagarwal ramprasadagarwal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nidhibhatg I am approving this PR to merge it for now, Please take care of the changes in saperate PR.

Copy link
Contributor

@JohanAhlen JohanAhlen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Let's merge this and work on the changes from the review comments in a subsequent PR.

@ramprasadagarwal ramprasadagarwal enabled auto-merge (squash) December 12, 2024 13:49
@JohanAhlen JohanAhlen dismissed bjornalm’s stale review December 12, 2024 14:04

Merging and fixing separately

@ramprasadagarwal ramprasadagarwal merged commit fec209e into master Dec 12, 2024
5 of 6 checks passed
@ramprasadagarwal ramprasadagarwal deleted the nidhi_sb_actions_m branch December 12, 2024 14:04
Alterrien pushed a commit to Alterrien/hue that referenced this pull request Dec 19, 2024
* [ui-storageBrowser] Improvements on storage browser content summary

* [ui-storageBrowser] Update create new files based on new public api

* [ui-storageBrowser] Update create new folders based on new public api

* [ui-storageBrowser] Update rename to use useSaveData hook

* [ui-storageBrowser] Implement UI for set replication

* [ui-storageBrowser] Added tests for set replication action

* [ui-storageBrowser] Improve storage browser actions using useMemo

* [ui-storageBrowser] Implement UI for copy action in storage browser

* [ui-storageBrowser] Implement UI for move action in storage browser
tabraiz12 pushed a commit that referenced this pull request Jan 27, 2025
)

* [ui-storageBrowser] Improvements on storage browser content summary

* [ui-storageBrowser] Update create new files based on new public api

* [ui-storageBrowser] Update create new folders based on new public api

* [ui-storageBrowser] Update rename to use useSaveData hook

* [ui-storageBrowser] Implement UI for set replication

* [ui-storageBrowser] Added tests for set replication action

* [ui-storageBrowser] Improve storage browser actions using useMemo

* [ui-storageBrowser] Implement UI for copy action in storage browser

* [ui-storageBrowser] Implement UI for move action in storage browser

(cherry picked from commit fec209e)
(cherry picked from commit 04315413c675571bfe98e430c14355b9fe7eb2df)
athithyaaselvam pushed a commit that referenced this pull request Mar 11, 2025
* [ui-storageBrowser] Improvements on storage browser content summary

* [ui-storageBrowser] Update create new files based on new public api

* [ui-storageBrowser] Update create new folders based on new public api

* [ui-storageBrowser] Update rename to use useSaveData hook

* [ui-storageBrowser] Implement UI for set replication

* [ui-storageBrowser] Added tests for set replication action

* [ui-storageBrowser] Improve storage browser actions using useMemo

* [ui-storageBrowser] Implement UI for copy action in storage browser

* [ui-storageBrowser] Implement UI for move action in storage browser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants