Skip to content

Commit 8080f2a

Browse files
committed
Integrate object creator into editor tool.
1 parent 7bf8113 commit 8080f2a

File tree

8 files changed

+79
-36
lines changed

8 files changed

+79
-36
lines changed

client/src/Editor/EditHome.jsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
import React from "react";
22
import ChildList from "./ChildList";
3+
import { Link } from "react-router-dom";
34

45
const EditHome = () => {
56
return (
67
<div>
7-
<p>Welcome to the editor!</p>
8+
<h1>Editor</h1>
9+
<h2>Tools</h2>
10+
<ul>
11+
<li>
12+
<Link to="/edit/newChild">Create New Top-Level Object</Link>
13+
</li>
14+
</ul>
15+
<h2>Contents</h2>
816
<ChildList />
917
</div>
1018
);

client/src/Editor/ObjectEditor.jsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
import React from "react";
22
import PropTypes from "prop-types";
33
import ChildList from "./ChildList";
4+
import { Link } from "react-router-dom";
45

56
const ObjectEditor = ({ pid }) => {
67
return (
78
<div>
8-
<p>You are editing {pid}</p>
9+
<h1>Editor: Object {pid}</h1>
10+
<h2>Tools</h2>
11+
<ul>
12+
<li>
13+
<Link to={`/edit/object/${pid}/newChild`}>Create New Child Object</Link>
14+
</li>
15+
</ul>
16+
<h2>Contents</h2>
917
<ChildList pid={pid} />
1018
</div>
1119
);

client/src/Editor/__snapshots__/EditHome.test.jsx.snap

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,24 @@
22

33
exports[`EditHome renders 1`] = `
44
<div>
5-
<p>
6-
Welcome to the editor!
7-
</p>
5+
<h1>
6+
Editor
7+
</h1>
8+
<h2>
9+
Tools
10+
</h2>
11+
<ul>
12+
<li>
13+
<Link
14+
to="/edit/newChild"
15+
>
16+
Create New Top-Level Object
17+
</Link>
18+
</li>
19+
</ul>
20+
<h2>
21+
Contents
22+
</h2>
823
<ChildList />
924
</div>
1025
`;

client/src/Editor/__snapshots__/ObjectEditor.test.jsx.snap

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,25 @@
22

33
exports[`ObjectEditor renders 1`] = `
44
<div>
5-
<p>
6-
You are editing
5+
<h1>
6+
Editor: Object
77
foo:123
8-
</p>
8+
</h1>
9+
<h2>
10+
Tools
11+
</h2>
12+
<ul>
13+
<li>
14+
<Link
15+
to="/edit/object/foo:123/newChild"
16+
>
17+
Create New Child Object
18+
</Link>
19+
</li>
20+
</ul>
21+
<h2>
22+
Contents
23+
</h2>
924
<ChildList
1025
pid="foo:123"
1126
/>

client/src/MainMenu.jsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ const MainMenu = () => {
2727
<Link to="/solr">Solr Indexer</Link>
2828
</li>
2929
</ul>
30-
<h2>Object Editor Pieces</h2>
31-
<ul>
32-
<li>
33-
<Link to="/editor/object/new">Create Object</Link>
34-
</li>
35-
</ul>
3630
</div>
3731
);
3832
};

client/src/Routes.jsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ import PdfGenerator from "./PdfGenerator";
1010
import SolrIndexer from "./SolrIndexer";
1111
import CreateObject from "./Editor/CreateObject";
1212

13+
const CreateObjectHook = () => {
14+
const { pid } = useParams();
15+
return <CreateObject parentPid={pid} allowNoParentPid={false} allowChangeParentPid={false} />;
16+
};
17+
1318
const JobPaginatorHook = () => {
1419
const { category, job } = useParams();
1520
return <JobPaginator initialCategory={category} initialJob={job} />;
@@ -29,6 +34,12 @@ const Routes = () => {
2934
<Route exact path="/edit">
3035
<EditHome />
3136
</Route>
37+
<Route exact path="/edit/newChild">
38+
<CreateObject allowNoParentPid={true} allowChangeParentPid={false} />
39+
</Route>
40+
<Route path="/edit/object/:pid/newChild">
41+
<CreateObjectHook />
42+
</Route>
3243
<Route path="/edit/object/:pid">
3344
<ObjectEditorHook />
3445
</Route>
@@ -44,9 +55,6 @@ const Routes = () => {
4455
<Route exact path="/solr">
4556
<SolrIndexer />
4657
</Route>
47-
<Route path="/editor/object/new">
48-
<CreateObject allowNoParentPid={true} />
49-
</Route>
5058
</Switch>
5159
);
5260
};

client/src/__snapshots__/MainMenu.test.js.snap

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,5 @@ exports[`MainMenu renders 1`] = `
6262
</Link>
6363
</li>
6464
</ul>
65-
<h2>
66-
Object Editor Pieces
67-
</h2>
68-
<ul>
69-
<li>
70-
<Link
71-
to="/editor/object/new"
72-
>
73-
Create Object
74-
</Link>
75-
</li>
76-
</ul>
7765
</div>
7866
`;

client/src/__snapshots__/Routes.test.js.snap

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ exports[`Routes render 1`] = `
1414
>
1515
<EditHome />
1616
</Route>
17+
<Route
18+
exact={true}
19+
path="/edit/newChild"
20+
>
21+
<CreateObject
22+
allowChangeParentPid={false}
23+
allowNoParentPid={true}
24+
/>
25+
</Route>
26+
<Route
27+
path="/edit/object/:pid/newChild"
28+
>
29+
<CreateObjectHook />
30+
</Route>
1731
<Route
1832
path="/edit/object/:pid"
1933
>
@@ -42,12 +56,5 @@ exports[`Routes render 1`] = `
4256
>
4357
<Component />
4458
</Route>
45-
<Route
46-
path="/editor/object/new"
47-
>
48-
<CreateObject
49-
allowNoParentPid={true}
50-
/>
51-
</Route>
5259
</Switch>
5360
`;

0 commit comments

Comments
 (0)