tinacms 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/api.d.ts +5 -0
- package/dist/index.es.js +97 -9
- package/dist/index.js +96 -8
- package/dist/style.css +3 -0
- package/package.json +3 -3
package/dist/admin/api.d.ts
CHANGED
|
@@ -21,6 +21,11 @@ export declare class TinaAdminApi {
|
|
|
21
21
|
constructor(cms: TinaCMS);
|
|
22
22
|
isAuthenticated(): Promise<boolean>;
|
|
23
23
|
fetchCollections(): import("@tinacms/schema-tools").TinaCloudCollection<true>[];
|
|
24
|
+
renameDocument({ collection, relativePath, newRelativePath }: {
|
|
25
|
+
collection: any;
|
|
26
|
+
relativePath: any;
|
|
27
|
+
newRelativePath: any;
|
|
28
|
+
}): Promise<void>;
|
|
24
29
|
deleteDocument({ collection, relativePath, }: {
|
|
25
30
|
collection: string;
|
|
26
31
|
relativePath: string;
|
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCMS, Form, GlobalFormPlugin, EventBus, Modal, ModalPopup, ModalHeader, ModalBody, ModalActions, Button, LoadingDots, useLocalStorage, TinaCMS, BranchSwitcherPlugin, BranchDataProvider, TinaProvider, TinaMediaStore, DummyMediaStore, Nav, LocalWarning, BillingWarning, Select, OverflowMenu, CursorPaginator, PopupModal, wrapFieldsWithMeta, FormStatus, FormBuilder } from "@tinacms/toolkit";
|
|
1
|
+
import { useCMS, Form, GlobalFormPlugin, EventBus, Modal, ModalPopup, ModalHeader, ModalBody, ModalActions, Button, LoadingDots, useLocalStorage, TinaCMS, BranchSwitcherPlugin, BranchDataProvider, TinaProvider, TinaMediaStore, DummyMediaStore, Nav, LocalWarning, BillingWarning, Select, OverflowMenu, CursorPaginator, PopupModal, BaseTextField, wrapFieldsWithMeta, FormStatus, FormBuilder } from "@tinacms/toolkit";
|
|
2
2
|
export * from "@tinacms/toolkit";
|
|
3
3
|
export { MdxFieldPluginExtendible } from "@tinacms/toolkit";
|
|
4
4
|
import * as G from "graphql";
|
|
@@ -556,7 +556,7 @@ const buildForm = (doc, cms, formify2, showInSidebar = false, onSubmit) => {
|
|
|
556
556
|
});
|
|
557
557
|
const variables = { params };
|
|
558
558
|
const mutationString = `#graphql
|
|
559
|
-
mutation UpdateDocument($collection: String!, $relativePath: String!, $params:
|
|
559
|
+
mutation UpdateDocument($collection: String!, $relativePath: String!, $params: DocumentUpdateMutation!) {
|
|
560
560
|
updateDocument(collection: $collection, relativePath: $relativePath, params: $params) {
|
|
561
561
|
__typename
|
|
562
562
|
}
|
|
@@ -2530,6 +2530,15 @@ class TinaAdminApi {
|
|
|
2530
2530
|
fetchCollections() {
|
|
2531
2531
|
return this.schema.getCollections();
|
|
2532
2532
|
}
|
|
2533
|
+
async renameDocument({ collection, relativePath, newRelativePath }) {
|
|
2534
|
+
await this.api.request(`#graphql
|
|
2535
|
+
mutation RenameDocument($collection: String!, $relativePath: String! $newRelativePath: String!) {
|
|
2536
|
+
updateDocument(collection: $collection, relativePath: $relativePath, params: {relativePath: $newRelativePath}){
|
|
2537
|
+
__typename
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
`, { variables: { collection, relativePath, newRelativePath } });
|
|
2541
|
+
}
|
|
2533
2542
|
async deleteDocument({
|
|
2534
2543
|
collection,
|
|
2535
2544
|
relativePath
|
|
@@ -2668,7 +2677,7 @@ class TinaAdminApi {
|
|
|
2668
2677
|
}
|
|
2669
2678
|
async updateDocument(collectionName, relativePath, params) {
|
|
2670
2679
|
const response = await this.api.request(`#graphql
|
|
2671
|
-
mutation($collection: String!, $relativePath: String!, $params:
|
|
2680
|
+
mutation($collection: String!, $relativePath: String!, $params: DocumentUpdateMutation!) {
|
|
2672
2681
|
updateDocument(
|
|
2673
2682
|
collection: $collection,
|
|
2674
2683
|
relativePath: $relativePath,
|
|
@@ -3240,6 +3249,9 @@ var styles = `.tina-tailwind {
|
|
|
3240
3249
|
.tina-tailwind .mt-2 {
|
|
3241
3250
|
margin-top: 8px;
|
|
3242
3251
|
}
|
|
3252
|
+
.tina-tailwind .mb-4 {
|
|
3253
|
+
margin-bottom: 16px;
|
|
3254
|
+
}
|
|
3243
3255
|
.tina-tailwind .mr-1\\.5 {
|
|
3244
3256
|
margin-right: 6px;
|
|
3245
3257
|
}
|
|
@@ -4537,6 +4549,9 @@ function BiMenu(props) {
|
|
|
4537
4549
|
function BiPlus(props) {
|
|
4538
4550
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M19 11h-6V5h-2v6H5v2h6v6h2v-6h6z" } }] })(props);
|
|
4539
4551
|
}
|
|
4552
|
+
function BiRename(props) {
|
|
4553
|
+
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M20.005 5.995h-1v2h1v8h-1v2h1c1.103 0 2-.897 2-2v-8c0-1.102-.898-2-2-2zm-14 4H15v4H6.005z" } }, { "tag": "path", "attr": { "d": "M17.005 17.995V4H20V2h-8v2h3.005v1.995h-11c-1.103 0-2 .897-2 2v8c0 1.103.897 2 2 2h11V20H12v2h8v-2h-2.995v-2.005zm-13-2v-8h11v8h-11z" } }] })(props);
|
|
4554
|
+
}
|
|
4540
4555
|
function BiTrash(props) {
|
|
4541
4556
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M5 20a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8h2V6h-4V4a2 2 0 0 0-2-2H9a2 2 0 0 0-2 2v2H3v2h2zM9 4h6v2H9zM8 8h9v12H7V8z" } }, { "tag": "path", "attr": { "d": "M9 10h2v8H9zm4 0h2v8h-2z" } }] })(props);
|
|
4542
4557
|
}
|
|
@@ -5032,10 +5047,12 @@ const handleNavigate = (navigate, cms, collection, collectionDefinition, documen
|
|
|
5032
5047
|
const CollectionListPage = () => {
|
|
5033
5048
|
const navigate = useNavigate();
|
|
5034
5049
|
const { collectionName } = useParams();
|
|
5035
|
-
const [
|
|
5050
|
+
const [deleteModalOpen, setDeleteModalOpen] = React.useState(false);
|
|
5051
|
+
const [renameModalOpen, setRenameModalOpen] = React.useState(false);
|
|
5036
5052
|
const [vars, setVars] = React.useState({
|
|
5037
5053
|
collection: collectionName,
|
|
5038
|
-
relativePath: ""
|
|
5054
|
+
relativePath: "",
|
|
5055
|
+
newRelativePath: ""
|
|
5039
5056
|
});
|
|
5040
5057
|
const [endCursor, setEndCursor] = useState("");
|
|
5041
5058
|
const [prevCursors, setPrevCursors] = useState([]);
|
|
@@ -5070,7 +5087,7 @@ const CollectionListPage = () => {
|
|
|
5070
5087
|
const collectionDefinition = cms.api.tina.schema.getCollection(collection.name);
|
|
5071
5088
|
const allowCreate = (_d = (_c = (_b = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _b.allowedActions) == null ? void 0 : _c.create) != null ? _d : true;
|
|
5072
5089
|
const allowDelete = (_g = (_f = (_e = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _e.allowedActions) == null ? void 0 : _f.delete) != null ? _g : true;
|
|
5073
|
-
return /* @__PURE__ */ React.createElement(PageWrapper, null, /* @__PURE__ */ React.createElement(React.Fragment, null,
|
|
5090
|
+
return /* @__PURE__ */ React.createElement(PageWrapper, null, /* @__PURE__ */ React.createElement(React.Fragment, null, deleteModalOpen && /* @__PURE__ */ React.createElement(DeleteModal, {
|
|
5074
5091
|
filename: vars.relativePath,
|
|
5075
5092
|
deleteFunc: async () => {
|
|
5076
5093
|
try {
|
|
@@ -5083,7 +5100,32 @@ const CollectionListPage = () => {
|
|
|
5083
5100
|
throw error;
|
|
5084
5101
|
}
|
|
5085
5102
|
},
|
|
5086
|
-
close: () =>
|
|
5103
|
+
close: () => setDeleteModalOpen(false)
|
|
5104
|
+
}), renameModalOpen && /* @__PURE__ */ React.createElement(RenameModal, {
|
|
5105
|
+
filename: vars.relativePath,
|
|
5106
|
+
newRelativePath: vars.newRelativePath,
|
|
5107
|
+
setNewRelativePath: (newRelativePath) => {
|
|
5108
|
+
setVars((vars2) => {
|
|
5109
|
+
return { ...vars2, newRelativePath };
|
|
5110
|
+
});
|
|
5111
|
+
},
|
|
5112
|
+
renameFunc: async () => {
|
|
5113
|
+
const newRelativePath = `${vars.newRelativePath}.${collection.format}`;
|
|
5114
|
+
try {
|
|
5115
|
+
await admin.renameDocument({
|
|
5116
|
+
collection: vars.collection,
|
|
5117
|
+
relativePath: vars.relativePath,
|
|
5118
|
+
newRelativePath
|
|
5119
|
+
});
|
|
5120
|
+
cms.alerts.info("Document was successfully renamed");
|
|
5121
|
+
reFetchCollection();
|
|
5122
|
+
} catch (error) {
|
|
5123
|
+
cms.alerts.warn("Document was not renamed, ask a developer for help or check the console for an error message");
|
|
5124
|
+
console.error(error);
|
|
5125
|
+
throw error;
|
|
5126
|
+
}
|
|
5127
|
+
},
|
|
5128
|
+
close: () => setRenameModalOpen(false)
|
|
5087
5129
|
}), /* @__PURE__ */ React.createElement(PageHeader, {
|
|
5088
5130
|
isLocalMode: (_i = (_h = cms == null ? void 0 : cms.api) == null ? void 0 : _h.tina) == null ? void 0 : _i.isLocalMode
|
|
5089
5131
|
}, /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
@@ -5216,9 +5258,26 @@ const CollectionListPage = () => {
|
|
|
5216
5258
|
onMouseDown: () => {
|
|
5217
5259
|
setVars({
|
|
5218
5260
|
collection: collectionName,
|
|
5219
|
-
relativePath: document.node._sys.breadcrumbs.join("/") + document.node._sys.extension
|
|
5261
|
+
relativePath: document.node._sys.breadcrumbs.join("/") + document.node._sys.extension,
|
|
5262
|
+
newRelativePath: ""
|
|
5220
5263
|
});
|
|
5221
|
-
|
|
5264
|
+
setDeleteModalOpen(true);
|
|
5265
|
+
}
|
|
5266
|
+
},
|
|
5267
|
+
allowDelete && {
|
|
5268
|
+
name: "rename",
|
|
5269
|
+
label: "Rename",
|
|
5270
|
+
Icon: /* @__PURE__ */ React.createElement(BiRename, {
|
|
5271
|
+
size: "1.3rem",
|
|
5272
|
+
className: "text-red-500"
|
|
5273
|
+
}),
|
|
5274
|
+
onMouseDown: () => {
|
|
5275
|
+
setVars({
|
|
5276
|
+
collection: collectionName,
|
|
5277
|
+
relativePath: document.node._sys.breadcrumbs.join("/") + document.node._sys.extension,
|
|
5278
|
+
newRelativePath: ""
|
|
5279
|
+
});
|
|
5280
|
+
setRenameModalOpen(true);
|
|
5222
5281
|
}
|
|
5223
5282
|
}
|
|
5224
5283
|
].filter(Boolean)
|
|
@@ -5263,6 +5322,35 @@ const DeleteModal = ({ close: close2, deleteFunc, filename }) => {
|
|
|
5263
5322
|
}
|
|
5264
5323
|
}, "Delete"))));
|
|
5265
5324
|
};
|
|
5325
|
+
const RenameModal = ({
|
|
5326
|
+
close: close2,
|
|
5327
|
+
renameFunc,
|
|
5328
|
+
filename,
|
|
5329
|
+
newRelativePath,
|
|
5330
|
+
setNewRelativePath
|
|
5331
|
+
}) => {
|
|
5332
|
+
return /* @__PURE__ */ React.createElement(Modal, null, /* @__PURE__ */ React.createElement(PopupModal, null, /* @__PURE__ */ React.createElement(ModalHeader, {
|
|
5333
|
+
close: close2
|
|
5334
|
+
}, "Rename ", filename), /* @__PURE__ */ React.createElement(ModalBody, {
|
|
5335
|
+
padded: true
|
|
5336
|
+
}, /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", {
|
|
5337
|
+
className: "mb-4"
|
|
5338
|
+
}, "Are you sure you want to rename ", /* @__PURE__ */ React.createElement("strong", null, filename), "? TinaCMS uses the filename as the ID; renaming this file could result in unresolved references."), /* @__PURE__ */ React.createElement(BaseTextField, {
|
|
5339
|
+
placeholder: "Enter a new name for the document's file",
|
|
5340
|
+
value: newRelativePath,
|
|
5341
|
+
onChange: (event) => setNewRelativePath(event.target.value)
|
|
5342
|
+
}))), /* @__PURE__ */ React.createElement(ModalActions, null, /* @__PURE__ */ React.createElement(Button, {
|
|
5343
|
+
style: { flexGrow: 2 },
|
|
5344
|
+
onClick: close2
|
|
5345
|
+
}, "Cancel"), /* @__PURE__ */ React.createElement(Button, {
|
|
5346
|
+
style: { flexGrow: 3 },
|
|
5347
|
+
variant: "primary",
|
|
5348
|
+
onClick: async () => {
|
|
5349
|
+
await renameFunc();
|
|
5350
|
+
close2();
|
|
5351
|
+
}
|
|
5352
|
+
}, "Rename"))));
|
|
5353
|
+
};
|
|
5266
5354
|
function HiChevronRight(props) {
|
|
5267
5355
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 20 20", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "d": "M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z", "clipRule": "evenodd" } }] })(props);
|
|
5268
5356
|
}
|
package/dist/index.js
CHANGED
|
@@ -572,7 +572,7 @@
|
|
|
572
572
|
});
|
|
573
573
|
const variables = { params };
|
|
574
574
|
const mutationString = `#graphql
|
|
575
|
-
mutation UpdateDocument($collection: String!, $relativePath: String!, $params:
|
|
575
|
+
mutation UpdateDocument($collection: String!, $relativePath: String!, $params: DocumentUpdateMutation!) {
|
|
576
576
|
updateDocument(collection: $collection, relativePath: $relativePath, params: $params) {
|
|
577
577
|
__typename
|
|
578
578
|
}
|
|
@@ -2546,6 +2546,15 @@ mutation addPendingDocumentMutation(
|
|
|
2546
2546
|
fetchCollections() {
|
|
2547
2547
|
return this.schema.getCollections();
|
|
2548
2548
|
}
|
|
2549
|
+
async renameDocument({ collection, relativePath, newRelativePath }) {
|
|
2550
|
+
await this.api.request(`#graphql
|
|
2551
|
+
mutation RenameDocument($collection: String!, $relativePath: String! $newRelativePath: String!) {
|
|
2552
|
+
updateDocument(collection: $collection, relativePath: $relativePath, params: {relativePath: $newRelativePath}){
|
|
2553
|
+
__typename
|
|
2554
|
+
}
|
|
2555
|
+
}
|
|
2556
|
+
`, { variables: { collection, relativePath, newRelativePath } });
|
|
2557
|
+
}
|
|
2549
2558
|
async deleteDocument({
|
|
2550
2559
|
collection,
|
|
2551
2560
|
relativePath
|
|
@@ -2684,7 +2693,7 @@ mutation addPendingDocumentMutation(
|
|
|
2684
2693
|
}
|
|
2685
2694
|
async updateDocument(collectionName, relativePath, params) {
|
|
2686
2695
|
const response = await this.api.request(`#graphql
|
|
2687
|
-
mutation($collection: String!, $relativePath: String!, $params:
|
|
2696
|
+
mutation($collection: String!, $relativePath: String!, $params: DocumentUpdateMutation!) {
|
|
2688
2697
|
updateDocument(
|
|
2689
2698
|
collection: $collection,
|
|
2690
2699
|
relativePath: $relativePath,
|
|
@@ -3256,6 +3265,9 @@ mutation addPendingDocumentMutation(
|
|
|
3256
3265
|
.tina-tailwind .mt-2 {
|
|
3257
3266
|
margin-top: 8px;
|
|
3258
3267
|
}
|
|
3268
|
+
.tina-tailwind .mb-4 {
|
|
3269
|
+
margin-bottom: 16px;
|
|
3270
|
+
}
|
|
3259
3271
|
.tina-tailwind .mr-1\\.5 {
|
|
3260
3272
|
margin-right: 6px;
|
|
3261
3273
|
}
|
|
@@ -4553,6 +4565,9 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
4553
4565
|
function BiPlus(props) {
|
|
4554
4566
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M19 11h-6V5h-2v6H5v2h6v6h2v-6h6z" } }] })(props);
|
|
4555
4567
|
}
|
|
4568
|
+
function BiRename(props) {
|
|
4569
|
+
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M20.005 5.995h-1v2h1v8h-1v2h1c1.103 0 2-.897 2-2v-8c0-1.102-.898-2-2-2zm-14 4H15v4H6.005z" } }, { "tag": "path", "attr": { "d": "M17.005 17.995V4H20V2h-8v2h3.005v1.995h-11c-1.103 0-2 .897-2 2v8c0 1.103.897 2 2 2h11V20H12v2h8v-2h-2.995v-2.005zm-13-2v-8h11v8h-11z" } }] })(props);
|
|
4570
|
+
}
|
|
4556
4571
|
function BiTrash(props) {
|
|
4557
4572
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M5 20a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8h2V6h-4V4a2 2 0 0 0-2-2H9a2 2 0 0 0-2 2v2H3v2h2zM9 4h6v2H9zM8 8h9v12H7V8z" } }, { "tag": "path", "attr": { "d": "M9 10h2v8H9zm4 0h2v8h-2z" } }] })(props);
|
|
4558
4573
|
}
|
|
@@ -5048,10 +5063,12 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
5048
5063
|
const CollectionListPage = () => {
|
|
5049
5064
|
const navigate = reactRouterDom.useNavigate();
|
|
5050
5065
|
const { collectionName } = reactRouterDom.useParams();
|
|
5051
|
-
const [
|
|
5066
|
+
const [deleteModalOpen, setDeleteModalOpen] = React__default["default"].useState(false);
|
|
5067
|
+
const [renameModalOpen, setRenameModalOpen] = React__default["default"].useState(false);
|
|
5052
5068
|
const [vars, setVars] = React__default["default"].useState({
|
|
5053
5069
|
collection: collectionName,
|
|
5054
|
-
relativePath: ""
|
|
5070
|
+
relativePath: "",
|
|
5071
|
+
newRelativePath: ""
|
|
5055
5072
|
});
|
|
5056
5073
|
const [endCursor, setEndCursor] = React.useState("");
|
|
5057
5074
|
const [prevCursors, setPrevCursors] = React.useState([]);
|
|
@@ -5086,7 +5103,7 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
5086
5103
|
const collectionDefinition = cms.api.tina.schema.getCollection(collection.name);
|
|
5087
5104
|
const allowCreate = (_d = (_c = (_b = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _b.allowedActions) == null ? void 0 : _c.create) != null ? _d : true;
|
|
5088
5105
|
const allowDelete = (_g = (_f = (_e = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _e.allowedActions) == null ? void 0 : _f.delete) != null ? _g : true;
|
|
5089
|
-
return /* @__PURE__ */ React__default["default"].createElement(PageWrapper, null, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
5106
|
+
return /* @__PURE__ */ React__default["default"].createElement(PageWrapper, null, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, deleteModalOpen && /* @__PURE__ */ React__default["default"].createElement(DeleteModal, {
|
|
5090
5107
|
filename: vars.relativePath,
|
|
5091
5108
|
deleteFunc: async () => {
|
|
5092
5109
|
try {
|
|
@@ -5099,7 +5116,32 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
5099
5116
|
throw error;
|
|
5100
5117
|
}
|
|
5101
5118
|
},
|
|
5102
|
-
close: () =>
|
|
5119
|
+
close: () => setDeleteModalOpen(false)
|
|
5120
|
+
}), renameModalOpen && /* @__PURE__ */ React__default["default"].createElement(RenameModal, {
|
|
5121
|
+
filename: vars.relativePath,
|
|
5122
|
+
newRelativePath: vars.newRelativePath,
|
|
5123
|
+
setNewRelativePath: (newRelativePath) => {
|
|
5124
|
+
setVars((vars2) => {
|
|
5125
|
+
return { ...vars2, newRelativePath };
|
|
5126
|
+
});
|
|
5127
|
+
},
|
|
5128
|
+
renameFunc: async () => {
|
|
5129
|
+
const newRelativePath = `${vars.newRelativePath}.${collection.format}`;
|
|
5130
|
+
try {
|
|
5131
|
+
await admin.renameDocument({
|
|
5132
|
+
collection: vars.collection,
|
|
5133
|
+
relativePath: vars.relativePath,
|
|
5134
|
+
newRelativePath
|
|
5135
|
+
});
|
|
5136
|
+
cms.alerts.info("Document was successfully renamed");
|
|
5137
|
+
reFetchCollection();
|
|
5138
|
+
} catch (error) {
|
|
5139
|
+
cms.alerts.warn("Document was not renamed, ask a developer for help or check the console for an error message");
|
|
5140
|
+
console.error(error);
|
|
5141
|
+
throw error;
|
|
5142
|
+
}
|
|
5143
|
+
},
|
|
5144
|
+
close: () => setRenameModalOpen(false)
|
|
5103
5145
|
}), /* @__PURE__ */ React__default["default"].createElement(PageHeader, {
|
|
5104
5146
|
isLocalMode: (_i = (_h = cms == null ? void 0 : cms.api) == null ? void 0 : _h.tina) == null ? void 0 : _i.isLocalMode
|
|
5105
5147
|
}, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
@@ -5232,9 +5274,26 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
5232
5274
|
onMouseDown: () => {
|
|
5233
5275
|
setVars({
|
|
5234
5276
|
collection: collectionName,
|
|
5235
|
-
relativePath: document.node._sys.breadcrumbs.join("/") + document.node._sys.extension
|
|
5277
|
+
relativePath: document.node._sys.breadcrumbs.join("/") + document.node._sys.extension,
|
|
5278
|
+
newRelativePath: ""
|
|
5236
5279
|
});
|
|
5237
|
-
|
|
5280
|
+
setDeleteModalOpen(true);
|
|
5281
|
+
}
|
|
5282
|
+
},
|
|
5283
|
+
allowDelete && {
|
|
5284
|
+
name: "rename",
|
|
5285
|
+
label: "Rename",
|
|
5286
|
+
Icon: /* @__PURE__ */ React__default["default"].createElement(BiRename, {
|
|
5287
|
+
size: "1.3rem",
|
|
5288
|
+
className: "text-red-500"
|
|
5289
|
+
}),
|
|
5290
|
+
onMouseDown: () => {
|
|
5291
|
+
setVars({
|
|
5292
|
+
collection: collectionName,
|
|
5293
|
+
relativePath: document.node._sys.breadcrumbs.join("/") + document.node._sys.extension,
|
|
5294
|
+
newRelativePath: ""
|
|
5295
|
+
});
|
|
5296
|
+
setRenameModalOpen(true);
|
|
5238
5297
|
}
|
|
5239
5298
|
}
|
|
5240
5299
|
].filter(Boolean)
|
|
@@ -5279,6 +5338,35 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
5279
5338
|
}
|
|
5280
5339
|
}, "Delete"))));
|
|
5281
5340
|
};
|
|
5341
|
+
const RenameModal = ({
|
|
5342
|
+
close: close2,
|
|
5343
|
+
renameFunc,
|
|
5344
|
+
filename,
|
|
5345
|
+
newRelativePath,
|
|
5346
|
+
setNewRelativePath
|
|
5347
|
+
}) => {
|
|
5348
|
+
return /* @__PURE__ */ React__default["default"].createElement(toolkit.Modal, null, /* @__PURE__ */ React__default["default"].createElement(toolkit.PopupModal, null, /* @__PURE__ */ React__default["default"].createElement(toolkit.ModalHeader, {
|
|
5349
|
+
close: close2
|
|
5350
|
+
}, "Rename ", filename), /* @__PURE__ */ React__default["default"].createElement(toolkit.ModalBody, {
|
|
5351
|
+
padded: true
|
|
5352
|
+
}, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("p", {
|
|
5353
|
+
className: "mb-4"
|
|
5354
|
+
}, "Are you sure you want to rename ", /* @__PURE__ */ React__default["default"].createElement("strong", null, filename), "? TinaCMS uses the filename as the ID; renaming this file could result in unresolved references."), /* @__PURE__ */ React__default["default"].createElement(toolkit.BaseTextField, {
|
|
5355
|
+
placeholder: "Enter a new name for the document's file",
|
|
5356
|
+
value: newRelativePath,
|
|
5357
|
+
onChange: (event) => setNewRelativePath(event.target.value)
|
|
5358
|
+
}))), /* @__PURE__ */ React__default["default"].createElement(toolkit.ModalActions, null, /* @__PURE__ */ React__default["default"].createElement(toolkit.Button, {
|
|
5359
|
+
style: { flexGrow: 2 },
|
|
5360
|
+
onClick: close2
|
|
5361
|
+
}, "Cancel"), /* @__PURE__ */ React__default["default"].createElement(toolkit.Button, {
|
|
5362
|
+
style: { flexGrow: 3 },
|
|
5363
|
+
variant: "primary",
|
|
5364
|
+
onClick: async () => {
|
|
5365
|
+
await renameFunc();
|
|
5366
|
+
close2();
|
|
5367
|
+
}
|
|
5368
|
+
}, "Rename"))));
|
|
5369
|
+
};
|
|
5282
5370
|
function HiChevronRight(props) {
|
|
5283
5371
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 20 20", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "d": "M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z", "clipRule": "evenodd" } }] })(props);
|
|
5284
5372
|
}
|
package/dist/style.css
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinacms",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "./dist/index.es.js",
|
|
6
6
|
"exports": {
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"@headlessui/react": "^1.5.0",
|
|
56
56
|
"@heroicons/react": "^1.0.4",
|
|
57
57
|
"@react-hook/window-size": "^3.0.7",
|
|
58
|
-
"@tinacms/schema-tools": "1.2.
|
|
58
|
+
"@tinacms/schema-tools": "1.2.1",
|
|
59
59
|
"@tinacms/sharedctx": "1.0.0",
|
|
60
|
-
"@tinacms/toolkit": "1.
|
|
60
|
+
"@tinacms/toolkit": "1.3.0",
|
|
61
61
|
"crypto-js": "^4.0.0",
|
|
62
62
|
"encoding": "0.1.13",
|
|
63
63
|
"fetch-ponyfill": "^7.1.0",
|