@tinacms/app 0.0.0-20230821165821 → 0.0.0-20230821174732
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/CHANGELOG.md +2 -17
- package/package.json +4 -4
- package/src/App.tsx +2 -4
- package/src/lib/graphql-reducer.ts +5 -36
- package/src/lib/errors.tsx +0 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,25 +1,10 @@
|
|
|
1
1
|
# @tinacms/app
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-20230821174732
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
- 1144af060: Improve error messaging when onPut / onDelete hooks throw errors
|
|
9
|
-
- Updated dependencies [7e4de0b2a]
|
|
10
|
-
- Updated dependencies [1144af060]
|
|
11
|
-
- tinacms@0.0.0-20230821165821
|
|
12
|
-
- @tinacms/mdx@0.0.0-20230821165821
|
|
13
|
-
|
|
14
|
-
## 1.2.26
|
|
15
|
-
|
|
16
|
-
### Patch Changes
|
|
17
|
-
|
|
18
|
-
- Updated dependencies [1563ce5b2]
|
|
19
|
-
- Updated dependencies [0e94b2725]
|
|
20
|
-
- Updated dependencies [e83ba8855]
|
|
21
|
-
- tinacms@1.5.19
|
|
22
|
-
- @tinacms/mdx@1.3.17
|
|
7
|
+
- tinacms@0.0.0-20230821174732
|
|
23
8
|
|
|
24
9
|
## 1.2.25
|
|
25
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/app",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-20230821174732",
|
|
4
4
|
"main": "src/main.tsx",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"devDependencies": {
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
"@headlessui/react": "1.6.6",
|
|
15
15
|
"@heroicons/react": "1.0.6",
|
|
16
16
|
"@monaco-editor/react": "4.4.5",
|
|
17
|
-
"@tinacms/mdx": "0.0.0-20230821165821",
|
|
18
17
|
"@xstate/react": "3.0.0",
|
|
19
18
|
"final-form": "4.20.7",
|
|
20
19
|
"graphiql": "3.0.0-alpha.1",
|
|
@@ -25,8 +24,9 @@
|
|
|
25
24
|
"react-dom": "17.0.2",
|
|
26
25
|
"react-router-dom": "6.3.0",
|
|
27
26
|
"tailwindcss": "^3.2.7",
|
|
28
|
-
"tinacms": "0.0.0-20230821165821",
|
|
29
27
|
"typescript": "^4.6.4",
|
|
30
|
-
"zod": "^3.14.3"
|
|
28
|
+
"zod": "^3.14.3",
|
|
29
|
+
"@tinacms/mdx": "1.3.16",
|
|
30
|
+
"tinacms": "0.0.0-20230821174732"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/src/App.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { Suspense
|
|
1
|
+
import React, { Suspense } from 'react'
|
|
2
2
|
import TinaCMS, { TinaAdmin, useCMS, MdxFieldPluginExtendible } from 'tinacms'
|
|
3
3
|
import { TinaEditProvider, useEditState } from 'tinacms/dist/edit-state'
|
|
4
4
|
import { Preview } from './preview'
|
|
@@ -78,9 +78,7 @@ export const TinaAdminWrapper = () => {
|
|
|
78
78
|
|
|
79
79
|
const GoToEdit = () => {
|
|
80
80
|
const { setEdit } = useEditState()
|
|
81
|
-
|
|
82
|
-
setEdit(true)
|
|
83
|
-
}, [])
|
|
81
|
+
setEdit(true)
|
|
84
82
|
return <div>Going into edit mode</div>
|
|
85
83
|
}
|
|
86
84
|
|
|
@@ -19,7 +19,6 @@ import {
|
|
|
19
19
|
FormOptions,
|
|
20
20
|
GlobalFormPlugin,
|
|
21
21
|
TinaState,
|
|
22
|
-
ErrorDialog,
|
|
23
22
|
} from 'tinacms'
|
|
24
23
|
import { createForm, createGlobalForm, FormifyCallback } from './build-form'
|
|
25
24
|
import type {
|
|
@@ -30,7 +29,6 @@ import type {
|
|
|
30
29
|
} from './types'
|
|
31
30
|
import { getFormAndFieldNameFromMetadata } from './util'
|
|
32
31
|
import { useSearchParams } from 'react-router-dom'
|
|
33
|
-
import { showErrorModal } from './errors'
|
|
34
32
|
|
|
35
33
|
const sysSchema = z.object({
|
|
36
34
|
breadcrumbs: z.array(z.string()),
|
|
@@ -154,14 +152,6 @@ const astNodeWithMeta: G.DocumentNode = {
|
|
|
154
152
|
const schema = G.buildASTSchema(astNode)
|
|
155
153
|
const schemaForResolver = G.buildASTSchema(astNodeWithMeta)
|
|
156
154
|
|
|
157
|
-
const isRejected = (
|
|
158
|
-
input: PromiseSettledResult<unknown>
|
|
159
|
-
): input is PromiseRejectedResult => input.status === 'rejected'
|
|
160
|
-
|
|
161
|
-
const isFulfilled = <T>(
|
|
162
|
-
input: PromiseSettledResult<T>
|
|
163
|
-
): input is PromiseFulfilledResult<T> => input.status === 'fulfilled'
|
|
164
|
-
|
|
165
155
|
export const useGraphQLReducer = (
|
|
166
156
|
iframe: React.MutableRefObject<HTMLIFrameElement>,
|
|
167
157
|
url: string
|
|
@@ -169,7 +159,6 @@ export const useGraphQLReducer = (
|
|
|
169
159
|
const cms = useCMS()
|
|
170
160
|
const tinaSchema = cms.api.tina.schema as TinaSchema
|
|
171
161
|
const [payloads, setPayloads] = React.useState<Payload[]>([])
|
|
172
|
-
const [requestErrors, setRequestErrors] = React.useState<string[]>([])
|
|
173
162
|
const [searchParams, setSearchParams] = useSearchParams()
|
|
174
163
|
const [results, setResults] = React.useState<
|
|
175
164
|
{
|
|
@@ -215,9 +204,7 @@ export const useGraphQLReducer = (
|
|
|
215
204
|
*/
|
|
216
205
|
React.useEffect(() => {
|
|
217
206
|
const run = async () => {
|
|
218
|
-
|
|
219
|
-
// gather the errors and display an error message containing each error unique message
|
|
220
|
-
return Promise.allSettled(
|
|
207
|
+
return Promise.all(
|
|
221
208
|
payloads.map(async (payload) => {
|
|
222
209
|
// This payload has already been expanded, skip it.
|
|
223
210
|
if (payload.expandedQuery) {
|
|
@@ -232,10 +219,7 @@ export const useGraphQLReducer = (
|
|
|
232
219
|
}
|
|
233
220
|
if (payloads.length) {
|
|
234
221
|
run().then((updatedPayloads) => {
|
|
235
|
-
setPayloads(updatedPayloads
|
|
236
|
-
setRequestErrors(
|
|
237
|
-
updatedPayloads.filter(isRejected).map((p) => String(p.reason))
|
|
238
|
-
)
|
|
222
|
+
setPayloads(updatedPayloads)
|
|
239
223
|
})
|
|
240
224
|
}
|
|
241
225
|
}, [JSON.stringify(payloads), cms])
|
|
@@ -591,12 +575,6 @@ export const useGraphQLReducer = (
|
|
|
591
575
|
cms.dispatch({ type: 'set-edit-mode', value: 'basic' })
|
|
592
576
|
}
|
|
593
577
|
}, [iframe.current, JSON.stringify(results)])
|
|
594
|
-
|
|
595
|
-
React.useEffect(() => {
|
|
596
|
-
if (requestErrors.length) {
|
|
597
|
-
showErrorModal('Unexpected error querying content', requestErrors, cms)
|
|
598
|
-
}
|
|
599
|
-
}, [requestErrors])
|
|
600
578
|
}
|
|
601
579
|
|
|
602
580
|
const onSubmit = async (
|
|
@@ -624,13 +602,7 @@ const onSubmit = async (
|
|
|
624
602
|
})
|
|
625
603
|
cms.alerts.success('Document saved!')
|
|
626
604
|
} catch (e) {
|
|
627
|
-
cms.alerts.error(
|
|
628
|
-
ErrorDialog({
|
|
629
|
-
title: 'There was a problem saving your document',
|
|
630
|
-
message: 'Tina caught an error while updating the page',
|
|
631
|
-
error: e,
|
|
632
|
-
})
|
|
633
|
-
)
|
|
605
|
+
cms.alerts.error('There was a problem saving your document')
|
|
634
606
|
console.error(e)
|
|
635
607
|
}
|
|
636
608
|
}
|
|
@@ -862,15 +834,12 @@ _internalSys: _sys {
|
|
|
862
834
|
return response.node
|
|
863
835
|
}
|
|
864
836
|
|
|
865
|
-
const expandPayload = async (
|
|
866
|
-
payload: Payload,
|
|
867
|
-
cms: TinaCMS
|
|
868
|
-
): Promise<Payload> => {
|
|
837
|
+
const expandPayload = async (payload: Payload, cms: TinaCMS) => {
|
|
869
838
|
const { query, variables } = payload
|
|
870
839
|
const documentNode = G.parse(query)
|
|
871
840
|
const expandedDocumentNode = expandQuery({ schema, documentNode })
|
|
872
841
|
const expandedQuery = G.print(expandedDocumentNode)
|
|
873
|
-
const expandedData = await cms.api.tina.request
|
|
842
|
+
const expandedData = await cms.api.tina.request(expandedQuery, {
|
|
874
843
|
variables,
|
|
875
844
|
})
|
|
876
845
|
|
package/src/lib/errors.tsx
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { TinaCMS } from 'tinacms'
|
|
3
|
-
|
|
4
|
-
const ErrorModalContent = (props: { title: string; errors: string[] }) => {
|
|
5
|
-
const { title, errors } = props
|
|
6
|
-
return (
|
|
7
|
-
<>
|
|
8
|
-
<div>{title}</div>
|
|
9
|
-
<ul>
|
|
10
|
-
{errors.map((error, i) => (
|
|
11
|
-
<li key={i}>{error}</li>
|
|
12
|
-
))}
|
|
13
|
-
</ul>
|
|
14
|
-
</>
|
|
15
|
-
)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const showErrorModal = (
|
|
19
|
-
title: string,
|
|
20
|
-
errors: string[],
|
|
21
|
-
cms: TinaCMS
|
|
22
|
-
) => {
|
|
23
|
-
cms.alerts.error(() => <ErrorModalContent title={title} errors={errors} />)
|
|
24
|
-
}
|