From 42d20d02d2f2e533e4c6511393d1bc92c590b7fc Mon Sep 17 00:00:00 2001 From: Polle Pas Date: Mon, 2 Dec 2024 11:57:58 +0100 Subject: [PATCH 01/30] Switch to tsup for package builds + enable noImplicitAny #1018 --- browser/.gitignore | 7 + browser/CHANGELOG.md | 5 + browser/Earthfile | 6 + browser/cli/package.json | 13 +- browser/create-template/package.json | 11 +- browser/data-browser/src/App.tsx | 9 +- .../CurrencyPicker/processCurrencyFile.ts | 7 +- .../SlashMenu/CommandsExtension.ts | 3 +- .../components/Dropdown/DefaultTrigger.tsx | 7 +- .../src/components/SearchFilter.tsx | 64 -- .../data-browser/src/components/Searchbar.tsx | 6 +- .../components/TableEditor/TableEditor.tsx | 11 +- .../Template/ApplyTemplateDialog.tsx | 2 +- .../data-browser/src/components/Toaster.tsx | 28 +- .../src/routes/History/versionHelpers.ts | 23 +- .../data-browser/src/routes/SearchRoute.tsx | 56 +- .../views/BookmarkPage/BookmarkPreview.tsx | 2 +- .../src/views/BookmarkPage/usePreview.ts | 10 +- .../data-browser/src/views/ChatRoomPage.tsx | 10 +- .../data-browser/src/views/EndpointPage.tsx | 4 +- browser/data-browser/src/views/ErrorPage.tsx | 17 +- .../src/views/OntologyPage/InlineDatatype.tsx | 13 +- browser/data-browser/tsconfig.json | 8 - browser/lib/README.md | 2 +- browser/lib/package.json | 44 +- browser/lib/src/authentication.ts | 13 +- browser/lib/src/client.ts | 11 +- browser/lib/src/commit.ts | 70 +- browser/lib/src/datatypes.ts | 4 +- browser/lib/src/index.ts | 4 - browser/lib/src/ontology.ts | 10 +- browser/lib/src/parse.ts | 13 +- browser/lib/src/resource.ts | 21 +- browser/lib/src/store.ts | 4 +- browser/lib/tsconfig.json | 24 +- browser/lib/tsup.config.ts | 33 + .../lib/{vite.config.ts => vitest.config.ts} | 9 +- browser/package.json | 1 + browser/pnpm-lock.yaml | 957 +++++++++++++----- browser/react/README.md | 51 +- browser/react/package.json | 54 +- browser/react/src/useChildren.ts | 1 - browser/react/tsconfig.json | 14 +- browser/react/tsup.config.ts | 33 + browser/svelte/package.json | 11 +- browser/tsconfig.build.json | 33 +- browser/tsconfig.json | 19 - docs/src/js-cli.md | 18 +- docs/src/js.md | 3 +- 49 files changed, 1178 insertions(+), 601 deletions(-) delete mode 100644 browser/data-browser/src/components/SearchFilter.tsx create mode 100644 browser/lib/tsup.config.ts rename browser/lib/{vite.config.ts => vitest.config.ts} (54%) create mode 100644 browser/react/tsup.config.ts diff --git a/browser/.gitignore b/browser/.gitignore index 5b0e76b5e..75baf8392 100644 --- a/browser/.gitignore +++ b/browser/.gitignore @@ -6,6 +6,7 @@ publish .husky .nohup .swc +.tsup */lib */dist */dev-dist @@ -26,3 +27,9 @@ data-browser/coverage !.yarn/versions .DS_Store **/.trunk/* + +**/tomic-lib-**.tgz +**/tomic-react-**.tgz +**/tomic-svelte-**.tgz +**/tomic-cli-**.tgz +**/tomic-create-template-**.tgz diff --git a/browser/CHANGELOG.md b/browser/CHANGELOG.md index 8c8401539..eebf839de 100644 --- a/browser/CHANGELOG.md +++ b/browser/CHANGELOG.md @@ -24,6 +24,11 @@ This changelog covers all five packages, as they are (for now) updated as a whol - Added `store.preloadResourceTree()` method, see docs for more info. - Fix generated ontologies not working in a Next.js server context. - SEMI BREAKING CHANGE: When using generated types by cli, @tomic/lib now requires them to be generated by @tomic/cli v0.41.0 or above. +- Fix types masquerading as esm module in cjs build. + +### @tomic/react + +- Add cjs build. ### @tomic/cli diff --git a/browser/Earthfile b/browser/Earthfile index a01800b8c..fc215e5f6 100644 --- a/browser/Earthfile +++ b/browser/Earthfile @@ -7,6 +7,7 @@ all: BUILD +build BUILD +test BUILD +lint + BUILD +lint-package BUILD +typedoc deps: @@ -18,6 +19,7 @@ deps: COPY react/package.json react/. COPY svelte/package.json svelte/. COPY cli/package.json cli/. + COPY create-template/package.json create-template/. RUN pnpm install --frozen-lockfile --shamefully-hoist COPY . . @@ -30,6 +32,10 @@ lint: FROM +deps RUN pnpm run lint +lint-package: + FROM +deps + RUN pnpm run lint-package + build: FROM +deps RUN pnpm run build diff --git a/browser/cli/package.json b/browser/cli/package.json index 5d06ab362..d22ed034f 100644 --- a/browser/cli/package.json +++ b/browser/cli/package.json @@ -1,6 +1,14 @@ { "version": "0.40.0", "author": "Polle Pas", + "homepage": "https://docs.atomicdata.dev/js-cli", + "repository": { + "type": "git", + "url": "git+https://github.com/atomicdata-dev/atomic-server.git" + }, + "bugs": { + "url": "https://github.com/atomicdata-dev/atomic-server/issues" + }, "dependencies": { "@tomic/lib": "workspace:*", "chalk": "^5.3.0", @@ -9,7 +17,7 @@ "devDependencies": { "typescript": "^5.6.3" }, - "description": "", + "description": "Generate types from Atomic Data ontologies", "license": "MIT", "name": "@tomic/cli", "publishConfig": { @@ -19,7 +27,8 @@ "build": "tsc", "lint": "eslint ./src --ext .js,.ts", "lint-fix": "eslint ./src --ext .js,.ts --fix", - "prepublishOnly": "pnpm run build && pnpm run lint-fix", + "prepublishOnly": "pnpm run build && pnpm run lint && pnpm run lint-package", + "lint-package": "pnpm dlx publint", "watch": "tsc --build --watch", "start": "pnpm watch", "tsc": "pnpm exec tsc --build", diff --git a/browser/create-template/package.json b/browser/create-template/package.json index ffb1ff4fc..340a68dec 100644 --- a/browser/create-template/package.json +++ b/browser/create-template/package.json @@ -1,6 +1,14 @@ { "version": "0.40.0", "author": "Polle Pas", + "homepage": "https://docs.atomicdata.dev/create-template/atomic-template", + "repository": { + "type": "git", + "url": "git+https://github.com/atomicdata-dev/atomic-server.git" + }, + "bugs": { + "url": "https://github.com/atomicdata-dev/atomic-server/issues" + }, "dependencies": { "@tomic/lib": "workspace:*", "chalk": "^5.3.0", @@ -20,7 +28,8 @@ "build": "tsc", "lint": "eslint ./src --ext .js,.ts", "lint-fix": "eslint ./src --ext .js,.ts --fix", - "prepublishOnly": "pnpm run build && pnpm run lint-fix", + "prepublishOnly": "pnpm run build && pnpm run lint && pnpm run lint-package", + "lint-package": "pnpm dlx publint", "watch": "tsc --build --watch", "start": "pnpm exec tsc --build --watch", "tsc": "pnpm exec tsc --build", diff --git a/browser/data-browser/src/App.tsx b/browser/data-browser/src/App.tsx index a9b21ccae..32755ec6c 100644 --- a/browser/data-browser/src/App.tsx +++ b/browser/data-browser/src/App.tsx @@ -1,7 +1,7 @@ import { BrowserRouter } from 'react-router-dom'; import { HelmetProvider } from 'react-helmet-async'; import { StoreContext, Store } from '@tomic/react'; -import { StyleSheetManager } from 'styled-components'; +import { StyleSheetManager, type ShouldForwardProp } from 'styled-components'; import { GlobalStyle, ThemeWrapper } from './styling'; import { AppRoutes } from './routes/Routes'; @@ -75,7 +75,7 @@ if (isDev()) { } // This implements the default behavior from styled-components v5 -function shouldForwardProp(propName, target) { +const shouldForwardProp: ShouldForwardProp<'web'> = (propName, target) => { if (typeof target === 'string') { // For HTML elements, forward the prop if it is a valid HTML attribute return isPropValid(propName); @@ -83,7 +83,7 @@ function shouldForwardProp(propName, target) { // For other elements, forward all props return true; -} +}; /** Entrypoint of the application. This is where providers go. */ function App(): JSX.Element { @@ -97,11 +97,10 @@ function App(): JSX.Element { - {/* @ts-ignore TODO: Check if types are fixed or upgrade styled-components to 6.0.0 */} {/* @ts-ignore fallback component type too strict */} - {/* Default form validation provider. Does not do anyting on its own but will make sure useValidation works without context*/} + {/* Default form validation provider. Does not do anything on its own but will make sure useValidation works without context*/} undefined} > diff --git a/browser/data-browser/src/chunks/CurrencyPicker/processCurrencyFile.ts b/browser/data-browser/src/chunks/CurrencyPicker/processCurrencyFile.ts index 39ac38fca..ab1553559 100644 --- a/browser/data-browser/src/chunks/CurrencyPicker/processCurrencyFile.ts +++ b/browser/data-browser/src/chunks/CurrencyPicker/processCurrencyFile.ts @@ -10,7 +10,7 @@ export const processCurrencyFile = (xmlStr: string): string => { const parser = new DOMParser(); const xmlDoc = parser.parseFromString(xmlStr, 'text/xml'); const currencyNodes = xmlDoc.getElementsByTagName('CcyNtry'); - const currencyMap = {}; + const currencyMap: Record = {}; for (let i = 0; i < currencyNodes.length; i++) { const currencyNode = currencyNodes[i]; @@ -22,7 +22,10 @@ export const processCurrencyFile = (xmlStr: string): string => { const currencyName = currencyNode.getElementsByTagName('CcyNm')[0]?.textContent; - currencyMap[code] = currencyName; + + if (currencyName) { + currencyMap[code] = currencyName; + } } return JSON.stringify(currencyMap); diff --git a/browser/data-browser/src/chunks/MarkdownEditor/SlashMenu/CommandsExtension.ts b/browser/data-browser/src/chunks/MarkdownEditor/SlashMenu/CommandsExtension.ts index 038a018af..f400647be 100644 --- a/browser/data-browser/src/chunks/MarkdownEditor/SlashMenu/CommandsExtension.ts +++ b/browser/data-browser/src/chunks/MarkdownEditor/SlashMenu/CommandsExtension.ts @@ -22,6 +22,7 @@ export const SlashCommands = Extension.create({ return { suggestion: { char: '/', + // @ts-expect-error Tiptap typing is not very good or clear so they're just any. command: ({ editor, range, props }) => { props.command({ editor, range }); }, @@ -46,7 +47,7 @@ export const suggestion: Partial = { icon: FaListUl, command: ({ editor, range }) => editor.chain().focus().deleteRange(range).toggleBulletList().run(), - }, + } as CommandItem, { title: 'Codeblock', icon: FaCode, diff --git a/browser/data-browser/src/components/Dropdown/DefaultTrigger.tsx b/browser/data-browser/src/components/Dropdown/DefaultTrigger.tsx index dde602dd8..408f319ec 100644 --- a/browser/data-browser/src/components/Dropdown/DefaultTrigger.tsx +++ b/browser/data-browser/src/components/Dropdown/DefaultTrigger.tsx @@ -1,6 +1,9 @@ import { useId } from 'react'; import { IconButton } from '../IconButton/IconButton'; -import { DropdownTriggerRenderFunction } from './DropdownTrigger'; +import { + DropdownTriggerRenderFunction, + type DropdownTriggerProps, +} from './DropdownTrigger'; /** Builds a default trigger for a dropdown menu using an IconButton. * Make sure the component stays mounted when the menu is open in order to have proper focus management. @@ -11,7 +14,7 @@ export const buildDefaultTrigger = ( ButtonComp: typeof IconButton = IconButton, ): DropdownTriggerRenderFunction => { const Comp = ( - { onClick, menuId, isActive }, + { onClick, menuId, isActive }: DropdownTriggerProps, ref: React.Ref, ) => { const id = useId(); diff --git a/browser/data-browser/src/components/SearchFilter.tsx b/browser/data-browser/src/components/SearchFilter.tsx deleted file mode 100644 index 6cc278ec1..000000000 --- a/browser/data-browser/src/components/SearchFilter.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import { useEffect, useState } from 'react'; -import { urls, useArray, useProperty, useResource } from '@tomic/react'; -import { ResourceSelector } from '../components/forms/ResourceSelector'; - -/** - * Shows a Class selector to the user. - * If a Class is selected, the filters for the required and recommended properties - * of that Class are shown. - */ -export function ClassFilter({ filters, setFilters }): JSX.Element { - const [klass, setClass] = useState(undefined); - const resource = useResource(klass); - const [requiredProps] = useArray(resource, urls.properties.requires); - const [recommendedProps] = useArray(resource, urls.properties.recommends); - const allProps = [...requiredProps, ...recommendedProps]; - - useEffect(() => { - // Set the filters to the default values of the properties - setFilters({ - ...filters, - [urls.properties.isA]: klass, - }); - }, [klass, JSON.stringify(filters)]); - - return ( -
- - {allProps?.map(propertySubject => ( - - ))} -
- ); -} - -function PropertyFilter({ filters, setFilters, subject }): JSX.Element { - const prop = useProperty(subject); - - function handleChange(e) { - setFilters({ - ...filters, - [prop.shortname]: e.target.value, - }); - } - - return ( -
- - -
- ); -} diff --git a/browser/data-browser/src/components/Searchbar.tsx b/browser/data-browser/src/components/Searchbar.tsx index 61da85233..f303d8e18 100644 --- a/browser/data-browser/src/components/Searchbar.tsx +++ b/browser/data-browser/src/components/Searchbar.tsx @@ -42,7 +42,7 @@ export function Searchbar({ } }; - function handleChange(e) { + const handleChange: React.ChangeEventHandler = e => { setInput(e.target.value); try { @@ -52,9 +52,9 @@ export function Searchbar({ } catch (_err) { navigate(searchURL(e.target.value, scope), { replace: true }); } - } + }; - const handleSubmit = (event: React.FormEvent) => { + const handleSubmit: React.FormEventHandler = event => { if (!subject) { return; } diff --git a/browser/data-browser/src/components/TableEditor/TableEditor.tsx b/browser/data-browser/src/components/TableEditor/TableEditor.tsx index 04b279107..ca71b14bd 100644 --- a/browser/data-browser/src/components/TableEditor/TableEditor.tsx +++ b/browser/data-browser/src/components/TableEditor/TableEditor.tsx @@ -8,7 +8,7 @@ import { } from 'react'; import { styled } from 'styled-components'; import { FixedSizeList, ListOnScrollProps } from 'react-window'; -import Autosizer from 'react-virtualized-auto-sizer'; +import Autosizer, { type VerticalSize } from 'react-virtualized-auto-sizer'; import { Cell, IndexCell } from './Cell'; import { TableRow } from './TableRow'; import { TableHeader, TableHeadingComponent } from './TableHeader'; @@ -157,7 +157,7 @@ function FancyTableInner({ ); const List = useCallback( - ({ height }) => ( + ({ height }: VerticalSize) => ( ({

{ARIA_TABLE_USAGE}

- {/* @ts-ignore */} (p => ({ style: { '--table-template-columns': p.gridTemplateColumns, '--table-content-width': p.contentRowWidth, - }, -}))` + } as Record, +}))` --table-height: 80vh; --table-row-height: ${p => p.rowHeight}px; --table-inner-padding: 0.5rem; @@ -257,7 +255,6 @@ const Table = styled.div.attrs(p => ({ &:focus-visible { outline: none; - /* border-color: ${p => p.theme.colors.main}; */ box-shadow: 0 0 0 2px ${p => p.theme.colors.main}; } `; diff --git a/browser/data-browser/src/components/Template/ApplyTemplateDialog.tsx b/browser/data-browser/src/components/Template/ApplyTemplateDialog.tsx index 92a16a7f3..28ffca7cc 100644 --- a/browser/data-browser/src/components/Template/ApplyTemplateDialog.tsx +++ b/browser/data-browser/src/components/Template/ApplyTemplateDialog.tsx @@ -26,7 +26,7 @@ interface ApplyTemplateDialogProps { bindOpen: (open: boolean) => void; } -const stableArray = []; +const stableArray: string[] = []; export function ApplyTemplateDialog({ template, diff --git a/browser/data-browser/src/components/Toaster.tsx b/browser/data-browser/src/components/Toaster.tsx index f283d0144..1c147cbbf 100644 --- a/browser/data-browser/src/components/Toaster.tsx +++ b/browser/data-browser/src/components/Toaster.tsx @@ -1,4 +1,9 @@ -import toast, { ToastBar, Toaster as ReactHotToast } from 'react-hot-toast'; +import toast, { + type Toast, + ToastBar, + Toaster as ReactHotToast, + type Renderable, +} from 'react-hot-toast'; import { FaCopy, FaTimes } from 'react-icons/fa'; import { useTheme } from 'styled-components'; import { zIndex } from '../styling'; @@ -45,12 +50,27 @@ export function Toaster(): JSX.Element { ); } -function ToastMessage({ icon, message, t }) { - let text = message.props.children; +interface ToastMessageProps { + icon: React.ReactNode; + message: Renderable; + t: Toast; +} + +function ToastMessage({ icon, message, t }: ToastMessageProps) { + let text: string; + + if (typeof message === 'string') { + text = message; + } else if (message && 'props' in message) { + // children can technically still be a react node but we never do that in our code so we'll just assume it to be a string. + text = message.props.children; + } else { + text = ''; + } function handleCopy() { toast.success('Copied error to clipboard'); - navigator.clipboard.writeText(message.props.children); + navigator.clipboard.writeText(text); toast.dismiss(t.id); } diff --git a/browser/data-browser/src/routes/History/versionHelpers.ts b/browser/data-browser/src/routes/History/versionHelpers.ts index aee9cc92d..511bb1b2e 100644 --- a/browser/data-browser/src/routes/History/versionHelpers.ts +++ b/browser/data-browser/src/routes/History/versionHelpers.ts @@ -38,16 +38,19 @@ export function dedupeVersions(versions: Version[]): Version[] { export function groupVersionsByMonth( versions: Version[], ): Record { - return versions.reduceRight((acc, version) => { - const createdDate = new Date(version.commit.createdAt); - const groupKey = groupFormatter.format(createdDate); - const group = acc[groupKey] ?? []; - - return { - ...acc, - [groupKey]: [...group, version], - }; - }, {}); + return versions.reduceRight( + (acc, version) => { + const createdDate = new Date(version.commit.createdAt); + const groupKey = groupFormatter.format(createdDate); + const group = acc[groupKey] ?? []; + + return { + ...acc, + [groupKey]: [...group, version], + }; + }, + {} as Record, + ); } function compareMaps(map1: Map, map2: Map) { diff --git a/browser/data-browser/src/routes/SearchRoute.tsx b/browser/data-browser/src/routes/SearchRoute.tsx index b39175f96..f0ddc4ef0 100644 --- a/browser/data-browser/src/routes/SearchRoute.tsx +++ b/browser/data-browser/src/routes/SearchRoute.tsx @@ -7,11 +7,9 @@ import ResourceCard from '../views/Card/ResourceCard'; import { useServerSearch } from '@tomic/react'; import { ErrorLook } from '../components/ErrorLook'; import { styled } from 'styled-components'; -import { FaFilter, FaSearch } from 'react-icons/fa'; +import { FaSearch } from 'react-icons/fa'; import { useQueryScopeHandler } from '../hooks/useQueryScope'; import { useSettings } from '../helpers/AppSettings'; -import { ClassFilter } from '../components/SearchFilter'; -import { Button } from '../components/Button'; import { Column } from '../components/Row'; import { Main } from '../components/Main'; @@ -20,7 +18,6 @@ export function Search(): JSX.Element { const [query] = useSearchQuery(); const { drive } = useSettings(); const { scope } = useQueryScopeHandler(); - const [filters, setFilters] = useState({}); const [enableFilter, setEnableFilter] = useState(false); useHotkeys( @@ -32,13 +29,10 @@ export function Search(): JSX.Element { [enableFilter], ); - const [showFilter, setShowFilter] = useState(false); - const [selectedIndex, setSelected] = useState(0); const { results, loading, error } = useServerSearch(query, { debounce: 0, parents: scope || drive, - filters, include: true, }); const navigate = useNavigate(); @@ -109,36 +103,19 @@ export function Search(): JSX.Element { {error.message} ) : ( <> -
- - - - {message ? ( - message - ) : ( - <> - {results.length}{' '} - {results.length > 1 ? 'Results' : 'Result'} for{' '} - {query} - - )} - - - {enableFilter && ( - - )} -
- {showFilter && ( - - )} + + + + {message ? ( + message + ) : ( + <> + {results.length} {results.length > 1 ? 'Results' : 'Result'}{' '} + for {query} + + )} + + {results.map((subject, index) => ( p.theme.margin * 3}rem; - > span { + margin-bottom: ${p => p.theme.size(8)}; + + & > span { overflow: hidden; text-overflow: ellipsis; } diff --git a/browser/data-browser/src/views/BookmarkPage/BookmarkPreview.tsx b/browser/data-browser/src/views/BookmarkPage/BookmarkPreview.tsx index c4b6998e1..ca4d0a412 100644 --- a/browser/data-browser/src/views/BookmarkPage/BookmarkPreview.tsx +++ b/browser/data-browser/src/views/BookmarkPage/BookmarkPreview.tsx @@ -33,7 +33,7 @@ export function BookmarkPreview({ ); } -const ErrorPage = ({ error }) => { +const ErrorPage = ({ error }: { error: Error }) => { return (
diff --git a/browser/data-browser/src/views/BookmarkPage/usePreview.ts b/browser/data-browser/src/views/BookmarkPage/usePreview.ts index 394d3f726..d6b335f4a 100644 --- a/browser/data-browser/src/views/BookmarkPage/usePreview.ts +++ b/browser/data-browser/src/views/BookmarkPage/usePreview.ts @@ -1,5 +1,11 @@ -import { AtomicError, ErrorType } from './../../../../lib/src/error'; -import { Resource, urls, useStore, useString } from '@tomic/react'; +import { + AtomicError, + ErrorType, + Resource, + urls, + useStore, + useString, +} from '@tomic/react'; import { startTransition, useCallback, useEffect, useState } from 'react'; import { debounce } from '../../helpers/debounce'; import { paths } from '../../routes/paths'; diff --git a/browser/data-browser/src/views/ChatRoomPage.tsx b/browser/data-browser/src/views/ChatRoomPage.tsx index ebd8eb281..49f2c5d69 100644 --- a/browser/data-browser/src/views/ChatRoomPage.tsx +++ b/browser/data-browser/src/views/ChatRoomPage.tsx @@ -66,7 +66,7 @@ export function ChatRoomPage({ resource }: ResourcePageProps) { const disableSend = newMessageVal.length === 0; /** Creates a message using the internal state */ - async function sendMessage(e?) { + async function sendMessage(e?: React.SyntheticEvent) { const messageBackup = newMessageVal; try { @@ -106,7 +106,9 @@ export function ChatRoomPage({ resource }: ResourcePageProps) { inputRef?.current?.focus(); } - function handleChangeMessageText(e) { + const handleChangeMessageText: React.ChangeEventHandler< + HTMLTextAreaElement + > = e => { setNewMessage(e.target.value); if (e.target.value === '') { @@ -128,7 +130,7 @@ export function ChatRoomPage({ resource }: ResourcePageProps) { if (trows !== textAreaHight) { setTextAreaHight(trows); } - } + }; return ( @@ -161,7 +163,7 @@ export function ChatRoomPage({ resource }: ResourcePageProps) { title='Send message [enter]' disabled={disableSend} clean - onClick={sendMessage} + onClick={() => sendMessage()} > Send diff --git a/browser/data-browser/src/views/EndpointPage.tsx b/browser/data-browser/src/views/EndpointPage.tsx index baadac6d8..d5be90db6 100644 --- a/browser/data-browser/src/views/EndpointPage.tsx +++ b/browser/data-browser/src/views/EndpointPage.tsx @@ -31,9 +31,9 @@ function EndpointPage({ resource }: EndpointProps): JSX.Element { const navigate = useNavigate(); /** Create the URL using the variables */ - async function constructSubject(e?) { + async function constructSubject(e?: React.SyntheticEvent) { e && e.preventDefault(); - const url = new URL(resource.getSubject()); + const url = new URL(resource.subject); await Promise.all( parameters.map(async propUrl => { diff --git a/browser/data-browser/src/views/ErrorPage.tsx b/browser/data-browser/src/views/ErrorPage.tsx index 4be11ec79..8f21f4d8d 100644 --- a/browser/data-browser/src/views/ErrorPage.tsx +++ b/browser/data-browser/src/views/ErrorPage.tsx @@ -17,7 +17,6 @@ import { clearAllLocalData } from '../helpers/clearData'; function ErrorPage({ resource }: ResourcePageProps): JSX.Element { const { agent } = useSettings(); const store = useStore(); - const subject = resource.getSubject(); if (isUnauthorized(resource.error)) { return ( @@ -28,7 +27,11 @@ function ErrorPage({ resource }: ResourcePageProps): JSX.Element { <> - @@ -47,12 +50,14 @@ function ErrorPage({ resource }: ResourcePageProps): JSX.Element { return ( -

Could not open {resource.getSubject()}

+

Could not open {resource.subject}