Skip to content
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
7,822 changes: 4,881 additions & 2,941 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@
"@types/d3-zoom": "^3.0.3",
"@types/jest": "^29.5.1",
"@types/node": "^20.1.3",
"@types/plotly.js": "^2.12.30",
"@types/react": "^18.2.6",
"@types/react-dom": "^18.2.4",
"@types/react-plotly.js": "^2.6.3",
"@types/react-router-dom": "^5.3.3",
"@types/uuid": "^8.3.4",
"@typescript-eslint/eslint-plugin": "^5.55.0",
Expand Down
2 changes: 0 additions & 2 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { ModalDialog } from '../features/layout/Modal';
import { useLoggedInProfileUser } from '../features/profile/profileSlice';
import Routes from './Routes';
import classes from './App.module.scss';
import { TooltipContainer } from '../common/components/Tooltip';

const useInitApp = () => {
const dispatch = useAppDispatch();
Expand Down Expand Up @@ -68,7 +67,6 @@ const App: FC = () => {
</Loader>
<Toaster />
<ModalDialog />
<TooltipContainer />
</ErrorBoundary>
</div>
</div>
Expand Down
18 changes: 8 additions & 10 deletions src/common/api/collectionsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ export interface HeatMapCell {
val: number | boolean;
}

export interface HeatMapRow<Meta = unknown> {
export interface HeatMapRow {
match: boolean;
sel: boolean;
kbase_id: KBaseId;
kbase_display_name: string;
cells: HeatMapCell[];
meta?: Meta;
meta?: Record<string, string>;
}

interface HeatMapColumnCategory {
Expand All @@ -115,9 +115,10 @@ interface HeatMapColumnCategory {

export interface HeatMapColumn {
col_id: string;
name: string;
description: string;
name: string;
type: 'float' | 'int' | 'bool' | 'count';
[key: string]: string;
}

interface ClientError {
Expand Down Expand Up @@ -890,19 +891,16 @@ export const collectionsApi = baseApi.injectEndpoints({
}),
});

export type CollectionsReturnType =
Comment thread
dauglyon marked this conversation as resolved.
typeof collectionsApi['endpoints'][keyof typeof collectionsApi['endpoints']]['initiate'];

export const parseCollectionsError = (
/**result.error object from any collections query.
* The type definition is unfortunately a bit visually hairy.
* But all the typedef is doing is extracting the error type.*/
error:
| Extract<
Awaited<
ReturnType<
ReturnType<
typeof collectionsApi['endpoints'][keyof typeof collectionsApi['endpoints']]['initiate']
>
>
>,
Awaited<ReturnType<ReturnType<CollectionsReturnType>>>,
{ error: unknown }
>['error']
| undefined
Expand Down
38 changes: 31 additions & 7 deletions src/common/components/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Table as TableType,
Row,
} from '@tanstack/react-table';
import type { RowData } from '@tanstack/react-table';
import { FontAwesomeIcon as FAIcon } from '@fortawesome/react-fontawesome';
import {
faArrowLeftLong,
Expand All @@ -22,6 +23,17 @@ import { CheckBox } from './CheckBox';
import { Loader } from './Loader';
import { HeatMapRow } from '../api/collectionsApi';

/*
See also: https://tanstack.com/table/v8/docs/api/core/column-def#meta
This supports passing arbitrary data into the table.
*/
declare module '@tanstack/react-table' {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface ColumnMeta<TData extends RowData, TValue> {
[key: string]: string;
}
}

type ColumnOptions = {
textAlign?: 'left' | 'right' | 'center';
};
Expand Down Expand Up @@ -108,13 +120,15 @@ export const Table = <Datum,>({
};

export const Pagination = <Datum,>({
table,
maxPage,
table,
className = '',
/**Odd, >=9*/
totalButtons = 9,
}: {
table: TableType<Datum>;
maxPage: number;
table: TableType<Datum>;
className?: string;
totalButtons?: number;
}) => {
Comment thread
dakotablair marked this conversation as resolved.
if (totalButtons < 9 || totalButtons % 2 !== 1)
Expand All @@ -136,6 +150,8 @@ export const Pagination = <Datum,>({
buttons.push(p);
}

const extraClasses = className ? `${className} ` : '';
const classNamePagination = `${extraClasses}${classes.pagination}`;
// add skip-to-start
if (buttons[0] !== start) {
buttons[0] = start;
Expand All @@ -147,9 +163,10 @@ export const Pagination = <Datum,>({
}
buttons.unshift(
<Button
key="prev"
className={classNamePagination}
color="base"
disabled={!table.getCanPreviousPage()}
key="prev"
onClick={() => table.previousPage()}
>
<FAIcon icon={faArrowLeftLong} />
Expand All @@ -160,16 +177,22 @@ export const Pagination = <Datum,>({
if (buttons[buttons.length - 1] !== end) {
buttons[buttons.length - 1] = end;
buttons[buttons.length - 2] = (
<Button key="etc-end" color="base" disabled>
<Button
key="etc-end"
className={classNamePagination}
color="base"
disabled
>
{'...'}
</Button>
);
}
buttons.push(
<Button
key="next"
className={classNamePagination}
color="base"
disabled={!table.getCanNextPage() || curr >= maxPage}
key="next"
onClick={() => table.nextPage()}
>
<FAIcon icon={faArrowRightLong} />
Expand All @@ -178,10 +201,11 @@ export const Pagination = <Datum,>({
const buttonList = buttons.map((button, ix) =>
typeof button === 'number' ? (
<Button
key={button}
className={classNamePagination}
color="base"
disabled={button === curr || button > maxPage}
hidden={button > maxPage} // Hides the max page when we can't display it
key={button}
onClick={() => table.setPageIndex(button)}
>
{button + 1}
Expand All @@ -191,7 +215,7 @@ export const Pagination = <Datum,>({
)
);
return (
<div className={classes['pagination']} data-testid="pagination">
<div className={classNamePagination} data-testid="pagination">
{buttonList}
</div>
);
Expand Down
44 changes: 0 additions & 44 deletions src/common/components/Tooltip.module.scss

This file was deleted.

101 changes: 0 additions & 101 deletions src/common/components/Tooltip.tsx

This file was deleted.

3 changes: 2 additions & 1 deletion src/common/components/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Button } from './Button';
import { Dropdown } from './Dropdown';
import { Input } from './Input';
import { Loader } from './Loader';
import { PlaceholderFactory } from './PlaceholderFactory';
import { Select, SelectOption } from './Select';

export { Button, Dropdown, Input, PlaceholderFactory, Select };
export { Button, Dropdown, Input, Loader, PlaceholderFactory, Select };
export type { SelectOption };
7 changes: 4 additions & 3 deletions src/features/collections/CollectionDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,9 @@ const FilterChips = ({ collectionId }: { collectionId: string }) => {
{filterEntries.map(([column, filter]) => {
return (
<FilterChip
name={column}
filter={filter}
key={`${column}-${filter.type}`}
name={column}
onDelete={() => clearFilterState(column)}
/>
);
Expand All @@ -277,7 +278,7 @@ const FilterMenu = (props: {
{filterEntries.flatMap(([column, filter]) => {
const hasVal = Boolean(filter.value);
const children = [
<Divider key={column + '__label'} textAlign="left">
<Divider key={`${column}__label`} textAlign="left">
<FilterChip
name={column}
filter={filter}
Expand All @@ -287,7 +288,7 @@ const FilterMenu = (props: {
onDelete={hasVal ? () => clearFilterState(column) : undefined}
/>
</Divider>,
<MenuItem>
<MenuItem key={`${column}__label`}>
<FilterControls
column={column}
filter={filter}
Expand Down
Loading