Skip to content

[ui-importer-modal] Bulk Edit column modal second iteration #4165

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 3 commits into
base: master
Choose a base branch
from

Conversation

ananya-agarwal
Copy link
Collaborator

What changes were proposed in this pull request?

Adding edit columns button on the right and on clicking it, getting the modal with 4 different columns, a cancel and a done button, where the user will be able to edit the column header from the modal and on clicking Done button, he/she will be able to see the updated column header (name) in the preview. Also, getting pre-filled data from the file (say csv) into the modal.

How was this patch tested?

Manual testing, will add unit tests soon.

Please review Hue Contributing Guide before opening a pull request.

before starting new work

header name changed but entire column vanishes

Optimized code but with removing column bug

Fixed mapping issue

removed grey color

Row data present as column values in sample values

Fixed padding for the edit columns button

WIP

wip
Copy link

github-actions bot commented Jun 10, 2025

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

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request implements a bulk edit modal for updating column headers in the importer preview, allowing users to modify column names, types, and comments directly from the UI.

  • Introduces a stateful implementation for handling columns and pre-fills modal data from file content.
  • Adds an Edit Columns modal component with inline editing capabilities using inputs and selects.
  • Updates styling for the new edit button and adds a placeholder for future test coverage.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
desktop/core/src/desktop/js/apps/newimporter/ImporterFilePreview/ImporterFilePreview.tsx Adds state management for columns, updates preview data mapping, and integrates the EditColumnsModal.
desktop/core/src/desktop/js/apps/newimporter/ImporterFilePreview/ImporterFilePreview.scss Introduces new styling for the edit columns button.
desktop/core/src/desktop/js/apps/newimporter/ImporterFilePreview/EditColumns/EditColumnsModal.tsx Implements a modal with a table interface for editing column properties and handling modal actions.
desktop/core/src/desktop/js/apps/newimporter/ImporterFilePreview/EditColumns/EditColumnsModal.test.tsx Contains preliminary test modifications with a placeholder for future tests.
Comments suppressed due to low confidence (1)

desktop/core/src/desktop/js/apps/newimporter/ImporterFilePreview/ImporterFilePreview.tsx:131

  • [nitpick] Ensure that the 'columns' state is correctly populated before calculating sample rows, as an empty array could lead to incomplete sample data.
const sampleRows = Array.isArray(previewData?.sample?.[0]) ? previewData.sample.map(rowArr => {

Copy link

UI Coverage Report

Lines Statements Branches Functions
Coverage: 32%
39.15% (30527/77959) 31.01% (14247/45936) 23.89% (2130/8915)

@cloudera cloudera deleted a comment from Copilot AI Jun 10, 2025
@cloudera cloudera deleted a comment from Copilot AI Jun 10, 2025
Copy link

github-actions bot commented Jun 10, 2025

Python Code Coverage

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

Pytest Report

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

}
};
fetchSqlTypes();
}, [t]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

t? why is a dependency?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

const noSqlTypesMsg = t('No SQL types returned from server.');
const fetchFailedMsg = t('Failed to fetch SQL types.');

useEffect(() => {
// Fetch SQL types on mount
const fetchSqlTypes = async () => {
try {
const res = await fetch(${SQL_TYPE_MAPPING_API_URL}?sql_dialect=hive);
const data = await res.json();
if (Array.isArray(data) && data.length > 0) {
setSqlTypes(data);
setTypeError(null);
} else {
setSqlTypes([]);
setTypeError(noSqlTypesMsg);
}
} catch (err) {
setSqlTypes([]);
setTypeError(fetchFailedMsg);
}
};
fetchSqlTypes();
}, []); // t removed from dependencies

Does this look better @tabraiz12

value={value}
onChange={(val: string) => handleChange(idx, 'type', val)}
getPopupContainer={triggerNode => triggerNode.parentNode}
style={{ border: '1px solid #838b92', borderRadius: '3px', width: '150px' }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

move inline styling

width={800}
>
{typeError && (
<div style={{ color: 'red', marginBottom: 16 }}>{typeError}</div>
Copy link
Collaborator

Choose a reason for hiding this comment

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

use variable and remove inline style

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! See comments below


useEffect(() => {
// Fetch SQL types on mount
const fetchSqlTypes = async () => {
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 useLoadData hook instead?
Also, till the time, API is loading, can you show the loader on the dropdown of the type? This can be done by passing a loading prop to dropdown component.

onOk={handleDone}
width={800}
>
{typeError && (
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use Loading Error Wrapper here.

@bjornalm
Copy link
Collaborator

Can we get some screenshots for this PR?

comment: col.comment || ''
}))
);
}, [columns, sample, isOpen]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

isOpen required? why is there a dependency

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