Skip to content

[ui-importer] Add configured filesystems in importer #4131

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

nidhibhatg
Copy link
Collaborator

@nidhibhatg nidhibhatg commented Apr 30, 2025

What changes were proposed in this pull request?

  • Adds configured filesystems in importer and displays all the filesystems
  • Modifies file chooser to support upload and create folder
  • Adds functionality to click files for importer use case
  • Style improvements
Screenshot 2025-04-30 at 3 08 47 PM Screenshot 2025-04-30 at 3 09 15 PM Screenshot 2025-04-30 at 7 57 28 PM Screenshot 2025-04-30 at 3 09 31 PM Screenshot 2025-04-30 at 3 09 54 PM Screenshot 2025-04-30 at 3 10 18 PM

How was this patch tested?

  • unit tests and manually

Please review Hue Contributing Guide before opening a pull request.

Copy link

github-actions bot commented Apr 30, 2025

✅ Test files were modified. Ensure that the tests cover all relevant changes. ✅

@nidhibhatg nidhibhatg force-pushed the nidhi_importer_filesystems branch from 465c3d9 to 42dccf4 Compare April 30, 2025 09:55
Copy link

github-actions bot commented Apr 30, 2025

Python Code Coverage

Python Coverage Report •
FileStmtsMissCoverMissing
TOTAL537342701349% 
report-only-changed-files is enabled. No files were changed during this commit :)

Pytest Report

Tests Skipped Failures Errors Time
1090 106 💤 0 ❌ 0 🔥 6m 2s ⏱️

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.

Nice work.
Please check the comments below.

...i18n
}: FileChooserModalProps): JSX.Element => {
const { t } = i18nReact.useTranslation();
const { cancelText = t('Cancel'), submitText = t('Submit') } = i18n;
const [destPath, setDestPath] = useState<string>(sourcePath);
const [submitLoading, setSubmitLoading] = useState<boolean>(false);
const [searchTerm, setSearchTerm] = useState<string>('');
const [showCreateFolderModal, setShowCreateFolderModal] = useState<boolean>(false);
const [polling, setPolling] = useState<boolean>(false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can avoid this state by using filesToUpload.length if its zero then pooling is false else true.

}}
/>
)}
<InputModal
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 refactor the **/StorageDirectoryActions/CreateAndUpload/CreateAndUploadAction.tsx component to take the create file and folder action to separate component and reuse it here?

const tableData: FileChooserTableData[] = useMemo(() => {
if (!filesData?.files) {
if (loading || error || !filesData?.files) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this required to check it?
In case of loading and error, LoadingErrorWrapper will take care of showing the appropriate spinner or alert.

@@ -34,9 +42,45 @@ interface ImporterSourceSelectorProps {
const ImporterSourceSelector = ({ setFileMetaData }: ImporterSourceSelectorProps): JSX.Element => {
const { t } = i18nReact.useTranslation();
const uploadRef = useRef<HTMLInputElement>(null);
const [showFileChooserModal, setShowFileChooserModal] = useState<boolean>(false);
const [filePath, setFilePath] = useState<string>('');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of two states, one for opening the fileChooserModal and one to set the userHomeDirectory for the fileChooserModal. Can we use [selectedUserHomeDirectory, setSelectedUserHomeDirectory] and, based on whether this is undefined or not, we can show the FileChooserModal?

loading,
error,
reloadData
} = useLoadData<FileSystem[]>(FILESYSTEMS_API_URL);
const { save: upload } = useSaveData<LocalFileUploadResponse>(UPLOAD_LOCAL_FILE_API_URL);
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 add error handling for uploading the local file as well?

{t('Select a source to import from')}
</div>
<div className="hue-importer__source-selector-options">
{(window as hueWindow).ENABLE_DIRECT_UPLOAD && (
Copy link
Collaborator

Choose a reason for hiding this comment

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

It will be a good idea to extract this code to a new component, as it will move all the code related to a local file to one place, and this component will look a bit cleaner.

@@ -124,10 +156,61 @@ const FileChooserModal = ({
if (record.type === BrowserViewType.dir) {
setDestPath(record.path);
}
if (isImport && record.type === BrowserViewType.file) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The isImport keyword is too specific to our use case, we can make this functionality generic. Something like isFileSelectionAllowed or anything more generic

@bjornalm
Copy link
Collaborator

bjornalm commented May 5, 2025

Lots of good feedback from @ramprasadagarwal. I'll hold while you guys sort it out, but I did notice that the screenshot of the drag and drop looks weird where the "drop area" appears behind the action buttons of the modal.

@@ -14,14 +14,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import React, { useRef } from 'react';
import React, { useRef, useState } from 'react';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add the tests for this file.

@nidhibhatg nidhibhatg force-pushed the nidhi_importer_filesystems branch from 811ebb9 to 3700a3c Compare May 20, 2025 09:54
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.

3 participants