Skip to content

Commit

Permalink
package upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
ensaremirerol committed Dec 11, 2024
1 parent dfcd190 commit f3e7cd0
Show file tree
Hide file tree
Showing 17 changed files with 624 additions and 311 deletions.
464 changes: 221 additions & 243 deletions app/package-lock.json

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@
"preview": "vite preview"
},
"dependencies": {
"@blueprintjs/core": "^5.16.0",
"@blueprintjs/icons": "^5.15.0",
"@blueprintjs/select": "^5.3.5",
"@blueprintjs/table": "^5.2.7",
"axios": "^1.7.8",
"@blueprintjs/core": "5.16.1",
"@blueprintjs/icons": "5.15.1",
"@blueprintjs/select": "5.3.6",
"@blueprintjs/table": "5.3.0",
"axios": "1.7.9",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^7.0.1",
"zustand": "^5.0.1"
"react-router-dom": "7.0.2",
"zustand": "5.0.2"
},
"devDependencies": {
"@eslint/js": "^9.15.0",
"@eslint/js": "9.16.0",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@vitejs/plugin-react": "^4.3.4",
"eslint": "^9.15.0",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.14",
"globals": "^15.12.0",
"sass-embedded": "^1.81.0",
"typescript": "~5.6.2",
"typescript-eslint": "^8.15.0",
"vite": "^6.0.0"
"@vitejs/plugin-react": "4.3.4",
"eslint": "9.16.0",
"eslint-plugin-react-hooks": "5.1.0",
"eslint-plugin-react-refresh": "0.4.16",
"globals": "15.13.0",
"sass-embedded": "1.82.0",
"typescript": "5.7.2",
"typescript-eslint": "8.18.0",
"vite": "6.0.3"
}
}
}
5 changes: 5 additions & 0 deletions app/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import WorkspacesPage from './pages/workspaces_page';

import './index.scss';
import OntologiesPage from './pages/ontologies_page';
import PrefixPage from './pages/prefixes_page';
import WorkspacePage from './pages/workspace_page';

