Fix View update button not being displayed in View Bar (#1469)
This commit is contained in:
@ -9,7 +9,7 @@ import { selectedOperandInDropdownScopedState } from '@/ui/filter-n-sort/states/
|
|||||||
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
|
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
|
||||||
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
|
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
|
||||||
|
|
||||||
import { sortAndFilterBarScopedState } from '../states/sortAndFilterBarScopedState';
|
import { isViewBarExpandedScopedState } from '../states/isViewBarExpandedScopedState';
|
||||||
import { FiltersHotkeyScope } from '../types/FiltersHotkeyScope';
|
import { FiltersHotkeyScope } from '../types/FiltersHotkeyScope';
|
||||||
|
|
||||||
import DropdownButton from './DropdownButton';
|
import DropdownButton from './DropdownButton';
|
||||||
@ -76,14 +76,14 @@ export function MultipleFiltersDropdownButton({
|
|||||||
|
|
||||||
const setHotkeyScope = useSetHotkeyScope();
|
const setHotkeyScope = useSetHotkeyScope();
|
||||||
|
|
||||||
const [sortAndFilterBar, setSortAndFilterBar] = useRecoilScopedState(
|
const [isViewBarExpanded, setIsViewBarExpanded] = useRecoilScopedState(
|
||||||
sortAndFilterBarScopedState,
|
isViewBarExpandedScopedState,
|
||||||
context,
|
context,
|
||||||
);
|
);
|
||||||
|
|
||||||
function handleIsUnfoldedChange(unfolded: boolean) {
|
function handleIsUnfoldedChange(unfolded: boolean) {
|
||||||
if (unfolded && isPrimaryButton) {
|
if (unfolded && isPrimaryButton) {
|
||||||
setSortAndFilterBar(!sortAndFilterBar);
|
setIsViewBarExpanded(!isViewBarExpanded);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoi
|
|||||||
import { useRemoveFilter } from '../hooks/useRemoveFilter';
|
import { useRemoveFilter } from '../hooks/useRemoveFilter';
|
||||||
import { availableFiltersScopedState } from '../states/availableFiltersScopedState';
|
import { availableFiltersScopedState } from '../states/availableFiltersScopedState';
|
||||||
import { filtersScopedState } from '../states/filtersScopedState';
|
import { filtersScopedState } from '../states/filtersScopedState';
|
||||||
import { sortAndFilterBarScopedState } from '../states/sortAndFilterBarScopedState';
|
import { isViewBarExpandedScopedState } from '../states/isViewBarExpandedScopedState';
|
||||||
import { FiltersHotkeyScope } from '../types/FiltersHotkeyScope';
|
import { FiltersHotkeyScope } from '../types/FiltersHotkeyScope';
|
||||||
import { SelectedSortType } from '../types/interface';
|
import { SelectedSortType } from '../types/interface';
|
||||||
import { getOperandLabelShort } from '../utils/getOperandLabel';
|
import { getOperandLabelShort } from '../utils/getOperandLabel';
|
||||||
@ -21,7 +21,7 @@ import { FilterDropdownButton } from './FilterDropdownButton';
|
|||||||
import SortOrFilterChip from './SortOrFilterChip';
|
import SortOrFilterChip from './SortOrFilterChip';
|
||||||
|
|
||||||
type OwnProps<SortField> = {
|
type OwnProps<SortField> = {
|
||||||
canToggle?: boolean;
|
canPersistView?: boolean;
|
||||||
context: Context<string | null>;
|
context: Context<string | null>;
|
||||||
sorts: Array<SelectedSortType<SortField>>;
|
sorts: Array<SelectedSortType<SortField>>;
|
||||||
onRemoveSort: (sortId: SelectedSortType<SortField>['key']) => void;
|
onRemoveSort: (sortId: SelectedSortType<SortField>['key']) => void;
|
||||||
@ -99,7 +99,7 @@ const StyledAddFilterContainer = styled.div`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
function SortAndFilterBar<SortField>({
|
function SortAndFilterBar<SortField>({
|
||||||
canToggle,
|
canPersistView,
|
||||||
context,
|
context,
|
||||||
sorts,
|
sorts,
|
||||||
onRemoveSort,
|
onRemoveSort,
|
||||||
@ -119,8 +119,8 @@ function SortAndFilterBar<SortField>({
|
|||||||
context,
|
context,
|
||||||
);
|
);
|
||||||
|
|
||||||
const [sortAndFilterBar] = useRecoilScopedState(
|
const [isViewBarExpanded] = useRecoilScopedState(
|
||||||
sortAndFilterBarScopedState,
|
isViewBarExpandedScopedState,
|
||||||
context,
|
context,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -142,10 +142,11 @@ function SortAndFilterBar<SortField>({
|
|||||||
onCancelClick();
|
onCancelClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
const shouldExpandViewBar =
|
||||||
(!canToggle && !filtersWithDefinition.length && !sorts.length) ||
|
canPersistView ||
|
||||||
!sortAndFilterBar
|
((filtersWithDefinition.length || sorts.length) && isViewBarExpanded);
|
||||||
) {
|
|
||||||
|
if (!shouldExpandViewBar) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,9 +7,7 @@ import { StyledDropdownMenuItemsContainer } from '@/ui/dropdown/components/Style
|
|||||||
import { StyledDropdownMenuSeparator } from '@/ui/dropdown/components/StyledDropdownMenuSeparator';
|
import { StyledDropdownMenuSeparator } from '@/ui/dropdown/components/StyledDropdownMenuSeparator';
|
||||||
import { IconChevronDown } from '@/ui/icon';
|
import { IconChevronDown } from '@/ui/icon';
|
||||||
import { OverflowingTextWithTooltip } from '@/ui/tooltip/OverflowingTextWithTooltip';
|
import { OverflowingTextWithTooltip } from '@/ui/tooltip/OverflowingTextWithTooltip';
|
||||||
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
|
|
||||||
|
|
||||||
import { sortAndFilterBarScopedState } from '../states/sortAndFilterBarScopedState';
|
|
||||||
import { FiltersHotkeyScope } from '../types/FiltersHotkeyScope';
|
import { FiltersHotkeyScope } from '../types/FiltersHotkeyScope';
|
||||||
import { SelectedSortType, SortType } from '../types/interface';
|
import { SelectedSortType, SortType } from '../types/interface';
|
||||||
|
|
||||||
@ -31,7 +29,6 @@ export function SortDropdownButton<SortField>({
|
|||||||
availableSorts,
|
availableSorts,
|
||||||
onSortSelect,
|
onSortSelect,
|
||||||
HotkeyScope,
|
HotkeyScope,
|
||||||
context,
|
|
||||||
}: OwnProps<SortField>) {
|
}: OwnProps<SortField>) {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
@ -52,11 +49,6 @@ export function SortDropdownButton<SortField>({
|
|||||||
setSelectedSortDirection('asc');
|
setSelectedSortDirection('asc');
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const [, setSortAndFilterBar] = useRecoilScopedState(
|
|
||||||
sortAndFilterBarScopedState,
|
|
||||||
context,
|
|
||||||
);
|
|
||||||
|
|
||||||
function handleIsUnfoldedChange(newIsUnfolded: boolean) {
|
function handleIsUnfoldedChange(newIsUnfolded: boolean) {
|
||||||
if (newIsUnfolded) {
|
if (newIsUnfolded) {
|
||||||
setIsUnfolded(true);
|
setIsUnfolded(true);
|
||||||
@ -69,7 +61,6 @@ export function SortDropdownButton<SortField>({
|
|||||||
function handleAddSort(sort: SortType<SortField>) {
|
function handleAddSort(sort: SortType<SortField>) {
|
||||||
setIsUnfolded(false);
|
setIsUnfolded(false);
|
||||||
onSortItemSelect(sort);
|
onSortItemSelect(sort);
|
||||||
setSortAndFilterBar(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -0,0 +1,6 @@
|
|||||||
|
import { atomFamily } from 'recoil';
|
||||||
|
|
||||||
|
export const isViewBarExpandedScopedState = atomFamily<boolean, string>({
|
||||||
|
key: 'isViewBarExpandedScopedState',
|
||||||
|
default: true,
|
||||||
|
});
|
||||||
@ -1,6 +0,0 @@
|
|||||||
import { atomFamily } from 'recoil';
|
|
||||||
|
|
||||||
export const sortAndFilterBarScopedState = atomFamily<boolean, string>({
|
|
||||||
key: 'sortAndFilterBarScopedState',
|
|
||||||
default: false,
|
|
||||||
});
|
|
||||||
@ -50,7 +50,7 @@ export function EntityTableBody() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<tbody>
|
||||||
{paddingTop > 0 && (
|
{paddingTop > 0 && (
|
||||||
<tr>
|
<tr>
|
||||||
<StyledSpace top={paddingTop} />
|
<StyledSpace top={paddingTop} />
|
||||||
@ -76,6 +76,6 @@ export function EntityTableBody() {
|
|||||||
<StyledSpace bottom={paddingBottom} />
|
<StyledSpace bottom={paddingBottom} />
|
||||||
</tr>
|
</tr>
|
||||||
)}
|
)}
|
||||||
</>
|
</tbody>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import styled from '@emotion/styled';
|
|||||||
import { useRecoilCallback, useRecoilState } from 'recoil';
|
import { useRecoilCallback, useRecoilState } from 'recoil';
|
||||||
|
|
||||||
import { IconButton } from '@/ui/button/components/IconButton';
|
import { IconButton } from '@/ui/button/components/IconButton';
|
||||||
import { sortAndFilterBarScopedState } from '@/ui/filter-n-sort/states/sortAndFilterBarScopedState';
|
|
||||||
import { IconPlus } from '@/ui/icon';
|
import { IconPlus } from '@/ui/icon';
|
||||||
import { useTrackPointer } from '@/ui/utilities/pointer-event/hooks/useTrackPointer';
|
import { useTrackPointer } from '@/ui/utilities/pointer-event/hooks/useTrackPointer';
|
||||||
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
|
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
|
||||||
@ -91,10 +90,6 @@ export function EntityTableHeader() {
|
|||||||
visibleTableColumnsScopedSelector,
|
visibleTableColumnsScopedSelector,
|
||||||
TableRecoilScopeContext,
|
TableRecoilScopeContext,
|
||||||
);
|
);
|
||||||
const [, setSortAndFilterBar] = useRecoilScopedState(
|
|
||||||
sortAndFilterBarScopedState,
|
|
||||||
TableRecoilScopeContext,
|
|
||||||
);
|
|
||||||
|
|
||||||
const [initialPointerPositionX, setInitialPointerPositionX] = useState<
|
const [initialPointerPositionX, setInitialPointerPositionX] = useState<
|
||||||
number | null
|
number | null
|
||||||
@ -135,20 +130,13 @@ export function EntityTableHeader() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
setTableColumns(nextColumns);
|
setTableColumns(nextColumns);
|
||||||
setSortAndFilterBar(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
set(resizeFieldOffsetState, 0);
|
set(resizeFieldOffsetState, 0);
|
||||||
setInitialPointerPositionX(null);
|
setInitialPointerPositionX(null);
|
||||||
setResizedFieldKey(null);
|
setResizedFieldKey(null);
|
||||||
},
|
},
|
||||||
[
|
[resizedFieldKey, tableColumnsByKey, tableColumns, setTableColumns],
|
||||||
resizedFieldKey,
|
|
||||||
tableColumnsByKey,
|
|
||||||
tableColumns,
|
|
||||||
setTableColumns,
|
|
||||||
setSortAndFilterBar,
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
useTrackPointer({
|
useTrackPointer({
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
|
|
||||||
import type { ViewFieldMetadata } from '@/ui/editable-field/types/ViewField';
|
import type { ViewFieldMetadata } from '@/ui/editable-field/types/ViewField';
|
||||||
import { sortAndFilterBarScopedState } from '@/ui/filter-n-sort/states/sortAndFilterBarScopedState';
|
|
||||||
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
|
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
|
||||||
import { useRecoilScopedValue } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedValue';
|
import { useRecoilScopedValue } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedValue';
|
||||||
|
|
||||||
@ -19,10 +18,6 @@ export const useTableColumns = () => {
|
|||||||
tableColumnsByKeyScopedSelector,
|
tableColumnsByKeyScopedSelector,
|
||||||
TableRecoilScopeContext,
|
TableRecoilScopeContext,
|
||||||
);
|
);
|
||||||
const [, setSortAndFilterBar] = useRecoilScopedState(
|
|
||||||
sortAndFilterBarScopedState,
|
|
||||||
TableRecoilScopeContext,
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleColumnVisibilityChange = useCallback(
|
const handleColumnVisibilityChange = useCallback(
|
||||||
(column: ColumnDefinition<ViewFieldMetadata>) => {
|
(column: ColumnDefinition<ViewFieldMetadata>) => {
|
||||||
@ -37,9 +32,8 @@ export const useTableColumns = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
setTableColumns(nextColumns);
|
setTableColumns(nextColumns);
|
||||||
setSortAndFilterBar(true);
|
|
||||||
},
|
},
|
||||||
[tableColumnsByKey, tableColumns, setTableColumns, setSortAndFilterBar],
|
[tableColumnsByKey, tableColumns, setTableColumns],
|
||||||
);
|
);
|
||||||
|
|
||||||
return { handleColumnVisibilityChange };
|
return { handleColumnVisibilityChange };
|
||||||
|
|||||||
@ -5,6 +5,8 @@ import { DropdownRecoilScopeContext } from '@/ui/dropdown/states/recoil-scope-co
|
|||||||
import { FilterDropdownButton } from '@/ui/filter-n-sort/components/FilterDropdownButton';
|
import { FilterDropdownButton } from '@/ui/filter-n-sort/components/FilterDropdownButton';
|
||||||
import SortAndFilterBar from '@/ui/filter-n-sort/components/SortAndFilterBar';
|
import SortAndFilterBar from '@/ui/filter-n-sort/components/SortAndFilterBar';
|
||||||
import { SortDropdownButton } from '@/ui/filter-n-sort/components/SortDropdownButton';
|
import { SortDropdownButton } from '@/ui/filter-n-sort/components/SortDropdownButton';
|
||||||
|
import { canPersistFiltersScopedSelector } from '@/ui/filter-n-sort/states/selectors/canPersistFiltersScopedSelector';
|
||||||
|
import { canPersistSortsScopedSelector } from '@/ui/filter-n-sort/states/selectors/canPersistSortsScopedSelector';
|
||||||
import { sortsScopedState } from '@/ui/filter-n-sort/states/sortsScopedState';
|
import { sortsScopedState } from '@/ui/filter-n-sort/states/sortsScopedState';
|
||||||
import { FiltersHotkeyScope } from '@/ui/filter-n-sort/types/FiltersHotkeyScope';
|
import { FiltersHotkeyScope } from '@/ui/filter-n-sort/types/FiltersHotkeyScope';
|
||||||
import { SelectedSortType, SortType } from '@/ui/filter-n-sort/types/interface';
|
import { SelectedSortType, SortType } from '@/ui/filter-n-sort/types/interface';
|
||||||
@ -54,6 +56,13 @@ export function TableHeader<SortField>({
|
|||||||
const canPersistTableColumns = useRecoilValue(
|
const canPersistTableColumns = useRecoilValue(
|
||||||
canPersistTableColumnsScopedSelector([tableScopeId, currentTableViewId]),
|
canPersistTableColumnsScopedSelector([tableScopeId, currentTableViewId]),
|
||||||
);
|
);
|
||||||
|
const canPersistFilters = useRecoilValue(
|
||||||
|
canPersistFiltersScopedSelector([tableScopeId, currentTableViewId]),
|
||||||
|
);
|
||||||
|
|
||||||
|
const canPersistSorts = useRecoilValue(
|
||||||
|
canPersistSortsScopedSelector([tableScopeId, currentTableViewId]),
|
||||||
|
);
|
||||||
|
|
||||||
const sortSelect = useCallback(
|
const sortSelect = useCallback(
|
||||||
(newSort: SelectedSortType<SortField>) => {
|
(newSort: SelectedSortType<SortField>) => {
|
||||||
@ -106,7 +115,9 @@ export function TableHeader<SortField>({
|
|||||||
}
|
}
|
||||||
bottomComponent={
|
bottomComponent={
|
||||||
<SortAndFilterBar
|
<SortAndFilterBar
|
||||||
canToggle={canPersistTableColumns}
|
canPersistView={
|
||||||
|
canPersistTableColumns || canPersistFilters || canPersistSorts
|
||||||
|
}
|
||||||
context={TableRecoilScopeContext}
|
context={TableRecoilScopeContext}
|
||||||
sorts={sorts}
|
sorts={sorts}
|
||||||
onRemoveSort={sortUnselect}
|
onRemoveSort={sortUnselect}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ module.exports = {
|
|||||||
'useRecoilState',
|
'useRecoilState',
|
||||||
'useRecoilFamilyState',
|
'useRecoilFamilyState',
|
||||||
'useRecoilSelector',
|
'useRecoilSelector',
|
||||||
'useRecoilScopedDate',
|
'useRecoilScopedState',
|
||||||
'useRecoilScopedFamilyState',
|
'useRecoilScopedFamilyState',
|
||||||
'useRecoilScopedSelector',
|
'useRecoilScopedSelector',
|
||||||
'useRecoilValue',
|
'useRecoilValue',
|
||||||
|
|||||||
Reference in New Issue
Block a user