Skip to content
This repository has been archived by the owner on Jan 16, 2025. It is now read-only.

[RA-TES-6187] CustomFilterBar component #24

Merged
merged 9 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const VerticalFormItem = styled(StyledFormItem)`
const HorizontalFormItem = styled(StyledFormItem)`
&& {
margin-bottom: 0;
align-items: center;
display: block;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Conflict.

}

.ant-form-item-label {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import { LOG_ACTIONS_CHANGE_DASHBOARD_FILTER } from 'src/logger/LogUtils';
import { FilterBarOrientation, RootState } from 'src/dashboard/types';
import { UserWithPermissionsAndRoles } from 'src/types/bootstrapTypes';
import KatalonHorizontal from 'src/katalon/CustomFilter/KatalonHorizontal';
import ActionButtons from 'src/katalon/ActionsButton';
triquanminh marked this conversation as resolved.
Show resolved Hide resolved
import { checkIsApplyDisabled } from './utils';
import { FiltersBarProps } from './types';
import {
Expand All @@ -61,7 +62,6 @@ import {
useInitialization,
} from './state';
import { createFilterKey, updateFilterKey } from './keyValue';
import ActionButtons from './ActionButtons';
import Vertical from './Vertical';
import { useSelectFiltersInScope } from '../state';

Expand Down
97 changes: 97 additions & 0 deletions superset-frontend/src/katalon/ActionsButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/* eslint-disable import/no-unresolved */
/* eslint-disable theme-colors/no-literal-colors */
import React, { useMemo } from 'react';
import {
DataMaskState,
DataMaskStateWithId,
t,
isDefined,
} from '@superset-ui/core';
import Button from '@mui/material/Button';
import { FilterBarOrientation } from 'src/dashboard/types';
import { getFilterBarTestId } from 'src/dashboard/components/nativeFilters/FilterBar/utils';
import { Stack } from '@mui/material';

interface ActionButtonsProps {
width?: number;
onApply: () => void;
onClearAll: () => void;
dataMaskSelected: DataMaskState;
dataMaskApplied: DataMaskStateWithId;
isApplyDisabled: boolean;
filterBarOrientation?: FilterBarOrientation;
}

const ActionButtons = ({
onApply,
onClearAll,
dataMaskApplied,
dataMaskSelected,
isApplyDisabled,
}: ActionButtonsProps) => {
const isClearAllEnabled = useMemo(
() =>
Object.values(dataMaskApplied).some(
filter =>
isDefined(dataMaskSelected[filter.id]?.filterState?.value) ||
(!dataMaskSelected[filter.id] &&
isDefined(filter.filterState?.value)),
),
[dataMaskApplied, dataMaskSelected],
);

return (
<Stack
sx={{
marginLeft: 'auto',
alignItems: 'center',
marginTop: '30px',
}}
direction="row"
spacing={1}
data-test="filterbar-action-buttons"
>
<Button
sx={{
bgcolor: '#F2F3FA',
color: '#1E30CC',
textTransform: 'none',
whiteSpace: 'nowrap',
fontSize: 14,
fontWeight: 500,
height: '32px',
'&.MuiButtonBase-root:hover': {
bgcolor: 'transparent',
},
}}
size="small"
variant="contained"
disableElevation
disabled={!isClearAllEnabled}
onClick={onClearAll}
{...getFilterBarTestId('clear-button')}
>
{t('Clear all')}
</Button>
<Button
sx={{
bgcolor: '#2236E5',
height: '32px',
textTransform: 'none',
fontSize: 14,
fontWeight: 500,
}}
variant="contained"
disabled={isApplyDisabled}
disableElevation
size="small"
onClick={onApply}
{...getFilterBarTestId('apply-button')}
>
{t('Apply')}
</Button>
</Stack>
);
};

export default ActionButtons;
84 changes: 56 additions & 28 deletions superset-frontend/src/katalon/CustomFilter/FilterExtension.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
Menu,
MenuItem,
Stack,
} from '@mui/material';

Check failure on line 12 in superset-frontend/src/katalon/CustomFilter/FilterExtension.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

Unable to resolve path to module '@mui/material'

Check failure on line 12 in superset-frontend/src/katalon/CustomFilter/FilterExtension.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

Unable to resolve path to module '@mui/material'
import styled from 'styled-components';

Check failure on line 13 in superset-frontend/src/katalon/CustomFilter/FilterExtension.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

Unable to resolve path to module 'styled-components'

Check failure on line 13 in superset-frontend/src/katalon/CustomFilter/FilterExtension.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

Unable to resolve path to module 'styled-components'

interface FilterItem {
id: string;
Expand All @@ -21,6 +22,28 @@
items: FilterItem[];
}

// eslint-disable-next-line theme-colors/no-literal-colors
const ContentStyleWrapper = styled.div`
display: flex;
align-items: end;
.ant-form-item-control {
width: 190px !important;
margin-right: 10px;
}
.MuiFormControl-root {
max-width: 100% !important;
}
.ant-form-item-label {
label {
height: 100% !important;
h4 {
color: #47494d;
font-weight: 500;
}
}
}
`;

function FilterExtension(props: FilterExtensionProps) {
const { items } = props;

Expand Down Expand Up @@ -109,39 +132,44 @@
// Take the list all filters,
// then device them into two parts
const visibleFilter: FilterItem[] = items.slice(0, 2);
const invisbleFilter: FilterItem[] = items.slice(3);
const invisbleFilter: FilterItem[] = items.slice(2);

return (
<Stack
sx={{
display: 'flex',
alignItems: 'center',
flexWrap: 'wrap',
gap: '3px',
}}
direction="row"
spacing={2}
>
{visibleFilter.length !== 0 &&
visibleFilter.map((item, index) => (
<div key={index}>{item.element}</div>
))}
{addFilter.length !== 0 &&
addFilter.map((item, index) => <div key={index}>{item.element}</div>)}
<Button
<ContentStyleWrapper>
<Stack
sx={{
bgcolor: '#FFFFFF',
color: '#0F1866',
textTransform: 'none',
fontSize: 16,
fontWeight: 600,
display: 'flex',
alignItems: 'end',
flexWrap: 'wrap',
}}
onClick={handleClick}
direction="row"
>
{t('+ Add more')}
</Button>
{renderPopperMenu(invisbleFilter)}
</Stack>
{visibleFilter.length !== 0 &&
visibleFilter.map((item, index) => (
<div key={index}>{item.element}</div>
))}
{addFilter.length !== 0 &&
addFilter.map((item, index) => (
<div key={index}>{item.element}</div>
))}
<Button
sx={{
height: '40px',
bgcolor: '#FFFFFF',
color: '#0F1866',
textTransform: 'none',
fontSize: 14,
fontWeight: 500,
lineHeight: '1.14',
whiteSpace: 'nowrap',
}}
onClick={handleClick}
>
{t('+ Add more')}
</Button>
{renderPopperMenu(invisbleFilter)}
</Stack>
</ContentStyleWrapper>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const HorizontalBar = styled.div`
theme.gridUnit * 3
}px ${theme.gridUnit * 4}px;
background: ${theme.colors.grayscale.light5};
box-shadow: inset 0px -2px 2px -1px ${theme.colors.grayscale.light2};
`}
`;

Expand All @@ -40,7 +39,7 @@ const HorizontalBarContent = styled.div`
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
align-items: flex-start;
justify-content: flex-start;
line-height: 0;
.loading {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable theme-colors/no-literal-colors */
import React, { ReactNode } from 'react';
import styled from 'styled-components';

Check failure on line 3 in superset-frontend/src/katalon/filters/components/Time/DropdownLabel.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

Unable to resolve path to module 'styled-components'

Check failure on line 3 in superset-frontend/src/katalon/filters/components/Time/DropdownLabel.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

Unable to resolve path to module 'styled-components'
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';

Check failure on line 4 in superset-frontend/src/katalon/filters/components/Time/DropdownLabel.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

Unable to resolve path to module '@mui/icons-material/KeyboardArrowDown'

Check failure on line 4 in superset-frontend/src/katalon/filters/components/Time/DropdownLabel.tsx

View workflow job for this annotation

GitHub Actions / frontend-build

Unable to resolve path to module '@mui/icons-material/KeyboardArrowDown'

export type DropdownLabel = {
label: ReactNode;
Expand All @@ -17,7 +17,7 @@
isPlaceholder?: boolean;
}>`
${({ isActive, isPlaceholder }) => `
width: 100%;
min-width: 190px;
height: 40px;

display: flex;
Expand All @@ -28,7 +28,7 @@

background-color: #FFFFFF;

border: 1px solid ${isActive ? ACTIVE_COLOR : '#E0E0E0'};
border: 1px solid ${isActive ? ACTIVE_COLOR : '#dbdde5'};
border-radius: 4px;

cursor: pointer;
Expand All @@ -38,7 +38,7 @@
background-color: ${isActive && ACTIVE_COLOR};

.date-label-content {
color: ${isPlaceholder ? '#B2B2B2' : '#A7323F'};
color: ${isPlaceholder ? '#B2B2B2' : '#000000'};
overflow: hidden;
text-overflow: ellipsis;
min-width: 0;
Expand Down
Loading