const router = createBrowserRouter([
Expand All @@ -20,6 +21,10 @@ const router = createBrowserRouter([
path: '/workspaces/:uuid/ontologies',
element: <OntologiesPage />,
},
{
path: '/workspaces/:uuid/prefixes',
element: <PrefixPage />,
},
]);

const App = () => {
Expand Down
2 changes: 1 addition & 1 deletion app/src/consts/toast.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { OverlayToaster } from '@blueprintjs/core';

const toast = await OverlayToaster.createAsync({
const toast = OverlayToaster.create({
position: 'top',
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +0,0 @@
.card-item {
width: calc(25% - 10px);
max-height: fit-content;
}

h5 {
text-overflow: ellipsis;
overflow: hidden;
}

p {
text-overflow: ellipsis;
overflow: hidden;
}

@media (max-width: 768px) {
.card-item.bp5-card.bp5-elevation-2 {
width: calc(100% - 10px);
}
}

.card-item-actions {
display: flex;
margin-top: auto;
justify-content: right;
& > *:not(:first-child) {
margin-left: 10px;
}
}
18 changes: 7 additions & 11 deletions app/src/pages/ontologies_page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useNavigate, useParams } from 'react-router-dom';
import { Button, ButtonGroup, Navbar, NonIdealState } from '@blueprintjs/core';
import { useEffect, useState } from 'react';
import DeleteAlert from '../../components/DeleteAlert';
import toast from '../../consts/toast';
import useErrorToast from '../../hooks/useErrorToast';
import { Ontology } from '../../lib/api/ontology_api/types';
import AddOntologyDialog from './components/AddOntologyDialog';
Expand Down Expand Up @@ -65,10 +64,6 @@ const OntologiesPage = () => {
try {
createOntology(uuid, data);
refreshOntologies(uuid);
toast.show({
message: 'Ontology created',
intent: 'success',
});
} catch {
/* empty */
}
Expand Down Expand Up @@ -97,7 +92,7 @@ const OntologiesPage = () => {
<Navbar.Group align='right'>
<ButtonGroup>
<Button icon='add' onClick={() => setOpen('create')}>
Add new Ontology
Add Ontology
</Button>
</ButtonGroup>
</Navbar.Group>
Expand All @@ -120,19 +115,20 @@ const OntologiesPage = () => {
}
/>
)}
<div className='card-grid-4'>
{ontologies &&
ontologies.length > 0 &&
ontologies.map(ontology => (
{ontologies && ontologies.length > 0 && (
<div className='card-grid-4'>
{ontologies.map(ontology => (
<OntologyCardItem
key={ontology.uuid}
ontology={ontology}
onDelete={handleDelete}
onOpen={ontology => {
navigation(`/workspaces/${uuid}/ontologies/${ontology.uuid}`);
}}
/>
))}
</div>
</div>
)}
</div>
</div>
);
Expand Down
5 changes: 2 additions & 3 deletions app/src/pages/ontologies_page/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const defaultState: OntologiesPageState = {
const functions: ZustandActions<
OntologiesPageStateActions,
OntologiesPageState
// eslint-disable-next-line @typescript-eslint/no-unused-vars
> = (set, get) => ({
refreshOntologies(workspaceUuid: string) {
set({ isLoading: 'Loading ontologies...' });
Expand All @@ -60,7 +59,7 @@ const functions: ZustandActions<
data.file,
)
.then(() => {
set({ error: null });
get().refreshOntologies(workspaceUuid);
})
.catch(error => {
if (error instanceof Error) {
Expand All @@ -75,7 +74,7 @@ const functions: ZustandActions<
set({ isLoading: 'Deleting ontology...' });
OntologyApi.deleteOntologyInWorkspace(workspaceUuid, ontologyUuid)
.then(() => {
set({ error: null });
get().refreshOntologies(workspaceUuid);
})
.catch(error => {
if (error instanceof Error) {
Expand Down
101 changes: 101 additions & 0 deletions app/src/pages/prefixes_page/components/AddPrefixDialog/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import {
Button,
Callout,
Dialog,
DialogBody,
DialogFooter,
FormGroup,
InputGroup,
} from '@blueprintjs/core';
import { useRef, useState } from 'react';
import { Prefix } from '../../../../lib/api/prefix_api/types';

interface AddPrefixDialogProps {
open: boolean;
onClose: () => void;
onCreate: (data: Prefix) => void;
}

const AddPrefixDialog = (props: AddPrefixDialogProps) => {
const form_ref = useRef<HTMLFormElement>(null);

const [error, setError] = useState<string | null>(null);

const onClose = () => {
props.onClose();
setError(null);
};

const submit = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
if (!form_ref.current) return;
setError(null);

const { prefix_value, uri } = form_ref.current;

if (!prefix_value || !uri) {
setError('Please fill all fields');
return;
}

// Check if baseUri is a valid URI
try {
new URL(uri.value);
} catch {
setError('Invalid base URI');
return;
}

props.onCreate({
prefix: prefix_value.value,
uri: uri.value,
});
};

return (
<Dialog
className='bp5-dark'
isOpen={props.open}
title='Add Prefix'
onClose={onClose}
>
<form ref={form_ref} onSubmit={submit}>
<DialogBody>
{error && (
<Callout className='error-callout' intent='danger'>
{error}
</Callout>
)}
<FormGroup
label='Prefix'
labelFor='prefix_value'
labelInfo='(required)'
>
<InputGroup id='prefix_value' name='prefix_value' required />
</FormGroup>
<FormGroup label='URI' labelFor='uri' labelInfo='(required)'>
<InputGroup id='uri' name='uri' type='url' required />
</FormGroup>
</DialogBody>
<DialogFooter
actions={
<>
<Button text='Cancel' onClick={onClose} />
<Button
text='Create'
intent='primary'
onClick={() =>
form_ref.current?.dispatchEvent(
new Event('submit', { cancelable: true, bubbles: true }),
)
}
/>
</>
}
/>
</form>
</Dialog>
);
};

export default AddPrefixDialog;
32 changes: 32 additions & 0 deletions app/src/pages/prefixes_page/components/PrefixCardItem/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Button } from '@blueprintjs/core';
import CardItem from '../../../../components/CardItem';
import { Prefix } from '../../../../lib/api/prefix_api/types';

interface PrefixCardItemProps {
prefix: Prefix;
onDelete: (Prefix: Prefix) => void;
}

const PrefixCardItem = ({ prefix, onDelete }: PrefixCardItemProps) => {
return (
<CardItem
title={prefix.prefix}
description={
<>
<p>
<b>URI</b>: {prefix.uri}
</p>
</>
}
actions={
<>
<Button intent='danger' onClick={() => onDelete(prefix)}>
Delete
</Button>
</>
}
/>
);
};

export default PrefixCardItem;
Loading

0 comments on commit f3e7cd0

Please sign in to comment.