Skip to content

Commit 5e42b25

Browse files
authored
chore: upgrade findable to 35.1.0 (#4502) (#4505)
* chore: upgrade findable to 35.1.0 (#4502) * fix: added services provider (#4502)
1 parent 340a2c3 commit 5e42b25

File tree

20 files changed

+14035
-19453
lines changed

20 files changed

+14035
-19453
lines changed

app/components/Detail/components/AnVILCMG/components/RequestAccess/requestAccess.styles.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const StyledButton = styled(Button, {
2727
2828
.MuiButton-endIcon {
2929
margin-left: -6px;
30+
margin-right: 0;
3031
}
3132
3233
${({ open }) =>
Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,12 @@
11
import { CollapsableSection } from "@databiosphere/findable-ui/lib/components/common/Section/components/CollapsableSection/collapsableSection";
2-
import type { EvaluateOptions } from "@mdx-js/mdx";
3-
import { evaluate } from "@mdx-js/mdx";
4-
import type { MDXProps } from "mdx/types";
5-
import { ReactNode, useEffect, useState } from "react";
6-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7-
import remarkGfm from "remark-gfm";
8-
import { MDX_COMPONENTS } from "./common/constants";
2+
import { MarkdownRenderer } from "@databiosphere/findable-ui/lib/components/MarkdownRenderer/markdownRenderer";
93
import { DescriptionProps } from "./types";
10-
import DOMPurify from "isomorphic-dompurify";
11-
12-
type ReactMDXContent = (props: MDXProps) => ReactNode;
13-
type Runtime = Pick<EvaluateOptions, "jsx" | "jsxs" | "Fragment">;
14-
15-
const runtime = { Fragment, jsx, jsxs } as Runtime;
4+
import { MDX_COMPONENTS } from "./common/constants";
165

176
export const Description = ({ content }: DescriptionProps): JSX.Element => {
18-
const [MdxContent, setMdxContent] = useState<ReactMDXContent>(
19-
() => (): null => null
20-
);
21-
22-
useEffect(() => {
23-
const sanitizedContent = DOMPurify.sanitize(content)
24-
// escape curly braces
25-
.replace(/{/g, "&lcub;")
26-
.replace(/}/g, "&rcub;")
27-
// escape backticks
28-
.replace(/`/g, "&#96;");
29-
evaluate(sanitizedContent, { ...runtime, remarkPlugins: [remarkGfm] }).then(
30-
(r) => setMdxContent(() => r.default)
31-
);
32-
}, [content]);
33-
34-
// Wrapping <MdxContent> with <div> to force `display: block`
357
return (
368
<CollapsableSection collapsable={false} title="Description">
37-
<div>
38-
{MdxContent ? <MdxContent components={MDX_COMPONENTS} /> : null}
39-
</div>
9+
<MarkdownRenderer components={MDX_COMPONENTS} value={content} />
4010
</CollapsableSection>
4111
);
4212
};

app/config/utils.ts

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
import {
2-
Attribute,
3-
AttributeValueTypes,
4-
DataDictionaryColumnDef,
5-
SelectCategoryValue,
6-
} from "@databiosphere/findable-ui/lib/common/entities";
7-
import { CellContext, ColumnDef } from "@tanstack/react-table";
8-
import { BasicCell } from "@databiosphere/findable-ui/lib/components/DataDictionary/components/Table/components/BasicCell/basicCell";
9-
import { GridTrackSize } from "@databiosphere/findable-ui/lib/config/entities";
1+
import { SelectCategoryValue } from "@databiosphere/findable-ui/lib/common/entities";
102

113
/**
124
* Returns select category value with formatted label.
@@ -23,29 +15,3 @@ export function mapSelectCategoryValue(
2315
};
2416
};
2517
}
26-
27-
/**
28-
* Returns an array of column defs, built from column def configurations, to
29-
* use when displaying the data dictionary.
30-
* @param columnDefConfigs - Array of column def configurations.
31-
* @returns Array of column defs.
32-
*/
33-
export function buildColumnDefs(
34-
columnDefConfigs: DataDictionaryColumnDef[]
35-
): ColumnDef<Attribute, AttributeValueTypes>[] {
36-
return columnDefConfigs.map((columnDefConfig) => {
37-
const {
38-
attributeDisplayName: header,
39-
attributeSlotName: key,
40-
width,
41-
} = columnDefConfig;
42-
return {
43-
accessorFn: (row) => row[key as keyof Attribute],
44-
cell: (props: CellContext<Attribute, AttributeValueTypes>) =>
45-
BasicCell({ ...props }),
46-
header: `${header}`,
47-
id: key,
48-
meta: { width: width as GridTrackSize },
49-
};
50-
});
51-
}

app/utils/tsvParser.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import fs from "fs";
1010

1111
type ReturnType = string | number | boolean;
1212

13-
type FieldKey = string;
14-
1513
/**
1614
* Returns the file contents parsed into a model shaped by FIELD, or as row arrays if FIELD is omitted.
1715
*
@@ -24,8 +22,8 @@ type FieldKey = string;
2422
export const parseContentRows = async function parseContentRows<T>(
2523
content: Buffer | string,
2624
delimiter = ",",
27-
FIELD: { [key: FieldKey]: string },
28-
FIELD_TYPE: { [key: FieldKey]: string }
25+
FIELD: { [key: string]: string },
26+
FIELD_TYPE: { [key: string]: string }
2927
): Promise<T[]> {
3028
if (!FIELD) return parseCsv(content, { delimiter, relax_quotes: true });
3129
const keyTypes = Object.fromEntries(
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { MarkdownCell } from "@databiosphere/findable-ui/lib/components/Table/components/TableCell/components/MarkdownCell/markdownCell";
2+
import { Attribute } from "@databiosphere/findable-ui/lib/common/entities";
3+
import { ColumnDef } from "@tanstack/react-table";
4+
5+
export const COLUMN_DEFS: ColumnDef<Attribute>[] = [
6+
{
7+
accessorKey: "classKey",
8+
enableColumnFilter: false,
9+
header: "Class Key",
10+
id: "classKey",
11+
},
12+
{
13+
accessorKey: "title",
14+
enableColumnFilter: false,
15+
header: "Title",
16+
meta: {
17+
width: {
18+
max: "1fr",
19+
min: "200px",
20+
},
21+
},
22+
},
23+
{
24+
accessorFn: (row: Attribute) => ({ values: row.description }),
25+
cell: MarkdownCell,
26+
enableColumnFilter: false,
27+
header: "Description",
28+
meta: {
29+
width: {
30+
max: "2fr",
31+
min: "480px",
32+
},
33+
},
34+
},
35+
{
36+
accessorKey: "name",
37+
enableColumnFilter: false,
38+
header: "Name",
39+
meta: {
40+
width: {
41+
max: "1fr",
42+
min: "180px",
43+
},
44+
},
45+
},
46+
];
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {
2+
Attribute,
3+
DataDictionary,
4+
} from "@databiosphere/findable-ui/lib/common/entities";
5+
6+
/**
7+
* Returns a data dictionary built from the given data dictionary.
8+
* @param dataDictionary - The data dictionary.
9+
* @returns The built data dictionary.
10+
*/
11+
export function buildDataDictionary(
12+
dataDictionary: DataDictionary
13+
): DataDictionary<Attribute> {
14+
return {
15+
...dataDictionary,
16+
classes: dataDictionary.classes.map((classData) => {
17+
return {
18+
...classData,
19+
attributes: classData.attributes.map((attribute) => {
20+
return {
21+
...attribute,
22+
};
23+
}),
24+
};
25+
}),
26+
};
27+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { TableOptions } from "@tanstack/react-table";
2+
import { Attribute } from "@databiosphere/findable-ui/lib/common/entities";
3+
4+
export const TABLE_OPTIONS: Omit<
5+
TableOptions<Attribute>,
6+
"columns" | "data" | "getCoreRowModel"
7+
> = {
8+
initialState: {
9+
columnVisibility: { classKey: false },
10+
expanded: true,
11+
grouping: ["classKey"],
12+
},
13+
};

0 commit comments

Comments
 (0)