docusaurus-theme-openapi-docs 0.0.0-346 → 0.0.0-348
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/package.json +3 -3
- package/src/theme/ApiItem/styles.module.css +4 -0
- package/lib/index.js +0 -48
- package/lib/markdown/createDescription.js +0 -20
- package/lib/markdown/schema.js +0 -121
- package/lib/markdown/utils.js +0 -45
- package/lib/postman-code-generators.d.ts +0 -9
- package/lib/react-magic-dropzone.d.ts +0 -9
- package/lib/theme/ApiDemoPanel/Accept/index.js +0 -41
- package/lib/theme/ApiDemoPanel/Accept/slice.js +0 -32
- package/lib/theme/ApiDemoPanel/Authorization/auth-types.js +0 -32
- package/lib/theme/ApiDemoPanel/Authorization/index.js +0 -174
- package/lib/theme/ApiDemoPanel/Authorization/slice.js +0 -137
- package/lib/theme/ApiDemoPanel/Body/index.js +0 -185
- package/lib/theme/ApiDemoPanel/Body/slice.js +0 -105
- package/lib/theme/ApiDemoPanel/ContentType/index.js +0 -41
- package/lib/theme/ApiDemoPanel/ContentType/slice.js +0 -32
- package/lib/theme/ApiDemoPanel/Curl/index.js +0 -235
- package/lib/theme/ApiDemoPanel/Curl/styles.module.css +0 -84
- package/lib/theme/ApiDemoPanel/Execute/index.js +0 -85
- package/lib/theme/ApiDemoPanel/Execute/makeRequest.js +0 -200
- package/lib/theme/ApiDemoPanel/FloatingButton/index.js +0 -32
- package/lib/theme/ApiDemoPanel/FloatingButton/styles.module.css +0 -26
- package/lib/theme/ApiDemoPanel/FormFileUpload/index.js +0 -96
- package/lib/theme/ApiDemoPanel/FormFileUpload/styles.module.css +0 -75
- package/lib/theme/ApiDemoPanel/FormItem/index.js +0 -35
- package/lib/theme/ApiDemoPanel/FormItem/styles.module.css +0 -7
- package/lib/theme/ApiDemoPanel/FormMultiSelect/index.js +0 -52
- package/lib/theme/ApiDemoPanel/FormMultiSelect/styles.module.css +0 -38
- package/lib/theme/ApiDemoPanel/FormSelect/index.js +0 -39
- package/lib/theme/ApiDemoPanel/FormSelect/styles.module.css +0 -51
- package/lib/theme/ApiDemoPanel/FormTextInput/index.js +0 -30
- package/lib/theme/ApiDemoPanel/FormTextInput/styles.module.css +0 -21
- package/lib/theme/ApiDemoPanel/MethodEndpoint/index.js +0 -60
- package/lib/theme/ApiDemoPanel/ParamOptions/index.js +0 -248
- package/lib/theme/ApiDemoPanel/ParamOptions/slice.js +0 -35
- package/lib/theme/ApiDemoPanel/ParamOptions/styles.module.css +0 -180
- package/lib/theme/ApiDemoPanel/Response/index.js +0 -75
- package/lib/theme/ApiDemoPanel/Response/slice.js +0 -37
- package/lib/theme/ApiDemoPanel/SecuritySchemes/index.js +0 -51
- package/lib/theme/ApiDemoPanel/Server/index.js +0 -109
- package/lib/theme/ApiDemoPanel/Server/slice.js +0 -41
- package/lib/theme/ApiDemoPanel/Server/styles.module.css +0 -61
- package/lib/theme/ApiDemoPanel/VSCode/index.js +0 -252
- package/lib/theme/ApiDemoPanel/VSCode/styles.module.css +0 -19
- package/lib/theme/ApiDemoPanel/buildPostmanRequest.js +0 -328
- package/lib/theme/ApiDemoPanel/hooks.js +0 -20
- package/lib/theme/ApiDemoPanel/index.js +0 -132
- package/lib/theme/ApiDemoPanel/persistanceMiddleware.js +0 -44
- package/lib/theme/ApiDemoPanel/postman-collection.d.ts +0 -10
- package/lib/theme/ApiDemoPanel/storage-utils.js +0 -47
- package/lib/theme/ApiDemoPanel/store.js +0 -48
- package/lib/theme/ApiDemoPanel/styles.module.css +0 -44
- package/lib/theme/ApiItem/index.js +0 -160
- package/lib/theme/ApiItem/styles.module.css +0 -109
- package/lib/theme/ApiTabs/index.js +0 -258
- package/lib/theme/ApiTabs/styles.module.css +0 -118
- package/lib/theme/ParamsItem/index.js +0 -68
- package/lib/theme/ParamsItem/styles.module.css +0 -24
- package/lib/theme/SchemaItem/index.js +0 -58
- package/lib/theme/SchemaItem/styles.module.css +0 -24
- package/lib/theme-classic.d.ts +0 -8
- package/lib/theme-openapi.d.ts +0 -48
- package/lib/theme-translations.d.ts +0 -9
- package/lib/types.js +0 -1
- package/lib-next/index.js +0 -38
- package/lib-next/markdown/createDescription.js +0 -13
- package/lib-next/markdown/schema.js +0 -115
- package/lib-next/markdown/utils.js +0 -31
- package/lib-next/postman-code-generators.d.ts +0 -9
- package/lib-next/react-magic-dropzone.d.ts +0 -9
- package/lib-next/theme/ApiDemoPanel/Accept/index.js +0 -33
- package/lib-next/theme/ApiDemoPanel/Accept/slice.js +0 -19
- package/lib-next/theme/ApiDemoPanel/Authorization/auth-types.js +0 -22
- package/lib-next/theme/ApiDemoPanel/Authorization/index.js +0 -203
- package/lib-next/theme/ApiDemoPanel/Authorization/slice.js +0 -101
- package/lib-next/theme/ApiDemoPanel/Body/index.js +0 -210
- package/lib-next/theme/ApiDemoPanel/Body/slice.js +0 -89
- package/lib-next/theme/ApiDemoPanel/ContentType/index.js +0 -33
- package/lib-next/theme/ApiDemoPanel/ContentType/slice.js +0 -19
- package/lib-next/theme/ApiDemoPanel/Curl/index.js +0 -262
- package/lib-next/theme/ApiDemoPanel/Curl/styles.module.css +0 -84
- package/lib-next/theme/ApiDemoPanel/Execute/index.js +0 -73
- package/lib-next/theme/ApiDemoPanel/Execute/makeRequest.js +0 -181
- package/lib-next/theme/ApiDemoPanel/FloatingButton/index.js +0 -19
- package/lib-next/theme/ApiDemoPanel/FloatingButton/styles.module.css +0 -26
- package/lib-next/theme/ApiDemoPanel/FormFileUpload/index.js +0 -112
- package/lib-next/theme/ApiDemoPanel/FormFileUpload/styles.module.css +0 -75
- package/lib-next/theme/ApiDemoPanel/FormItem/index.js +0 -29
- package/lib-next/theme/ApiDemoPanel/FormItem/styles.module.css +0 -7
- package/lib-next/theme/ApiDemoPanel/FormMultiSelect/index.js +0 -49
- package/lib-next/theme/ApiDemoPanel/FormMultiSelect/styles.module.css +0 -38
- package/lib-next/theme/ApiDemoPanel/FormSelect/index.js +0 -28
- package/lib-next/theme/ApiDemoPanel/FormSelect/styles.module.css +0 -51
- package/lib-next/theme/ApiDemoPanel/FormTextInput/index.js +0 -23
- package/lib-next/theme/ApiDemoPanel/FormTextInput/styles.module.css +0 -21
- package/lib-next/theme/ApiDemoPanel/MethodEndpoint/index.js +0 -53
- package/lib-next/theme/ApiDemoPanel/ParamOptions/index.js +0 -284
- package/lib-next/theme/ApiDemoPanel/ParamOptions/slice.js +0 -22
- package/lib-next/theme/ApiDemoPanel/ParamOptions/styles.module.css +0 -180
- package/lib-next/theme/ApiDemoPanel/Response/index.js +0 -65
- package/lib-next/theme/ApiDemoPanel/Response/slice.js +0 -22
- package/lib-next/theme/ApiDemoPanel/SecuritySchemes/index.js +0 -48
- package/lib-next/theme/ApiDemoPanel/Server/index.js +0 -114
- package/lib-next/theme/ApiDemoPanel/Server/slice.js +0 -25
- package/lib-next/theme/ApiDemoPanel/Server/styles.module.css +0 -61
- package/lib-next/theme/ApiDemoPanel/VSCode/index.js +0 -265
- package/lib-next/theme/ApiDemoPanel/VSCode/styles.module.css +0 -19
- package/lib-next/theme/ApiDemoPanel/buildPostmanRequest.js +0 -309
- package/lib-next/theme/ApiDemoPanel/hooks.js +0 -9
- package/lib-next/theme/ApiDemoPanel/index.js +0 -108
- package/lib-next/theme/ApiDemoPanel/persistanceMiddleware.js +0 -38
- package/lib-next/theme/ApiDemoPanel/postman-collection.d.ts +0 -10
- package/lib-next/theme/ApiDemoPanel/storage-utils.js +0 -35
- package/lib-next/theme/ApiDemoPanel/store.js +0 -30
- package/lib-next/theme/ApiDemoPanel/styles.module.css +0 -44
- package/lib-next/theme/ApiItem/index.js +0 -171
- package/lib-next/theme/ApiItem/styles.module.css +0 -109
- package/lib-next/theme/ApiTabs/index.js +0 -258
- package/lib-next/theme/ApiTabs/styles.module.css +0 -118
- package/lib-next/theme/ParamsItem/index.js +0 -68
- package/lib-next/theme/ParamsItem/styles.module.css +0 -24
- package/lib-next/theme/SchemaItem/index.js +0 -58
- package/lib-next/theme/SchemaItem/styles.module.css +0 -24
- package/lib-next/theme-classic.d.ts +0 -8
- package/lib-next/theme-openapi.d.ts +0 -48
- package/lib-next/theme-translations.d.ts +0 -9
- package/lib-next/types.js +0 -1
- package/yarn-error.log +0 -15035
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/* ============================================================================
|
|
2
|
-
* Copyright (c) Palo Alto Networks
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
* ========================================================================== */
|
|
7
|
-
import { createSlice } from "@reduxjs/toolkit";
|
|
8
|
-
import { createStorage, hashArray } from "../storage-utils";
|
|
9
|
-
import { getAuthDataKeys } from "./auth-types"; // The global definitions
|
|
10
|
-
// "securitySchemes": {
|
|
11
|
-
// "BearerAuth": { "type": "http", "scheme": "BeAreR" },
|
|
12
|
-
// "BasicAuth": { "type": "http", "scheme": "basic" }
|
|
13
|
-
// },
|
|
14
|
-
// The operation level requirements
|
|
15
|
-
// "security": [
|
|
16
|
-
// { "BearerAuth": [] },
|
|
17
|
-
// { "BearerAuth": [], "BasicAuth": [] }
|
|
18
|
-
// ],
|
|
19
|
-
// SLICE_STATE
|
|
20
|
-
// data:
|
|
21
|
-
// BearerAuth:
|
|
22
|
-
// token=xxx
|
|
23
|
-
// BasicAuth:
|
|
24
|
-
// username=xxx
|
|
25
|
-
// password=xxx
|
|
26
|
-
//
|
|
27
|
-
// options:
|
|
28
|
-
// "BearerAuth": [{ key: "BearerAuth", scopes: [], ...rest }]
|
|
29
|
-
// "BearerAuth and BasicAuth": [{ key: "BearerAuth", scopes: [], ...rest }, { key: "BasicAuth", scopes: [], ...rest }]
|
|
30
|
-
//
|
|
31
|
-
// selected: "BearerAuth and BasicAuth"
|
|
32
|
-
// LOCAL_STORAGE
|
|
33
|
-
// hash(SLICE_STATE.options) -> "BearerAuth and BasicAuth"
|
|
34
|
-
// BearerAuth -> { token: xxx }
|
|
35
|
-
// BasicAuth -> { username: xxx, password: xxx }
|
|
36
|
-
|
|
37
|
-
export function createAuth({ security, securitySchemes, options: opts }) {
|
|
38
|
-
const storage = createStorage(opts?.authPersistance);
|
|
39
|
-
let data = {};
|
|
40
|
-
let options = {};
|
|
41
|
-
|
|
42
|
-
for (const option of security ?? []) {
|
|
43
|
-
const id = Object.keys(option).join(" and ");
|
|
44
|
-
|
|
45
|
-
for (const [schemeID, scopes] of Object.entries(option)) {
|
|
46
|
-
const scheme = securitySchemes?.[schemeID];
|
|
47
|
-
|
|
48
|
-
if (scheme) {
|
|
49
|
-
if (options[id] === undefined) {
|
|
50
|
-
options[id] = [];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const dataKeys = getAuthDataKeys(scheme);
|
|
54
|
-
|
|
55
|
-
for (const key of dataKeys) {
|
|
56
|
-
if (data[schemeID] === undefined) {
|
|
57
|
-
data[schemeID] = {};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
let persisted = undefined;
|
|
61
|
-
|
|
62
|
-
try {
|
|
63
|
-
persisted = JSON.parse(storage.getItem(schemeID) ?? "")[key];
|
|
64
|
-
} catch {}
|
|
65
|
-
|
|
66
|
-
data[schemeID][key] = persisted;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
options[id].push({ ...scheme, key: schemeID, scopes });
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
let persisted = undefined;
|
|
75
|
-
|
|
76
|
-
try {
|
|
77
|
-
persisted = storage.getItem(hashArray(Object.keys(options))) ?? undefined;
|
|
78
|
-
} catch {}
|
|
79
|
-
|
|
80
|
-
return {
|
|
81
|
-
data,
|
|
82
|
-
options,
|
|
83
|
-
selected: persisted ?? Object.keys(options)[0],
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
const initialState = {};
|
|
87
|
-
export const slice = createSlice({
|
|
88
|
-
name: "auth",
|
|
89
|
-
initialState,
|
|
90
|
-
reducers: {
|
|
91
|
-
setAuthData: (state, action) => {
|
|
92
|
-
const { scheme, key, value } = action.payload;
|
|
93
|
-
state.data[scheme][key] = value;
|
|
94
|
-
},
|
|
95
|
-
setSelectedAuth: (state, action) => {
|
|
96
|
-
state.selected = action.payload;
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
export const { setAuthData, setSelectedAuth } = slice.actions;
|
|
101
|
-
export default slice.reducer;
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
/* ============================================================================
|
|
2
|
-
* Copyright (c) Palo Alto Networks
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
* ========================================================================== */
|
|
7
|
-
import React from "react";
|
|
8
|
-
import ContentType from "../ContentType";
|
|
9
|
-
import FormSelect from "../FormSelect";
|
|
10
|
-
import { useTypedDispatch, useTypedSelector } from "../hooks";
|
|
11
|
-
import FormFileUpload from "./../FormFileUpload";
|
|
12
|
-
import FormItem from "./../FormItem";
|
|
13
|
-
import FormTextInput from "./../FormTextInput";
|
|
14
|
-
import VSCode from "./../VSCode";
|
|
15
|
-
import {
|
|
16
|
-
clearFormBodyKey,
|
|
17
|
-
clearRawBody,
|
|
18
|
-
setFileFormBody,
|
|
19
|
-
setFileRawBody,
|
|
20
|
-
setStringFormBody,
|
|
21
|
-
setStringRawBody,
|
|
22
|
-
} from "./slice";
|
|
23
|
-
|
|
24
|
-
function BodyWrap({ requestBodyMetadata, jsonRequestBodyExample }) {
|
|
25
|
-
const contentType = useTypedSelector((state) => state.contentType.value); // NOTE: We used to check if body was required, but opted to always show the request body
|
|
26
|
-
// to reduce confusion, see: https://github.com/cloud-annotations/docusaurus-openapi/issues/145
|
|
27
|
-
// No body
|
|
28
|
-
|
|
29
|
-
if (contentType === undefined) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<>
|
|
35
|
-
<ContentType />
|
|
36
|
-
<Body
|
|
37
|
-
requestBodyMetadata={requestBodyMetadata}
|
|
38
|
-
jsonRequestBodyExample={jsonRequestBodyExample}
|
|
39
|
-
/>
|
|
40
|
-
</>
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function Body({ requestBodyMetadata, jsonRequestBodyExample }) {
|
|
45
|
-
const contentType = useTypedSelector((state) => state.contentType.value);
|
|
46
|
-
const dispatch = useTypedDispatch(); // Lot's of possible content-types:
|
|
47
|
-
// - application/json
|
|
48
|
-
// - application/xml
|
|
49
|
-
// - text/plain
|
|
50
|
-
// - text/css
|
|
51
|
-
// - text/html
|
|
52
|
-
// - text/javascript
|
|
53
|
-
// - application/javascript
|
|
54
|
-
// - multipart/form-data
|
|
55
|
-
// - application/x-www-form-urlencoded
|
|
56
|
-
// - image/svg+xml;charset=US-ASCII
|
|
57
|
-
// Show editor:
|
|
58
|
-
// - application/json
|
|
59
|
-
// - application/xml
|
|
60
|
-
// - */*
|
|
61
|
-
// Show form:
|
|
62
|
-
// - multipart/form-data
|
|
63
|
-
// - application/x-www-form-urlencoded
|
|
64
|
-
|
|
65
|
-
const schema = requestBodyMetadata?.content?.[contentType]?.schema;
|
|
66
|
-
|
|
67
|
-
if (schema?.format === "binary") {
|
|
68
|
-
return (
|
|
69
|
-
<FormItem label="Body">
|
|
70
|
-
<FormFileUpload
|
|
71
|
-
placeholder={schema.description || "Body"}
|
|
72
|
-
onChange={(file) => {
|
|
73
|
-
if (file === undefined) {
|
|
74
|
-
dispatch(clearRawBody());
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
dispatch(
|
|
79
|
-
setFileRawBody({
|
|
80
|
-
src: `/path/to/${file.name}`,
|
|
81
|
-
content: file,
|
|
82
|
-
})
|
|
83
|
-
);
|
|
84
|
-
}}
|
|
85
|
-
/>
|
|
86
|
-
</FormItem>
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (
|
|
91
|
-
(contentType === "multipart/form-data" ||
|
|
92
|
-
contentType === "application/x-www-form-urlencoded") &&
|
|
93
|
-
schema?.type === "object"
|
|
94
|
-
) {
|
|
95
|
-
return (
|
|
96
|
-
<FormItem label="Body">
|
|
97
|
-
<div
|
|
98
|
-
style={{
|
|
99
|
-
marginTop: "calc(var(--ifm-pre-padding) / 2)",
|
|
100
|
-
borderRadius: "4px",
|
|
101
|
-
padding: "var(--ifm-pre-padding)",
|
|
102
|
-
border: "1px solid var(--openapi-monaco-border-color)",
|
|
103
|
-
}}
|
|
104
|
-
>
|
|
105
|
-
{Object.entries(schema.properties ?? {}).map(([key, val]) => {
|
|
106
|
-
if (val.format === "binary") {
|
|
107
|
-
return (
|
|
108
|
-
<FormItem key={key} label={key}>
|
|
109
|
-
<FormFileUpload
|
|
110
|
-
placeholder={val.description || key}
|
|
111
|
-
onChange={(file) => {
|
|
112
|
-
if (file === undefined) {
|
|
113
|
-
dispatch(clearFormBodyKey(key));
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
dispatch(
|
|
118
|
-
setFileFormBody({
|
|
119
|
-
key: key,
|
|
120
|
-
value: {
|
|
121
|
-
src: `/path/to/${file.name}`,
|
|
122
|
-
content: file,
|
|
123
|
-
},
|
|
124
|
-
})
|
|
125
|
-
);
|
|
126
|
-
}}
|
|
127
|
-
/>
|
|
128
|
-
</FormItem>
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (val.enum) {
|
|
133
|
-
return (
|
|
134
|
-
<FormItem key={key} label={key}>
|
|
135
|
-
<FormSelect
|
|
136
|
-
options={["---", ...val.enum]}
|
|
137
|
-
onChange={(e) => {
|
|
138
|
-
const val = e.target.value;
|
|
139
|
-
|
|
140
|
-
if (val === "---") {
|
|
141
|
-
dispatch(clearFormBodyKey(key));
|
|
142
|
-
} else {
|
|
143
|
-
dispatch(
|
|
144
|
-
setStringFormBody({
|
|
145
|
-
key: key,
|
|
146
|
-
value: val,
|
|
147
|
-
})
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
}}
|
|
151
|
-
/>
|
|
152
|
-
</FormItem>
|
|
153
|
-
);
|
|
154
|
-
} // TODO: support all the other types.
|
|
155
|
-
|
|
156
|
-
return (
|
|
157
|
-
<FormItem key={key} label={key}>
|
|
158
|
-
<FormTextInput
|
|
159
|
-
placeholder={val.description || key}
|
|
160
|
-
onChange={(e) => {
|
|
161
|
-
dispatch(
|
|
162
|
-
setStringFormBody({
|
|
163
|
-
key: key,
|
|
164
|
-
value: e.target.value,
|
|
165
|
-
})
|
|
166
|
-
);
|
|
167
|
-
}}
|
|
168
|
-
/>
|
|
169
|
-
</FormItem>
|
|
170
|
-
);
|
|
171
|
-
})}
|
|
172
|
-
</div>
|
|
173
|
-
</FormItem>
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
let language = "plaintext";
|
|
178
|
-
let exampleBodyString = ""; //"body content";
|
|
179
|
-
|
|
180
|
-
if (contentType === "application/json") {
|
|
181
|
-
if (jsonRequestBodyExample) {
|
|
182
|
-
exampleBodyString = JSON.stringify(jsonRequestBodyExample, null, 2);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
language = "json";
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (contentType === "application/xml") {
|
|
189
|
-
language = "xml";
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
return (
|
|
193
|
-
<FormItem label="Body">
|
|
194
|
-
<VSCode
|
|
195
|
-
value={exampleBodyString}
|
|
196
|
-
language={language}
|
|
197
|
-
onChange={(value) => {
|
|
198
|
-
if (value.trim() === "") {
|
|
199
|
-
dispatch(clearRawBody());
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
dispatch(setStringRawBody(value));
|
|
204
|
-
}}
|
|
205
|
-
/>
|
|
206
|
-
</FormItem>
|
|
207
|
-
);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
export default BodyWrap;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/* ============================================================================
|
|
2
|
-
* Copyright (c) Palo Alto Networks
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
* ========================================================================== */
|
|
7
|
-
import { createSlice } from "@reduxjs/toolkit";
|
|
8
|
-
const initialState = {};
|
|
9
|
-
export const slice = createSlice({
|
|
10
|
-
name: "body",
|
|
11
|
-
initialState,
|
|
12
|
-
reducers: {
|
|
13
|
-
clearRawBody: (_state) => {
|
|
14
|
-
return {
|
|
15
|
-
type: "empty",
|
|
16
|
-
};
|
|
17
|
-
},
|
|
18
|
-
setStringRawBody: (_state, action) => {
|
|
19
|
-
return {
|
|
20
|
-
type: "raw",
|
|
21
|
-
content: {
|
|
22
|
-
type: "string",
|
|
23
|
-
value: action.payload,
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
setFileRawBody: (_state, action) => {
|
|
28
|
-
return {
|
|
29
|
-
type: "raw",
|
|
30
|
-
content: {
|
|
31
|
-
type: "file",
|
|
32
|
-
value: action.payload,
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
clearFormBodyKey: (state, action) => {
|
|
37
|
-
if (state?.type === "form") {
|
|
38
|
-
delete state.content[action.payload];
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
setStringFormBody: (state, action) => {
|
|
42
|
-
if (state?.type !== "form") {
|
|
43
|
-
return {
|
|
44
|
-
type: "form",
|
|
45
|
-
content: {
|
|
46
|
-
[action.payload.key]: {
|
|
47
|
-
type: "string",
|
|
48
|
-
value: action.payload.value,
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
state.content[action.payload.key] = {
|
|
55
|
-
type: "string",
|
|
56
|
-
value: action.payload.value,
|
|
57
|
-
};
|
|
58
|
-
return state;
|
|
59
|
-
},
|
|
60
|
-
setFileFormBody: (state, action) => {
|
|
61
|
-
if (state?.type !== "form") {
|
|
62
|
-
return {
|
|
63
|
-
type: "form",
|
|
64
|
-
content: {
|
|
65
|
-
[action.payload.key]: {
|
|
66
|
-
type: "file",
|
|
67
|
-
value: action.payload.value,
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
state.content[action.payload.key] = {
|
|
74
|
-
type: "file",
|
|
75
|
-
value: action.payload.value,
|
|
76
|
-
};
|
|
77
|
-
return state;
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
export const {
|
|
82
|
-
clearRawBody,
|
|
83
|
-
setStringRawBody,
|
|
84
|
-
setFileRawBody,
|
|
85
|
-
clearFormBodyKey,
|
|
86
|
-
setStringFormBody,
|
|
87
|
-
setFileFormBody,
|
|
88
|
-
} = slice.actions;
|
|
89
|
-
export default slice.reducer;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/* ============================================================================
|
|
2
|
-
* Copyright (c) Palo Alto Networks
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
* ========================================================================== */
|
|
7
|
-
import React from "react";
|
|
8
|
-
import { useTypedDispatch, useTypedSelector } from "../hooks";
|
|
9
|
-
import FormItem from "./../FormItem";
|
|
10
|
-
import FormSelect from "./../FormSelect";
|
|
11
|
-
import { setContentType } from "./slice";
|
|
12
|
-
|
|
13
|
-
function ContentType() {
|
|
14
|
-
const value = useTypedSelector((state) => state.contentType.value);
|
|
15
|
-
const options = useTypedSelector((state) => state.contentType.options);
|
|
16
|
-
const dispatch = useTypedDispatch();
|
|
17
|
-
|
|
18
|
-
if (options.length <= 1) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<FormItem label="Content-Type">
|
|
24
|
-
<FormSelect
|
|
25
|
-
value={value}
|
|
26
|
-
options={options}
|
|
27
|
-
onChange={(e) => dispatch(setContentType(e.target.value))}
|
|
28
|
-
/>
|
|
29
|
-
</FormItem>
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export default ContentType;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/* ============================================================================
|
|
2
|
-
* Copyright (c) Palo Alto Networks
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
* ========================================================================== */
|
|
7
|
-
import { createSlice } from "@reduxjs/toolkit";
|
|
8
|
-
const initialState = {};
|
|
9
|
-
export const slice = createSlice({
|
|
10
|
-
name: "contentType",
|
|
11
|
-
initialState,
|
|
12
|
-
reducers: {
|
|
13
|
-
setContentType: (state, action) => {
|
|
14
|
-
state.value = action.payload;
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
export const { setContentType } = slice.actions;
|
|
19
|
-
export default slice.reducer;
|