-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
feat(filter-set): Update existing filter set #13545
Merged
Merged
Changes from all commits
Commits
Show all changes
73 commits
Select commit
Hold shift + click to select a range
2731518
refactor(native-filters): move data mask to root reducer
simcha90 de6a332
Merge branch 'master' of github.com:apache/superset into filtersState…
simcha90 6652d19
refactor: update rest stuff for dataMask
simcha90 266a0a3
refactor: add ownCrrentState to explore
simcha90 5344dd4
fix: fix immer reducer
simcha90 2b4bd8f
Merge branch 'master' of github.com:apache/superset into filtersState…
simcha90 dabfd24
fix: merge with master
simcha90 802823c
refactor: support explore dataMask
simcha90 8aed240
refactor: support explore dataMask
simcha90 a0fa114
docs: add comment
simcha90 eaec7ef
refactor: remove json stringify
simcha90 cba3467
fix: fix failed cases
simcha90 04d6398
feat: filter bat buttons start
simcha90 af9e35a
fix: fix CR notes
simcha90 64fb87d
fix: fix cascade filters
simcha90 57c954f
fix: fix CR notes
simcha90 bd9b767
Merge branch 'filtersState_to_data_mask' of github.com:simchaNielsen/…
simcha90 bff44d1
refactor: add clear all
simcha90 09b594a
fix: fix CR notes
simcha90 c522391
Merge branch 'master' of github.com:apache/superset into filtersState…
simcha90 1bf1552
Merge branch 'filtersState_to_data_mask' of github.com:simchaNielsen/…
simcha90 0527067
fix: fix CR notes
simcha90 9abe26e
Merge branch 'filtersState_to_data_mask' of github.com:simchaNielsen/…
simcha90 2d12c37
fix: fix CR notes
simcha90 84d8cbd
Merge branch 'filtersState_to_data_mask' of github.com:simchaNielsen/…
simcha90 a9202b1
feat: buttons in filter bar
simcha90 9ae46b9
Merge branch 'master' of github.com:apache/superset into filter_bar_a…
simcha90 cdcae95
lint: update imports
simcha90 6c91054
feat: add tabs for filter sets
simcha90 844adaa
Merge branch 'master' of github.com:apache/superset into filter-set_tabs
simcha90 93e5d97
Merge branch 'master' of github.com:apache/superset into filter-set_tabs
simcha90 04259c2
feat: add buttons to filter set
simcha90 c053836
Merge branch 'master' of github.com:apache/superset into filter_set_d…
simcha90 26a0f28
feat: first phase add filter sets
simcha90 60b1374
fix: undo FF
simcha90 7985f5d
refactor: continue filter sets
simcha90 6671c1d
Merge branch 'master' of github.com:apache/superset into filter_set_d…
simcha90 3af62be
fix: fix CR notes
simcha90 d7e6b23
Merge branch 'filter_set_design' of github.com:simchaNielsen/incubato…
simcha90 038e5cc
refactor: header
simcha90 c7a9849
fix: fix CR notes
simcha90 d47a1ea
fix: fix CR notes
simcha90 02800d9
Merge branch 'filter_set_design' of github.com:simchaNielsen/incubato…
simcha90 4182f51
refactor: continue filter sets
simcha90 68e32d8
lint: fix lint
simcha90 f0904de
Merge branch 'filter_set_design' of github.com:simchaNielsen/incubato…
simcha90 eb8e9b9
refactor: continue filter sets
simcha90 bdbd0f9
fix: fix filter bar opening
simcha90 18d39bb
Merge branch 'filter_set_design' of github.com:simchaNielsen/incubato…
simcha90 33adb45
refactor: continue filter sets
simcha90 cc82b6a
Merge branch 'master' of github.com:apache/superset into filter_set_d…
simcha90 8bd69ed
Merge branch 'filter_set_design' of github.com:simchaNielsen/incubato…
simcha90 376386b
refactor: continue filter sets
simcha90 db7eccb
refactor: continue filter sets
simcha90 5d6d39e
Merge branch 'master' of github.com:apache/superset into filter_set_d…
simcha90 33e182d
feat: filters sets history
simcha90 5fa0e07
feat: filters sets history
simcha90 7539f03
fix: filter set name
simcha90 d887995
refactor: fix expand filters case
simcha90 a6884a2
Merge branch 'master' of github.com:apache/superset into filter_set_d…
simcha90 01439b6
fix: fix CR notes
simcha90 c075d9a
refactor: filter sets
simcha90 52a66aa
refactor: filter sets
simcha90 0ee5881
Merge branch 'filter_set_design_2' of github.com:simchaNielsen/incuba…
simcha90 27c0ca1
refactor: filter sets
simcha90 34b26b6
refactor: filter sets
simcha90 a21a394
refactor: update sets
simcha90 041fe8b
Merge branch 'master' of github.com:apache/superset into filter_set_u…
simcha90 24dcd16
feat: edit filter set
simcha90 d8e1bd9
refactor: add warning icon
simcha90 e558783
fix: fix CR notes
simcha90 accd1f2
Update superset-frontend/src/dashboard/components/nativeFilters/Filte…
simcha90 5b3803a
fix: fix CR notes
simcha90 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
150 changes: 150 additions & 0 deletions
150
...rset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterSets/EditSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import React, { FC, useMemo } from 'react'; | ||
import { HandlerFunction, styled, t } from '@superset-ui/core'; | ||
import { Typography, Tooltip } from 'src/common/components'; | ||
import { useDispatch } from 'react-redux'; | ||
import Button from 'src/components/Button'; | ||
import { setFilterSetsConfiguration } from 'src/dashboard/actions/nativeFilters'; | ||
import { DataMaskUnit } from 'src/dataMask/types'; | ||
import { WarningOutlined } from '@ant-design/icons'; | ||
import { ActionButtons } from './Footer'; | ||
import { useDataMask, useFilterSets } from '../state'; | ||
import { APPLY_FILTERS_HINT, findExistingFilterSet } from './utils'; | ||
|
||
const Wrapper = styled.div` | ||
display: grid; | ||
grid-template-columns: 1fr; | ||
align-items: flex-start; | ||
justify-content: flex-start; | ||
grid-gap: ${({ theme }) => theme.gridUnit}px; | ||
background: ${({ theme }) => theme.colors.primary.light4}; | ||
padding: ${({ theme }) => theme.gridUnit * 2}px; | ||
`; | ||
|
||
const Title = styled(Typography.Text)` | ||
color: ${({ theme }) => theme.colors.primary.dark2}; | ||
`; | ||
|
||
const Warning = styled(Typography.Text)` | ||
font-size: ${({ theme }) => theme.typography.sizes.s}px; | ||
& .anticon { | ||
padding: ${({ theme }) => theme.gridUnit}px; | ||
} | ||
`; | ||
|
||
const ActionButton = styled.div<{ disabled?: boolean }>` | ||
display: flex; | ||
& button { | ||
${({ disabled }) => `pointer-events: ${disabled ? 'none' : 'all'}`}; | ||
flex: 1; | ||
} | ||
`; | ||
|
||
type EditSectionProps = { | ||
filterSetId: string; | ||
dataMaskSelected: DataMaskUnit; | ||
onCancel: HandlerFunction; | ||
disabled: boolean; | ||
}; | ||
|
||
const EditSection: FC<EditSectionProps> = ({ | ||
filterSetId, | ||
onCancel, | ||
dataMaskSelected, | ||
disabled, | ||
}) => { | ||
const dataMaskApplied = useDataMask(); | ||
const dispatch = useDispatch(); | ||
const filterSets = useFilterSets(); | ||
const filterSetFilterValues = Object.values(filterSets); | ||
const handleSave = () => { | ||
dispatch( | ||
setFilterSetsConfiguration( | ||
filterSetFilterValues.map(filterSet => { | ||
const newFilterSet = { | ||
...filterSet, | ||
dataMask: { nativeFilters: { ...dataMaskApplied } }, | ||
}; | ||
return filterSetId === filterSet.id ? newFilterSet : filterSet; | ||
}), | ||
), | ||
); | ||
onCancel(); | ||
}; | ||
|
||
const foundFilterSet = useMemo( | ||
() => | ||
findExistingFilterSet({ | ||
dataMaskApplied, | ||
dataMaskSelected, | ||
filterSetFilterValues, | ||
}), | ||
[dataMaskApplied, dataMaskSelected, filterSetFilterValues], | ||
); | ||
|
||
const isDuplicateFilterSet = | ||
foundFilterSet && foundFilterSet.id !== filterSetId; | ||
|
||
return ( | ||
<Wrapper> | ||
<Title strong>{t('Editing filter set:')}</Title> | ||
<Title>{filterSets[filterSetId].name}</Title> | ||
<ActionButtons> | ||
<Button | ||
ghost | ||
buttonStyle="tertiary" | ||
buttonSize="small" | ||
onClick={onCancel} | ||
data-test="filter-set-edit-cancel" | ||
> | ||
{t('Cancel')} | ||
</Button> | ||
<Tooltip | ||
placement="top" | ||
title={ | ||
(isDuplicateFilterSet && t('Filter set already exists')) || | ||
(disabled && APPLY_FILTERS_HINT) | ||
} | ||
> | ||
<ActionButton disabled={disabled || isDuplicateFilterSet}> | ||
<Button | ||
disabled={disabled || isDuplicateFilterSet} | ||
buttonStyle="primary" | ||
htmlType="submit" | ||
buttonSize="small" | ||
onClick={handleSave} | ||
data-test="filter-set-edit-save" | ||
> | ||
{t('Save')} | ||
</Button> | ||
</ActionButton> | ||
</Tooltip> | ||
</ActionButtons> | ||
{isDuplicateFilterSet && ( | ||
<Warning mark> | ||
<WarningOutlined /> | ||
{t('This filter set is identical to: "%s"', foundFilterSet?.name)} | ||
</Warning> | ||
)} | ||
</Wrapper> | ||
); | ||
}; | ||
|
||
export default EditSection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this isn't yet in the design, I think it would be a good idea to make the title editable when in edit mode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may be in next PR, here it will cause refactor some code and move to other files