Skip to content
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

Combine columns #42021

Merged
merged 21 commits into from
May 1, 2024
Merged

Combine columns #42021

merged 21 commits into from
May 1, 2024

Conversation

romeovs
Copy link
Contributor

@romeovs romeovs commented Apr 30, 2024

Merges the feature branch combine-columns into master. (Epic here).

This branch contains work from: #40082, unaltered, except for fixing merge conflicts.

Closes #39980

Adds combine column drill through to the chill mode header columns.

How to verify

  • Open the Accounts table in chill mode
  • Click the header of a string column (eg. Email, First Name or Plan)
  • Click + Combine columns
  • Play around with the column editor
  • Click Done
  • Verify the new column is added as the last column

Demo

See video attached to this Slack message

Screenshot 2024-04-19 at 14 52 22 Screenshot 2024-04-19 at 14 52 26 Screenshot 2024-04-19 at 14 52 34

bshepherdson and others added 14 commits April 4, 2024 17:43
This is needed to show the previews in the UX for the combining columns
epic #39977.

Fixes #39979.
This is following the original plan of using a drill for this. It's hard
to combine that with the "preview" functionality.

See [thread](https://metaboat.slack.com/archives/C06P22KS4JH/p1712264174056569)
for discussion of how we might approach that issue.

Fixes #39978.
This is following the original plan of using a drill for this. It's hard
to combine that with the "preview" functionality.

See [thread](https://metaboat.slack.com/archives/C06P22KS4JH/p1712264174056569)
for discussion of how we might approach that issue.

Fixes #39978.
This is needed to show the previews in the UX for the combining columns
epic #39977.

Fixes #39979.
This is needed to show the previews in the UX for the combining columns
epic #39977.

Fixes #39979.
* Type Section['icon'] properly, including the hack for summarize section

* Add combine columns section

* Add types for combine columns drill

* Add combine columns drill component stub

* Mock combine columns drill

* Add component stub

* Encapsulate typing hacks

* Extract CombineColumnsDrill

* Extract ColumnAndSeparatorRow

* Improve naming, add button to edit separators

* Translate string

* Improve styling

* Separator input

* Handle removing columns

* Rename lib.ts to utils.ts

* Implement onSubmit

* Add getNextColumnAndSeparator

* Use form for a11y

* Handle vertical overflow

* Handle horizontal overflow

* Extract formatSeparator

* Use proper translations

* Adjust min/max sizes

* Fix scrollbar being unnecessarily shown

* Display source column name

* Avoid serializing the entire column and putting it into DOM

* Use module.css extension

* Format code

* Improve a11y

* Mock combineColumnsDrillExpression and previewExpression

* Add Preview component

* Move preview logic to Preview component

* Style Preview

* Format code

* Move styles to CSS modules

* Update UI to latest designs
- move "Add another column" button
- remove "Separated by X" button
- always show separator inputs

* Remove displayInfo mock

* Add asReturned

* Update CombineColumnsDrillThruInfo

* Integrate new way of working with combine columns drill

* Fix generating expression names

* Integrate drill with click actions

* Integrate new preview workflow

* Revert "Update UI to latest designs"

This reverts commit cda039d.

* Use previewExpression interface correctly

* Use new preview_expression API

* Make sure columns are created with original query and stage index

* Extract usePreview and handle preview errors

* Update popover title

* Move add column button

* Fix outline being cut off

* Style preview label as per design

* Format empty separator

* Make preview scrollable

* Use project convention

* Simplify ScrollArea usage

* Use ScrollArea in CombineColumnsDrill

* Update comment

* Remove Lib.previewExpression

* Clean up the preview after removing Lib.previewExpression

* Implement getPreview

* Change default column preview to 'text'

* Remove usePreview hook which is no longer in use

* Rename Preview to Example

* Use different placeholder for separator input

* Add whitespace placeholder

* Add ColumnPicker boilerplate

* Export Input

* Use QueryColumnPicker for ColumnPicker

* Pass width to AccordionList

* Add sequences popover events with tippy

* Remove unused ColumnOption helpers

* Add testid to Example

* Add e2e test for combine column in header

* Select content of separator input on focus

* Reduce padding on example

* Add monospace variant to Text

* Use monospace variant in Example

* Use monospace font in textinput

* Match faux-select label styles to our TextInput label styles

* Add missing color

* Remove !important

* Use pre whitespace so consecutive spaces show up

* Remove empty default

* Add example for boolean

* Remove !important

* Use should.have text over contain

---------

Co-authored-by: Romeo Van Snick <romeo@romeovansnick.be>
@romeovs romeovs self-assigned this Apr 30, 2024
@romeovs romeovs requested a review from camsaul as a code owner April 30, 2024 10:11
@romeovs romeovs added the no-backport Do not backport this PR to any branch label Apr 30, 2024
@metabase-bot metabase-bot bot added the visual Run Percy visual testing label Apr 30, 2024
Copy link

github-actions bot commented Apr 30, 2024

Codenotify: Notifying subscribers in CODENOTIFY files for diff 912b5e5...5dbf1af.

Notify File(s)
@alxnddr frontend/src/metabase/visualizations/components/ClickActions/utils.ts
frontend/src/metabase/visualizations/types/click-actions.ts
@kdoh frontend/src/metabase/ui/components/overlays/Popover/index.tsx
frontend/src/metabase/ui/index.ts

Copy link

replay-io bot commented Apr 30, 2024

Status Complete ↗︎
Commit 5dbf1af
Results
⚠️ 5 Flaky
2445 Passed

@nemanjaglumac nemanjaglumac requested review from ranquild and a team April 30, 2024 12:27
Copy link
Contributor

@ranquild ranquild left a comment

Choose a reason for hiding this comment

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

Inline comments. I'll test the branch locally a bit later today

<Title
mb="lg"
order={4}
>{jt`Combine “${columnInfo.displayName}” with other columns`}</Title>
Copy link
Contributor

Choose a reason for hiding this comment

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

Just t? There are no react nodes

onChange: (column: Lib.ColumnMetadata) => void;
};

const theme = getThemeOverrides();
Copy link
Contributor

Choose a reason for hiding this comment

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

Strong no. This should never be used directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I followed this pattern because it is already in use in the codebase.

I've change the code to use useMantineTheme but I had to export it from metabase/ui because it wasn't yet.

Or do you have another preferred way of reading theme properties?

Copy link
Contributor

Choose a reason for hiding this comment

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

useMantineTheme LGTM

return;
}
if (!evt.currentTarget.contains(evt.relatedTarget as Node)) {
setTimeout(() => setOpen(false), 100);
Copy link
Contributor

Choose a reason for hiding this comment

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

This will cause issues with onmounts before timeout. Please use a hook (maybe from react-use) that handles that.


// Hack to prevent parent TippyPopover from closing when selecting an item
// TODO: remove when TippyPopover is no longer used
function Dropdown({
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be handled by Popover already.

Copy link
Contributor

Choose a reason for hiding this comment

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

@romeovs please move this to metabase/ui like for Select

export const SelectDropdown = forwardRef(function SelectDropdown(
so people don't need to copy-paste this

onRemove: (index: number) => void;
}

const { fontFamilyMonospace } = getThemeOverrides();
Copy link
Contributor

Choose a reason for hiding this comment

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

Strong no.

Copy link
Contributor

@ranquild ranquild left a comment

Choose a reason for hiding this comment

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

@romeovs please use this to make the newly created column appear after the selected one

extra: () => ({ settingsSyncOptions: { column: clicked.column } }),

@romeovs romeovs requested a review from ranquild May 1, 2024 07:07
Copy link
Contributor

@ranquild ranquild left a comment

Choose a reason for hiding this comment

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

@romeovs last comment about moving the hack for Popover to metabase/ui. Approving to unblock the PR

@romeovs
Copy link
Contributor Author

romeovs commented May 1, 2024

@romeovs please use this to make the newly created column appear after the selected one

extra: () => ({ settingsSyncOptions: { column: clicked.column } }),

The project actually specifies to attach the column at the end. @mngr what is your preference here?

@romeovs romeovs merged commit 0dc7504 into master May 1, 2024
112 checks passed
@romeovs romeovs deleted the combine-columns branch May 1, 2024 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-backport Do not backport this PR to any branch .Team/QueryingComponents visual Run Percy visual testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FE] "Combine columns" drill thru
5 participants