Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#863 js docs #866

Merged
merged 5 commits into from
Mar 21, 2024
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
1 change: 1 addition & 0 deletions .vscode/recommendations.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ms-vscode.vscode-typescript-next",
"dbaeumer.vscode-eslint",
"antfu.vite",
"DavidAnson.vscode-markdownlint",
"ms-playwright.playwright"
]
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ By far most changes relate to `atomic-server`, so if not specified, assume the c
**Changes to JS assets (including the front-end and JS libraries) are not shown here**, but in [`/browser/CHANGELOG`](/browser/CHANGELOG.md).
See [STATUS.md](server/STATUS.md) to learn more about which features will remain stable.

## [UNRELEASED]

- Remove `process-management` feature #324 #334

## [v0.37.0] - 2024-02-01

- Refactor `atomic_lib::Resource` propval methods (e.g. `set_propval` => `set`), make them chainable. #822
Expand Down
46 changes: 1 addition & 45 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 26 additions & 3 deletions browser/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,36 @@ This changelog covers all three packages, as they are (for now) updated as a who
- [#850](https://github.com/atomicdata-dev/atomic-server/issues/850) Add drag & drop sorting to ResourceArray inputs.
- [#757](https://github.com/atomicdata-dev/atomic-server/issues/757) Add drag & drop sorting to sidebar.

### @tomic/lib

- Deprecated `resource.getSubject()` in favor of `resource.subject`.
- Deprecated `store.getResouceAsync()` in favor of `store.getResource()`.
- Deprecated `resource.pushPropval()` in favor of `resource.push()`.
- Deprecated `resource.removePropval()` in favor of `resource.remove()`.
- Added `resource.matchClass()` method.
- Added `resource.setVersion()` method.
- Added `collection.getMembersOnPage()` method.
- Added `collection.numberOfPages`.
- BREAKING CHANGE: Renamed `resource.getCommitsCollection` to `resource.getCommitsCollectionSubject`.
- BREAKING CHANGE: `resource.getChildrenCollection()` now returns a `Promise<Collection>` instead of a subject.
- BREAKING CHANGE: Resource now keeps a reference to store internally, therefore all methods that required you to pass a store have been changed to not require a store.
These methods are:
- `resource.canWrite()`
- `resource.getHistory()`
- `resource.getRights()`
- `resource.destroy()`
- `resource.save()`
- `resource.set()`
- `resource.removeClasses()`
- `resource.addClasses()`

## v0.37.0

### Atomic Browser

- [#747](https://github.com/atomicdata-dev/atomic-server/issues/747) Show ontology classes on new resource page.
- [#770](https://github.com/atomicdata-dev/atomic-server/issues/770) Display more info on search result page.
- [#771](https://github.com/atomicdata-dev/atomic-server/issues/771) Tables: Don't paste in multiple rows when focussed on an input
- [#747](https://github.com/atomicdata-dev/atomic-server/issues/747) Show ontology classes on the new resource page.
- [#770](https://github.com/atomicdata-dev/atomic-server/issues/770) Display more info on the search result page.
- [#771](https://github.com/atomicdata-dev/atomic-server/issues/771) Tables: Don't paste in multiple rows when focused on an input
- [#758](https://github.com/atomicdata-dev/atomic-server/issues/758) Fix Relation column forms to close when clicking on the searchbox
- [#780](https://github.com/atomicdata-dev/atomic-server/issues/780) Use tags in ontology editor to create enum properties.
- [#810](https://github.com/atomicdata-dev/atomic-server/issues/810) Add button to resource selectors to navigate to the selected resource.
Expand Down
25 changes: 13 additions & 12 deletions browser/data-browser/src/components/InviteForm.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {
useResource,
useStore,
properties,
Resource,
urls,
useCurrentAgent,
core,
server,
} from '@tomic/react';
import { useCallback, useState } from 'react';
import toast from 'react-hot-toast';
Expand Down Expand Up @@ -35,41 +36,41 @@ export function InviteForm({ target }: InviteFormProps) {

/** Stores the Invite, sends it to the server, shows the Subject to the User */
const createInvite = useCallback(async () => {
await invite.set(properties.isA, [urls.classes.invite], store);
await invite.set(properties.read, [urls.instances.publicAgent], store);
await invite.set(properties.invite.target, target.getSubject(), store);
await invite.set(core.properties.isA, [server.classes.invite]);
await invite.set(core.properties.read, [urls.instances.publicAgent]);
await invite.set(server.properties.target, target.subject);

try {
if (!agent) {
throw new Error('No agent found');
}

await invite.set(properties.parent, agent.subject, store);
await invite.save(store);
await navigator.clipboard.writeText(invite.getSubject());
await invite.set(core.properties.parent, agent.subject);
await invite.save();
await navigator.clipboard.writeText(invite.subject);
toast.success('Copied to clipboard');
setSaved(true);
} catch (e) {
setErr(e);
}
}, [invite, store, agent, target]);
}, [invite, agent, target]);

if (!saved) {
return (
<Card>
<ResourceField
label={'Give edit rights'}
propertyURL={urls.properties.invite.write}
propertyURL={server.properties.write}
resource={invite}
/>
<ResourceField
label={'Invite text (optional)'}
propertyURL={urls.properties.description}
propertyURL={core.properties.description}
resource={invite}
/>
<ResourceField
label={'How many times this link can be used. No value = no limit.'}
propertyURL={urls.properties.invite.usagesLeft}
propertyURL={server.properties.usagesLeft}
resource={invite}
/>
<Button onClick={createInvite}>Create Invite</Button>
Expand All @@ -84,7 +85,7 @@ export function InviteForm({ target }: InviteFormProps) {
return (
<Card>
<p>Invite created and copied to clipboard! Send it to your buddy:</p>
<CodeBlock content={invite.getSubject()} data-test='invite-code' />
<CodeBlock content={invite.subject} data-test='invite-code' />
</Card>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function ResourceContextMenu({
const parent = resource.get(core.properties.parent);

try {
await resource.destroy(store);
await resource.destroy();
onAfterDelete?.();
toast.success('Resource deleted!');

Expand Down
25 changes: 10 additions & 15 deletions browser/data-browser/src/components/SideBar/useSidebarDnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
useSensor,
useSensors,
} from '@dnd-kit/core';
import { Resource, Store, core, dataBrowser, useStore } from '@tomic/react';
import { Resource, core, dataBrowser, useStore } from '@tomic/react';
import { useCallback, useState } from 'react';
import { getTransitionName } from '../../helpers/transitionName';
import { useSettings } from '../../helpers/AppSettings';
Expand All @@ -24,7 +24,6 @@ export type SideBarDragData = {
};

async function moveItemInSameParent(
store: Store,
parent: Resource,
subject: string,
toPosition: number,
Expand All @@ -40,13 +39,12 @@ async function moveItemInSameParent(
removed,
);

await parent.set(dataBrowser.properties.subResources, newArray, store);
await parent.set(dataBrowser.properties.subResources, newArray);

await parent.save(store);
await parent.save();
}

async function moveItemBetweenParents(
store: Store,
oldParent: Resource,
newParent: Resource,
resource: Resource,
Expand All @@ -56,24 +54,22 @@ async function moveItemBetweenParents(
oldParent.get(dataBrowser.properties.subResources) ?? [];
await oldParent.set(
dataBrowser.properties.subResources,
oldSubResources.filter(subject => subject !== resource.getSubject()),
store,
oldSubResources.filter(subject => subject !== resource.subject),
);

const newSubResources =
newParent.get(dataBrowser.properties.subResources) ?? [];

await newParent.set(
dataBrowser.properties.subResources,
newSubResources.toSpliced(position, 0, resource.getSubject()),
store,
newSubResources.toSpliced(position, 0, resource.subject),
);

await resource.set(core.properties.parent, newParent.getSubject(), store);
await resource.set(core.properties.parent, newParent.subject);

await oldParent.save(store);
await newParent.save(store);
await resource.save(store);
await oldParent.save();
await newParent.save();
await resource.save();
}

export const useSidebarDnd = (
Expand Down Expand Up @@ -193,10 +189,9 @@ export const useSidebarDnd = (
let promise: Promise<void>;

if (renderedUnder === dropParent) {
promise = moveItemInSameParent(store, newParent, subject, position);
promise = moveItemInSameParent(newParent, subject, position);
} else {
promise = moveItemBetweenParents(
store,
oldParent,
newParent,
resource,
Expand Down
2 changes: 1 addition & 1 deletion browser/data-browser/src/components/Tag/CreateTagRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function CreateTagRow({ parent, onNewTag }: CreateTagRowProps) {
});

if (emoji) {
await tag.set(dataBrowser.properties.emoji, emoji, store);
await tag.set(dataBrowser.properties.emoji, emoji);
}

onNewTag(tag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ export function FilePicker({
const thisUnsub = store.on(
StoreEvents.ResourceSaved,
async savedResource => {
if (savedResource.getSubject() === resource.getSubject()) {
if (savedResource.subject === resource.subject) {
thisUnsub();
const [subject] = await upload([selectedFile]);
await setValue(subject);
resource.save(store);
resource.save();
}
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ export const registerBasicInstanceHandlers = () => {
[core.properties.read]: [agent.subject],
});

const agentResource = await store.getResourceAsync(agent.subject);
agentResource.pushPropVal(server.properties.drives, [
newResource.getSubject(),
]);
agentResource.save(store);
settings.setDrive(newResource.getSubject());
// resources created with createAndNavigate have a parent by default which we don't want for drives.
newResource.remove(core.properties.parent);

const agentResource = await store.getResource(agent.subject);
agentResource.push(server.properties.drives, [newResource.subject]);
agentResource.save();
settings.setDrive(newResource.subject);
},
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,22 @@ export const NewTableDialog: FC<CustomResourceDialogProps> = ({
const createResourceAndNavigate = useCreateAndNavigate();

const onCancel = useCallback(() => {
instanceResource.destroy(store);
instanceResource.destroy();
onClose();
}, [onClose, instanceResource, store]);
}, [onClose, instanceResource]);

const onSuccess = useCallback(async () => {
await instanceResource.set(
core.properties.shortname,
stringToSlug(name),
store,
);
await instanceResource.set(core.properties.shortname, stringToSlug(name));
await instanceResource.set(
core.properties.description,
`Represents a row in the ${name} table`,
store,
);
await instanceResource.set(
core.properties.isA,
[core.classes.class],
store,
);
await instanceResource.set(core.properties.parent, parent, store);
await instanceResource.set(
core.properties.recommends,
[core.properties.name],
store,
);
await instanceResource.save(store);
await instanceResource.set(core.properties.isA, [core.classes.class]);
await instanceResource.set(core.properties.parent, parent);
await instanceResource.set(core.properties.recommends, [
core.properties.name,
]);
await instanceResource.save();

createResourceAndNavigate(
dataBrowser.classes.table,
Expand All @@ -74,7 +63,7 @@ export const NewTableDialog: FC<CustomResourceDialogProps> = ({
);

onClose();
}, [name, instanceResource, store, onClose, parent]);
}, [name, instanceResource, onClose, parent]);

const [dialogProps, show, hide] = useDialog({ onCancel, onSuccess });

Expand Down
Loading
Loading