@digi-frontend/dgate-api-documentation 1.0.21 → 1.0.26
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/src/components/InfoForm/InfoForm.js +1 -1
- package/dist/src/components/InfoForm/InfoForm.js.map +1 -1
- package/dist/src/components/JsonInput/JsonInput.js +1 -1
- package/dist/src/components/JsonInput/JsonInput.js.map +1 -1
- package/dist/src/components/LivePreview/LivePreview.js +1 -1
- package/dist/src/components/LivePreview/LivePreview.js.map +1 -1
- package/dist/src/components/MethodAccordion/MethodAccordion.js +1 -1
- package/dist/src/components/MethodAccordion/MethodAccordion.js.map +1 -1
- package/dist/src/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/src/components/table/table.js +1 -1
- package/dist/src/components/table/table.js.map +1 -1
- package/dist/src/components/table/tags-table.js +1 -1
- package/dist/src/components/table/tags-table.js.map +1 -1
- package/dist/src/constants/regex.js +1 -1
- package/dist/src/constants/regex.js.map +1 -1
- package/dist/src/helpers/layout.helper.js +1 -1
- package/dist/src/helpers/layout.helper.js.map +1 -1
- package/dist/src/layout/layout.js +1 -1
- package/dist/src/layout/layout.js.map +1 -1
- package/dist/src/layout/layout.module.css.js +1 -1
- package/dist/src/validator/form.scheme.js +1 -1
- package/dist/src/validator/form.scheme.js.map +1 -1
- package/dist/styles.css +344 -311
- package/dist/types/components/MethodAccordion/MethodAccordion.d.ts +3 -1
- package/dist/types/components/Tooltip/Tooltip.d.ts +2 -2
- package/dist/types/constants/regex.d.ts +2 -0
- package/dist/types/validator/form.scheme.d.ts +1 -1
- package/package.json +2 -2
- package/src/components/InfoForm/InfoForm.module.scss +24 -1
- package/src/components/InfoForm/InfoForm.tsx +89 -47
- package/src/components/JsonInput/JsonInput.tsx +18 -7
- package/src/components/LivePreview/LivePreview.module.scss +18 -5
- package/src/components/LivePreview/LivePreview.tsx +47 -25
- package/src/components/MethodAccordion/MethodAccordion.tsx +103 -67
- package/src/components/Tooltip/Tooltip.scss +12 -9
- package/src/components/Tooltip/Tooltip.tsx +2 -3
- package/src/components/table/style.scss +1 -1
- package/src/components/table/table.tsx +11 -8
- package/src/components/table/tags-table.tsx +49 -14
- package/src/constants/regex.ts +2 -0
- package/src/helpers/layout.helper.ts +1 -1
- package/src/layout/layout.module.css +5 -0
- package/src/layout/layout.tsx +45 -7
- package/src/validator/form.scheme.ts +9 -9
package/src/layout/layout.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JSX, useEffect } from 'react'
|
|
1
|
+
import { JSX, useEffect, useState } from 'react'
|
|
2
2
|
import { Alert, Button } from 'digitinary-ui'
|
|
3
3
|
import MethodsAccordion from '../components/MethodAccordion/MethodAccordion'
|
|
4
4
|
import styles from './layout.module.css'
|
|
@@ -11,6 +11,7 @@ import { FormikProvider, useFormik } from 'formik'
|
|
|
11
11
|
import { schemaValidation } from '../validator/form.scheme'
|
|
12
12
|
import { TransformedOpenApi } from '@entities/transformedOpenApi'
|
|
13
13
|
import { methodColorMapping } from '../constants/index'
|
|
14
|
+
import CommonDialog from '../components/dialog'
|
|
14
15
|
|
|
15
16
|
interface ILayoutProps {
|
|
16
17
|
openApiJson?: OpenAPIFile
|
|
@@ -36,6 +37,8 @@ const Layout = ({ openApiJson, handleSave, setIsFormDirty }: ILayoutProps): JSX.
|
|
|
36
37
|
validateForm(values)
|
|
37
38
|
},
|
|
38
39
|
})
|
|
40
|
+
const [isPublishDialogOpen, setIsPublishDialogOpen] = useState(false)
|
|
41
|
+
const [openMethodIndex, setOpenMethodIndex] = useState<number | null>(null)
|
|
39
42
|
|
|
40
43
|
useEffect(() => {
|
|
41
44
|
if (setIsFormDirty) {
|
|
@@ -45,10 +48,11 @@ const Layout = ({ openApiJson, handleSave, setIsFormDirty }: ILayoutProps): JSX.
|
|
|
45
48
|
|
|
46
49
|
return (
|
|
47
50
|
<div className={styles.docsLayout}>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
{formik.dirty && (
|
|
52
|
+
<Alert className={styles.apiDocAlert} color="warning" severity="warning">
|
|
53
|
+
There are changes you made may not be saved
|
|
54
|
+
</Alert>
|
|
55
|
+
)}
|
|
52
56
|
<div className={styles.layoutContainer}>
|
|
53
57
|
<div className={`${styles.editorSide} ${styles.docSide}`}>
|
|
54
58
|
<SectionHead
|
|
@@ -63,7 +67,8 @@ const Layout = ({ openApiJson, handleSave, setIsFormDirty }: ILayoutProps): JSX.
|
|
|
63
67
|
type="submit"
|
|
64
68
|
variant="contained"
|
|
65
69
|
color="primary"
|
|
66
|
-
onClick={
|
|
70
|
+
onClick={() => setIsPublishDialogOpen(true)}
|
|
71
|
+
disabled={!formik.isValid || formik.isSubmitting}
|
|
67
72
|
>
|
|
68
73
|
Save
|
|
69
74
|
</Button>
|
|
@@ -73,7 +78,7 @@ const Layout = ({ openApiJson, handleSave, setIsFormDirty }: ILayoutProps): JSX.
|
|
|
73
78
|
<FormikProvider value={formik}>
|
|
74
79
|
<InfoForm />
|
|
75
80
|
</FormikProvider>
|
|
76
|
-
<SectionHead className={styles.editorSectionHead} text="
|
|
81
|
+
<SectionHead className={styles.editorSectionHead} text="Endpoints" />
|
|
77
82
|
<FormikProvider value={formik}>
|
|
78
83
|
{formik.values.paths.map((path, pathIndex) => (
|
|
79
84
|
<>
|
|
@@ -90,6 +95,8 @@ const Layout = ({ openApiJson, handleSave, setIsFormDirty }: ILayoutProps): JSX.
|
|
|
90
95
|
const h = `paths[${pathIndex}].methods[${methodIndex}].${key}`
|
|
91
96
|
formik.setFieldValue(h, value)
|
|
92
97
|
}}
|
|
98
|
+
isOpen={openMethodIndex === methodIndex}
|
|
99
|
+
setIsOpen={(open) => setOpenMethodIndex(open ? methodIndex : null)}
|
|
93
100
|
/>
|
|
94
101
|
))}
|
|
95
102
|
</>
|
|
@@ -104,6 +111,37 @@ const Layout = ({ openApiJson, handleSave, setIsFormDirty }: ILayoutProps): JSX.
|
|
|
104
111
|
)}
|
|
105
112
|
</div>
|
|
106
113
|
</div>
|
|
114
|
+
<CommonDialog
|
|
115
|
+
status="warning"
|
|
116
|
+
content={
|
|
117
|
+
<p
|
|
118
|
+
style={{
|
|
119
|
+
textAlign: 'center',
|
|
120
|
+
fontWeight: 400,
|
|
121
|
+
fontSize: '1rem',
|
|
122
|
+
lineHeight: '1.4375rem',
|
|
123
|
+
}}
|
|
124
|
+
>
|
|
125
|
+
Are you sure you want to Publish your changes?
|
|
126
|
+
</p>
|
|
127
|
+
}
|
|
128
|
+
onSubmit={{
|
|
129
|
+
onClick: () => {
|
|
130
|
+
formik.handleSubmit()
|
|
131
|
+
setIsPublishDialogOpen(false)
|
|
132
|
+
},
|
|
133
|
+
text: 'Publish',
|
|
134
|
+
color: 'warning',
|
|
135
|
+
fullWidth: true,
|
|
136
|
+
}}
|
|
137
|
+
onCancel={{
|
|
138
|
+
text: 'Cancel',
|
|
139
|
+
color: 'normal',
|
|
140
|
+
fullWidth: true,
|
|
141
|
+
}}
|
|
142
|
+
onClose={() => setIsPublishDialogOpen(false)}
|
|
143
|
+
open={isPublishDialogOpen}
|
|
144
|
+
/>
|
|
107
145
|
</div>
|
|
108
146
|
)
|
|
109
147
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as yup from
|
|
1
|
+
import * as yup from 'yup'
|
|
2
2
|
export const schemaValidation = yup.object({
|
|
3
3
|
openapi: yup.string().required(),
|
|
4
4
|
info: yup
|
|
5
5
|
.object({
|
|
6
|
-
title: yup.string().required(
|
|
7
|
-
description: yup.string().
|
|
8
|
-
version: yup.string().required(
|
|
6
|
+
title: yup.string().trim().required('API Name is required.'),
|
|
7
|
+
description: yup.string().trim().required(),
|
|
8
|
+
version: yup.string().required('API Version is required'),
|
|
9
9
|
})
|
|
10
10
|
.required(),
|
|
11
11
|
servers: yup
|
|
@@ -32,8 +32,8 @@ export const schemaValidation = yup.object({
|
|
|
32
32
|
yup.object(
|
|
33
33
|
props
|
|
34
34
|
? Object.keys(props).reduce((acc, propKey) => {
|
|
35
|
-
acc[propKey] = yup.mixed()
|
|
36
|
-
return acc
|
|
35
|
+
acc[propKey] = yup.mixed()
|
|
36
|
+
return acc
|
|
37
37
|
}, {})
|
|
38
38
|
: {}
|
|
39
39
|
)
|
|
@@ -42,8 +42,8 @@ export const schemaValidation = yup.object({
|
|
|
42
42
|
items: yup.mixed().optional(),
|
|
43
43
|
enum: yup.array(yup.string()).optional(),
|
|
44
44
|
required: yup.array(yup.string()).optional(),
|
|
45
|
-
})
|
|
46
|
-
return acc
|
|
45
|
+
})
|
|
46
|
+
return acc
|
|
47
47
|
}, {})
|
|
48
48
|
: {}
|
|
49
49
|
)
|
|
@@ -67,4 +67,4 @@ export const schemaValidation = yup.object({
|
|
|
67
67
|
})
|
|
68
68
|
)
|
|
69
69
|
.optional(),
|
|
70
|
-
})
|
|
70
|
+
})
|