Skip to content

Commit 04bf5f7

Browse files
committed
Update docs for @reactodia/workspace@0.33.0
1 parent 2d8dfc7 commit 04bf5f7

5 files changed

Lines changed: 34 additions & 24 deletions

File tree

.github/workflows/ci-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
branches: [ "main" ]
1111

1212
env:
13-
reactodia_workspace_ref: 'v0.32.0'
13+
reactodia_workspace_ref: 'v0.33.0'
1414

1515
jobs:
1616
build:

.github/workflows/deploy-pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
workflow_dispatch:
99

1010
env:
11-
reactodia_workspace_ref: 'v0.32.0'
11+
reactodia_workspace_ref: 'v0.33.0'
1212

1313
jobs:
1414
build:

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@reactodia/reactodia.github.io",
3-
"version": "0.31.2",
3+
"version": "0.33.0",
44
"private": true,
55
"scripts": {
66
"docusaurus": "docusaurus",
@@ -21,7 +21,7 @@
2121
"@easyops-cn/docusaurus-search-local": "^0.51.0",
2222
"@mdx-js/react": "^3.1.0",
2323
"@reactodia/hashmap": "^0.2.1",
24-
"@reactodia/workspace": "^0.32.0",
24+
"@reactodia/workspace": "^0.33.0",
2525
"clsx": "^2.1.1",
2626
"n3": "^1.17.2",
2727
"prism-react-renderer": "^2.4.1",

src/examples/ExampleMetadata.ts

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -145,23 +145,27 @@ export class ExampleMetadataProvider extends Reactodia.BaseMetadataProvider {
145145
await Reactodia.delay(SIMULATED_DELAY, {signal});
146146
const properties = new Map<Reactodia.PropertyTypeIri, Reactodia.MetadataPropertyShape>();
147147
if (types.some(type => this.editableTypes.has(type))) {
148-
properties.set(rdfs.comment, {
148+
properties.set(Reactodia.rdfs.label, {
149149
valueShape: {termType: 'Literal'},
150+
order: 1,
150151
});
151-
properties.set(Reactodia.rdfs.label, {
152+
properties.set(rdfs.comment, {
152153
valueShape: {termType: 'Literal'},
154+
order: 2,
153155
});
154156
properties.set(Reactodia.schema.thumbnailUrl, {
155157
valueShape: {termType: 'NamedNode'},
156158
maxCount: 1,
159+
order: 3,
157160
});
158161
properties.set(rdfs.seeAlso, {
159162
valueShape: {termType: 'NamedNode'},
163+
order: 4,
160164
});
161165
}
162166
return {properties};
163167
},
164-
getRelationShape: async (linkType, {signal}) => {
168+
getRelationShape: async (linkType, source, target, {signal}) => {
165169
await Reactodia.delay(SIMULATED_DELAY, {signal});
166170
const properties = new Map<Reactodia.PropertyTypeIri, Reactodia.MetadataPropertyShape>();
167171
if (this.editableRelations.has(linkType)) {
@@ -183,11 +187,16 @@ export class ExampleValidationProvider implements Reactodia.ValidationProvider {
183187
async validate(
184188
event: Reactodia.ValidationEvent
185189
): Promise<Reactodia.ValidationResult> {
190+
const {target, outboundLinks, graph, state, translation, language, signal} = event;
186191
const items: Array<Reactodia.ValidatedElement | Reactodia.ValidatedLink> = [];
187192

188-
if (event.target.types.includes(owl.Class)) {
189-
event.state.links.forEach(e => {
190-
if (e.type === 'relationAdd' && e.data.sourceId === event.target.id) {
193+
if (target.types.includes(owl.Class)) {
194+
for (const e of state.links.values()) {
195+
if (e.type === 'relationAdd' && e.data.sourceId === target.id) {
196+
const linkType = graph.getLinkType(e.data.linkTypeId);
197+
const linkLabel = translation.formatLabel(
198+
linkType?.data?.label, e.data.linkTypeId, language
199+
);
191200
items.push({
192201
type: 'link',
193202
target: e.data,
@@ -196,41 +205,42 @@ export class ExampleValidationProvider implements Reactodia.ValidationProvider {
196205
});
197206
items.push({
198207
type: 'element',
199-
target: event.target.id,
208+
target: target.id,
200209
severity: 'warning',
201-
message: `Cannot create <${e.data.linkTypeId}> link from a Class`,
210+
message: `Cannot create "${linkLabel}" relation from a Class`,
202211
});
203212
}
204-
});
213+
}
205214
}
206215

207216
if (
208-
event.state.elements.has(event.target.id) &&
209-
event.target.types.includes(owl.ObjectProperty)
217+
state.elements.has(target.id) &&
218+
target.types.includes(owl.ObjectProperty)
210219
) {
211-
if (!event.outboundLinks.some(link => link.linkTypeId === rdfs.subPropertyOf)) {
220+
if (!outboundLinks.some(link => link.linkTypeId === rdfs.subPropertyOf)) {
212221
items.push({
213222
type: 'element',
214-
target: event.target.id,
223+
target: target.id,
215224
severity: 'info',
216225
message: 'It might be a good idea to make the property a sub-property of another',
217226
});
218227
}
219228
}
220229

221-
for (const link of event.outboundLinks) {
230+
for (const link of outboundLinks) {
222231
const {[rdfs.comment]: comments} = link.properties;
223232
if (comments && !comments.every(comment => comment.termType === 'Literal' && comment.language)) {
224233
items.push({
225234
type: 'link',
226235
target: link,
227236
severity: 'error',
228-
message: 'rdfs:comment value should have a language',
237+
message: 'value should have a language',
238+
propertyType: rdfs.comment,
229239
});
230240
}
231241
}
232242

233-
await Reactodia.delay(SIMULATED_DELAY, {signal: event.signal});
243+
await Reactodia.delay(SIMULATED_DELAY, {signal});
234244
return {items};
235245
}
236246
}

0 commit comments

Comments
 (0)