* Added Overview page * Revised Getting Started page * Minor revision * Edited readme, minor modifications to docs * Removed sweep.yaml, .devcontainer, .ergomake * Moved security.md to .github, added contributing.md * changes as per code review * updated contributing.md * fixed broken links & added missing links in doc, improved structure * fixed link in wsl setup * fixed server link, added https cloning in yarn-setup * removed package-lock.json * added doc card, admonitions * removed underline from nav buttons * refactoring modules/ui * refactoring modules/ui * Change folder case * Fix theme location * Fix case 2 * Fix storybook --------- Co-authored-by: Nimra Ahmed <nimra1408@gmail.com> Co-authored-by: Nimra Ahmed <50912134+nimraahmed@users.noreply.github.com>
53 lines
1.9 KiB
TypeScript
53 lines
1.9 KiB
TypeScript
import { useContext } from 'react';
|
|
import { useSearchParams } from 'react-router-dom';
|
|
import { useRecoilCallback } from 'recoil';
|
|
|
|
import { ViewBar } from '@/ui/data/view-bar/components/ViewBar';
|
|
import { ViewBarContext } from '@/ui/data/view-bar/contexts/ViewBarContext';
|
|
import { useRecoilScopeId } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopeId';
|
|
|
|
import { TableOptionsDropdownId } from '../../constants/TableOptionsDropdownId';
|
|
import { TableOptionsDropdown } from '../../options/components/TableOptionsDropdown';
|
|
import { TableRecoilScopeContext } from '../../states/recoil-scope-contexts/TableRecoilScopeContext';
|
|
import { savedTableColumnsFamilyState } from '../../states/savedTableColumnsFamilyState';
|
|
import { tableColumnsScopedState } from '../../states/tableColumnsScopedState';
|
|
import { TableOptionsHotkeyScope } from '../../types/TableOptionsHotkeyScope';
|
|
|
|
export const TableHeader = () => {
|
|
const { onCurrentViewSubmit, ...viewBarContextProps } =
|
|
useContext(ViewBarContext);
|
|
const tableRecoilScopeId = useRecoilScopeId(TableRecoilScopeContext);
|
|
const [_, setSearchParams] = useSearchParams();
|
|
|
|
const handleViewSelect = useRecoilCallback(
|
|
({ set, snapshot }) =>
|
|
async (viewId: string) => {
|
|
const savedTableColumns = await snapshot.getPromise(
|
|
savedTableColumnsFamilyState(viewId),
|
|
);
|
|
set(tableColumnsScopedState(tableRecoilScopeId), savedTableColumns);
|
|
setSearchParams({ view: viewId });
|
|
},
|
|
[tableRecoilScopeId, setSearchParams],
|
|
);
|
|
|
|
return (
|
|
<ViewBarContext.Provider
|
|
value={{
|
|
...viewBarContextProps,
|
|
onCurrentViewSubmit,
|
|
onViewSelect: handleViewSelect,
|
|
}}
|
|
>
|
|
<ViewBar
|
|
optionsDropdownButton={
|
|
<TableOptionsDropdown
|
|
customHotkeyScope={{ scope: TableOptionsHotkeyScope.Dropdown }}
|
|
/>
|
|
}
|
|
optionsDropdownScopeId={TableOptionsDropdownId}
|
|
/>
|
|
</ViewBarContext.Provider>
|
|
);
|
|
};
|