@digi-frontend/dgate-api-documentation 1.0.10 → 1.0.11
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/_virtual/index3.js +1 -1
- package/dist/_virtual/index4.js +1 -1
- package/dist/_virtual/index5.js +1 -1
- package/dist/_virtual/index6.js +1 -1
- package/dist/node_modules/toposort/index.js +1 -1
- package/dist/node_modules/yup/index.esm.js +1 -1
- package/dist/src/components/InfoForm/InfoForm.js +1 -1
- package/dist/src/components/InfoForm/InfoForm.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/table/tags-table.js +1 -1
- package/dist/src/components/table/tags-table.js.map +1 -1
- package/dist/styles.css +531 -646
- package/package.json +1 -1
- package/src/components/InfoForm/InfoForm.tsx +12 -7
- package/src/components/LivePreview/LivePreview.tsx +132 -17
- package/src/components/table/tags-table.tsx +1 -0
package/package.json
CHANGED
|
@@ -16,6 +16,8 @@ const InfoForm = ({ readOnly }: { readOnly?: boolean }) => {
|
|
|
16
16
|
const [tableData, setTableData] = useState([])
|
|
17
17
|
const [tableRecords, setTableRecords] = useState()
|
|
18
18
|
const [authType, setAuthType] = useState('')
|
|
19
|
+
const [description, setDescription] = useState('')
|
|
20
|
+
const [url, setURL] = useState('')
|
|
19
21
|
const { values, setFieldValue, errors } = useFormikContext<TransformedOpenApi>()
|
|
20
22
|
const [externalTooltipRefs, setExternalTooltipRefs] = useState<{ [key: number]: any }>({})
|
|
21
23
|
const [tooltipRefs, setTooltipRefs] = useState<{ [key: number]: any }>({})
|
|
@@ -163,22 +165,24 @@ const InfoForm = ({ readOnly }: { readOnly?: boolean }) => {
|
|
|
163
165
|
placeholder="Describe External Doc..."
|
|
164
166
|
value={item.externalDocs?.description}
|
|
165
167
|
disabled={readOnly}
|
|
166
|
-
onChange={(value) =>
|
|
168
|
+
onChange={(value) => {
|
|
167
169
|
onTableChange(
|
|
168
170
|
'externalDocs',
|
|
169
171
|
{ ...item.externalDocs, description: value },
|
|
170
172
|
index
|
|
171
173
|
)
|
|
172
|
-
|
|
174
|
+
setDescription(value)
|
|
175
|
+
}}
|
|
173
176
|
/>
|
|
174
177
|
<p className={styles.editDescTooltipContent_header}>External Docs Link</p>
|
|
175
178
|
<TextArea
|
|
176
179
|
placeholder="External Docs Link..."
|
|
177
180
|
value={item.externalDocs?.url}
|
|
178
181
|
disabled={readOnly}
|
|
179
|
-
onChange={(value) =>
|
|
182
|
+
onChange={(value) => {
|
|
180
183
|
onTableChange('externalDocs', { ...item.externalDocs, url: value }, index)
|
|
181
|
-
|
|
184
|
+
setURL(value)
|
|
185
|
+
}}
|
|
182
186
|
/>
|
|
183
187
|
{!readOnly && (
|
|
184
188
|
<Button
|
|
@@ -187,10 +191,11 @@ const InfoForm = ({ readOnly }: { readOnly?: boolean }) => {
|
|
|
187
191
|
size="small"
|
|
188
192
|
onClick={() => {
|
|
189
193
|
setFieldValue(`tags[${index}].externalDocs`, {
|
|
190
|
-
description:
|
|
191
|
-
url:
|
|
194
|
+
description: description,
|
|
195
|
+
url: url,
|
|
192
196
|
})
|
|
193
|
-
|
|
197
|
+
setDescription('')
|
|
198
|
+
setURL('')
|
|
194
199
|
externalTooltipRefs[index]?.hide()
|
|
195
200
|
}}
|
|
196
201
|
>
|
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
2
|
import styles from './LivePreview.module.scss'
|
|
3
3
|
import SimpleLabelValue from '../../components/SimpleLabelValue'
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
import MethodsAccordion from '../../components/MethodAccordion/MethodAccordion'
|
|
6
6
|
import { TransformedOpenApi } from '../../types/transformedOpenApi'
|
|
7
7
|
import { useFormikContext } from 'formik'
|
|
8
|
-
import { methodColorMapping } from '../../constants/index'
|
|
8
|
+
import { methodColorMapping, tagsTableHeaders } from '../../constants/index'
|
|
9
|
+
import TagsTable from '../table/tags-table'
|
|
10
|
+
import { Button, TextArea } from 'digitinary-ui'
|
|
11
|
+
import Tooltip from '../../components/Tooltip/Tooltip'
|
|
12
|
+
import { DeleteIcon, deleteOutlinedIcon, EditIcon } from '../../assets/icons'
|
|
9
13
|
|
|
10
14
|
interface LivePreviewProps {
|
|
11
15
|
transformedData?: TransformedOpenApi
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
const LivePreview: React.FC<LivePreviewProps> = ({ transformedData }) => {
|
|
19
|
+
const [tableRecords, setTableRecords] = useState()
|
|
20
|
+
const [tooltipRefs, setTooltipRefs] = useState<{ [key: number]: any }>({})
|
|
21
|
+
const [tableData, setTableData] = useState([])
|
|
22
|
+
const [externalTooltipRefs, setExternalTooltipRefs] = useState<{ [key: number]: any }>({})
|
|
15
23
|
const { values } = useFormikContext<TransformedOpenApi>()
|
|
16
24
|
const { info, components, tags } = values
|
|
17
25
|
const { securitySchemes } = components
|
|
@@ -19,6 +27,118 @@ const LivePreview: React.FC<LivePreviewProps> = ({ transformedData }) => {
|
|
|
19
27
|
securitySchemes && typeof securitySchemes == 'object' && Object.keys(securitySchemes).length
|
|
20
28
|
? Object.keys(securitySchemes)[0]
|
|
21
29
|
: null
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
console.log({updated: values.tags})
|
|
33
|
+
if (values.tags && values.tags.length) {
|
|
34
|
+
setTableRecords(generateTableData(values.tags, true))
|
|
35
|
+
setTableData(values.tags)
|
|
36
|
+
}
|
|
37
|
+
}, [values.tags])
|
|
38
|
+
|
|
39
|
+
const generateTableData = (items, readOnly) => {
|
|
40
|
+
return items.map((item, index) => ({
|
|
41
|
+
id: index,
|
|
42
|
+
tagName: item.name,
|
|
43
|
+
description: (
|
|
44
|
+
<div className={styles.paramDescContainer}>
|
|
45
|
+
<Tooltip
|
|
46
|
+
arrowWithBorder
|
|
47
|
+
placement="bottom-end"
|
|
48
|
+
type="function"
|
|
49
|
+
trigger="click"
|
|
50
|
+
delay={[0, 0]}
|
|
51
|
+
onCreate={(instance) =>
|
|
52
|
+
setTooltipRefs((prev) => ({
|
|
53
|
+
...prev,
|
|
54
|
+
[index]: instance,
|
|
55
|
+
}))
|
|
56
|
+
}
|
|
57
|
+
content={
|
|
58
|
+
<div className={styles.editDescTooltipContent}>
|
|
59
|
+
<p className={styles.editDescTooltipContent_header}>Description</p>
|
|
60
|
+
<TextArea
|
|
61
|
+
placeholder="Describe parameter..."
|
|
62
|
+
value={item.description}
|
|
63
|
+
disabled={readOnly}
|
|
64
|
+
onChange={(value) => null}
|
|
65
|
+
/>
|
|
66
|
+
</div>
|
|
67
|
+
}
|
|
68
|
+
>
|
|
69
|
+
<Button className={styles.editDescBtn} variant="link" color="action">
|
|
70
|
+
{item.description ? item.description.substring(0, 12) : '-'}
|
|
71
|
+
{item.description && item.description.length > 12 ? '...' : ''}
|
|
72
|
+
</Button>
|
|
73
|
+
</Tooltip>
|
|
74
|
+
</div>
|
|
75
|
+
),
|
|
76
|
+
externalDocs: (
|
|
77
|
+
<div className={styles.paramDescContainer}>
|
|
78
|
+
<Tooltip
|
|
79
|
+
arrowWithBorder
|
|
80
|
+
placement="bottom-end"
|
|
81
|
+
type="function"
|
|
82
|
+
trigger="click"
|
|
83
|
+
delay={[0, 0]}
|
|
84
|
+
onCreate={(instance) =>
|
|
85
|
+
setExternalTooltipRefs((prev) => ({
|
|
86
|
+
...prev,
|
|
87
|
+
[index]: instance,
|
|
88
|
+
}))
|
|
89
|
+
}
|
|
90
|
+
content={
|
|
91
|
+
<div className={styles.editDescTooltipContent}>
|
|
92
|
+
<p className={styles.editDescTooltipContent_header}>External Docs Description</p>
|
|
93
|
+
<TextArea
|
|
94
|
+
placeholder="Describe External Doc..."
|
|
95
|
+
value={item.externalDocs?.description}
|
|
96
|
+
disabled={readOnly}
|
|
97
|
+
onChange={(value) => null}
|
|
98
|
+
/>
|
|
99
|
+
<p className={styles.editDescTooltipContent_header}>External Docs Link</p>
|
|
100
|
+
<TextArea
|
|
101
|
+
placeholder="External Docs Link..."
|
|
102
|
+
value={item.externalDocs?.url}
|
|
103
|
+
disabled={readOnly}
|
|
104
|
+
onChange={(value) => null}
|
|
105
|
+
/>
|
|
106
|
+
</div>
|
|
107
|
+
}
|
|
108
|
+
>
|
|
109
|
+
<Button
|
|
110
|
+
className={styles.editDescBtn}
|
|
111
|
+
variant="link"
|
|
112
|
+
color="action"
|
|
113
|
+
onClick={() => {
|
|
114
|
+
const a = document.createElement('a')
|
|
115
|
+
a.href = item.externalDocs?.url
|
|
116
|
+
a.click()
|
|
117
|
+
}}
|
|
118
|
+
>
|
|
119
|
+
{item?.externalDocs?.description
|
|
120
|
+
? item?.externalDocs?.description?.substring(0, 12)
|
|
121
|
+
: '-'}
|
|
122
|
+
{item?.externalDocs?.description && item?.externalDocs?.description?.length > 12
|
|
123
|
+
? '...'
|
|
124
|
+
: ''}
|
|
125
|
+
</Button>
|
|
126
|
+
</Tooltip>
|
|
127
|
+
|
|
128
|
+
{!readOnly && <div className={styles.paramDescContainer_separator}></div>}
|
|
129
|
+
|
|
130
|
+
{!readOnly && (
|
|
131
|
+
<Button
|
|
132
|
+
className={styles.deleteParamBtn}
|
|
133
|
+
variant="link"
|
|
134
|
+
color="error"
|
|
135
|
+
onClick={() => null}
|
|
136
|
+
></Button>
|
|
137
|
+
)}
|
|
138
|
+
</div>
|
|
139
|
+
),
|
|
140
|
+
}))
|
|
141
|
+
}
|
|
22
142
|
return (
|
|
23
143
|
<div>
|
|
24
144
|
<div className="row">
|
|
@@ -39,20 +159,15 @@ const LivePreview: React.FC<LivePreviewProps> = ({ transformedData }) => {
|
|
|
39
159
|
<SimpleLabelValue
|
|
40
160
|
key={'tags'}
|
|
41
161
|
label={'Tags: '}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
/>
|
|
52
|
-
) : (
|
|
53
|
-
'-'
|
|
54
|
-
)
|
|
55
|
-
}
|
|
162
|
+
/>
|
|
163
|
+
<TagsTable
|
|
164
|
+
id="tags-table"
|
|
165
|
+
data={tableRecords}
|
|
166
|
+
headCells={tagsTableHeaders}
|
|
167
|
+
isFormOpen={false}
|
|
168
|
+
setIsFormOpen={() => null}
|
|
169
|
+
saveNewRow={() => null}
|
|
170
|
+
readOnly={true}
|
|
56
171
|
/>
|
|
57
172
|
|
|
58
173
|
<SimpleLabelValue key={'endpoints'} label={'Endpoints '} />
|