Skip to content

Commit 58c3b4b

Browse files
SB-ChetanKordeSB-pradeep-bandeSB-rohitdesaiSB-virendrasolankeprafullaAtSB
authored
Stop 2417 iata fix (#2811)
* make changes in responses.tsx for iata demo poc * update in previewer component * change previewer page * update lazyschemaprevier * unwanted code, removed checked and finalSetMaskState and persistOnlyParentDisabled code * update request and response according to local storage properties * fix: choose mask workflow using feature flag * fix: added feature flag condition * added new code for disable expand for number node * pushed working code * added subtype * items removed from array node when it is empty * multi-model dynamic rendering * resolved expand icon issue for circular reference node in depth level * fix: added local modal masking preview * changes for multi-model doc view for request and response * added model logic * fix: removed console logs * resolved description issue removed console * remove lint error in Model.tsx * removed commented code * removed console and commented code * removed remaining consoles * Upgrade version for elements repo * resolved 'should allow changing content type' test case from packages/elements-core/src/components/Docs/HttpOperation/HttpOperation.spec.tsx * added minimatch version * added minimatch version * added minimatch version in angular package * removed minimatch * bump elements-core version --------- Co-authored-by: Pradeep Bande <pradeep.bande@smartbear.com> Co-authored-by: sb-rohitdesai <rohitkumar.desai@smartbear.com> Co-authored-by: SB-virendrasolanke <virendra.solanke@smartbear.com> Co-authored-by: prafullaAtSB <150028847+prafullaAtSB@users.noreply.github.com> Co-authored-by: Akshay Thakar <akshay.thakar@smartbear.com>
1 parent 88a02fd commit 58c3b4b

12 files changed

Lines changed: 504 additions & 41 deletions

File tree

examples/angular/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,8 @@
3939
"@angular/language-service": "^12.0.5",
4040
"angular-http-server": "^1.10.0",
4141
"typescript": "4.2.4"
42+
},
43+
"resolutions": {
44+
"minimatch": "9.0.5"
4245
}
4346
}

packages/elements-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@stoplight/elements-core",
3-
"version": "9.0.2",
3+
"version": "9.0.3",
44
"sideEffects": [
55
"web-components.min.js",
66
"src/web-components/**",

packages/elements-core/src/components/Docs/Docs.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ export interface DocsComponentProps<T = unknown> extends BaseDocsProps {
169169
* The input data for the component to display.
170170
*/
171171
data: T;
172+
disableProps?: any;
172173
}
173174

174175
export const Docs = React.memo<DocsProps>(
@@ -212,16 +213,19 @@ export interface ParsedDocsProps extends BaseDocsProps {
212213
}
213214

214215
export const ParsedDocs = ({ node, nodeUnsupported, ...commonProps }: ParsedDocsProps) => {
216+
const disableProps = (node.data as any)?.disableProps;
217+
215218
switch (node.type) {
216219
case 'article':
217220
return <Article data={node.data} {...commonProps} />;
218221
case 'http_operation':
219222
case 'http_webhook':
220-
return <HttpOperation data={node.data} {...commonProps} />;
223+
return <HttpOperation data={node.data} disableProps={disableProps} {...commonProps} />;
224+
221225
case 'http_service':
222226
return <HttpService data={node.data} {...commonProps} />;
223227
case 'model':
224-
return <Model data={node.data} {...commonProps} />;
228+
return <Model data={node.data} disableProps={disableProps} {...commonProps} />;
225229
default:
226230
nodeUnsupported?.('invalidType');
227231
return null;

packages/elements-core/src/components/Docs/HttpOperation/Body.tsx

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@ import { isJSONSchema } from '../../../utils/guards';
99
import { getOriginalObject } from '../../../utils/ref-resolving/resolvedObject';
1010
import { MarkdownViewer } from '../../MarkdownViewer';
1111
import { SectionSubtitle } from '../Sections';
12+
import LazySchemaTreePreviewer from './LazySchemaTreePreviewer';
1213

1314
export interface BodyProps {
1415
body: IHttpOperationRequestBody;
1516
onChange?: (requestBodyIndex: number) => void;
1617
isHttpWebhookOperation?: boolean;
18+
disableProps?: Array<{
19+
location: string;
20+
paths: Array<{ path: string }>;
21+
}>;
1722
}
1823

1924
export const isBodyEmpty = (body?: BodyProps['body']) => {
@@ -24,11 +29,10 @@ export const isBodyEmpty = (body?: BodyProps['body']) => {
2429
return contents.length === 0 && !description?.trim();
2530
};
2631

27-
export const Body = ({ body, onChange, isHttpWebhookOperation = false }: BodyProps) => {
32+
export const Body = ({ body, onChange, isHttpWebhookOperation = false, disableProps }: BodyProps) => {
2833
const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
2934
const [chosenContent, setChosenContent] = React.useState(0);
3035
const { nodeHasChanged, renderExtensionAddon } = useOptionsCtx();
31-
3236
React.useEffect(() => {
3337
onChange?.(chosenContent);
3438
// disabling because we don't want to react on `onChange` change
@@ -41,6 +45,21 @@ export const Body = ({ body, onChange, isHttpWebhookOperation = false }: BodyPro
4145
const schema = contents[chosenContent]?.schema;
4246
const descriptionChanged = nodeHasChanged?.({ nodeId: body.id, attr: 'description' });
4347

48+
/* Get Masked Properties And Pass to LazySchemaTreePreviewer */
49+
const getMaskProperties = (): Array<{ path: string; required?: boolean }> => {
50+
const disablePropsConfig = disableProps || [];
51+
const absolutePathsToHide: Array<{ path: string; required?: boolean }> = [];
52+
disablePropsConfig.forEach(configEntry => {
53+
const { location, paths } = configEntry;
54+
paths.forEach(item => {
55+
// Construct the full absolute path
56+
const fullPath = `${location}/${item.path}`;
57+
absolutePathsToHide.push({ path: fullPath });
58+
});
59+
});
60+
return absolutePathsToHide;
61+
};
62+
4463
return (
4564
<VStack spacing={6}>
4665
<SectionSubtitle title="Body" id="request-body">
@@ -62,16 +81,20 @@ export const Body = ({ body, onChange, isHttpWebhookOperation = false }: BodyPro
6281
<NodeAnnotation change={descriptionChanged} />
6382
</Box>
6483
)}
65-
{isJSONSchema(schema) && (
66-
<JsonSchemaViewer
67-
resolveRef={refResolver}
68-
maxRefDepth={maxRefDepth}
69-
schema={getOriginalObject(schema)}
70-
viewMode={isHttpWebhookOperation ? 'standalone' : 'write'}
71-
renderRootTreeLines
72-
nodeHasChanged={nodeHasChanged}
73-
renderExtensionAddon={renderExtensionAddon}
74-
/>
84+
{schema && localStorage.getItem('use_new_mask_workflow') === 'true' ? (
85+
<LazySchemaTreePreviewer schema={schema} hideData={getMaskProperties()} />
86+
) : (
87+
isJSONSchema(schema) && (
88+
<JsonSchemaViewer
89+
resolveRef={refResolver}
90+
maxRefDepth={maxRefDepth}
91+
schema={getOriginalObject(schema)}
92+
viewMode={isHttpWebhookOperation ? 'standalone' : 'write'}
93+
renderRootTreeLines
94+
nodeHasChanged={nodeHasChanged}
95+
renderExtensionAddon={renderExtensionAddon}
96+
/>
97+
)
7598
)}
7699
</VStack>
77100
);

packages/elements-core/src/components/Docs/HttpOperation/HttpOperation.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ import { Callbacks } from './Callbacks';
3030
import { Request } from './Request';
3131
import { Responses } from './Responses';
3232

33-
export type HttpOperationProps = DocsComponentProps<IHttpEndpointOperation>;
33+
export type HttpOperationProps = DocsComponentProps<IHttpEndpointOperation> & {
34+
disableProps?: Record<string, any>;
35+
};
3436

3537
const HttpOperationComponent = React.memo<HttpOperationProps>(
36-
({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy }) => {
38+
({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy, disableProps }) => {
3739
const { nodeHasChanged } = useOptionsCtx();
3840
const data = useResolvedObject(unresolvedData) as IHttpEndpointOperation;
3941
const { ref: layoutRef, isCompact } = useIsCompact(layoutOptions);
40-
4142
const mocking = React.useContext(MockingContext);
4243
const isDeprecated = !!data.deprecated;
4344
const isInternal = !!data.internal;
@@ -97,18 +98,22 @@ const HttpOperationComponent = React.memo<HttpOperationProps>(
9798
</Box>
9899
)}
99100
<NodeVendorExtensions data={data} />
101+
100102
<Request
101103
onChange={setTextRequestBodyIndex}
102104
operation={data}
103105
hideSecurityInfo={layoutOptions?.hideSecurityInfo}
104106
isHttpWebhookOperation={isHttpWebhookOperation(data)}
107+
disableProps={disableProps?.request}
105108
/>
109+
106110
{data.responses && (
107111
<Responses
108112
responses={data.responses}
109113
onMediaTypeChange={setResponseMediaType}
110114
onStatusCodeChange={setResponseStatusCode}
111115
isCompact={isCompact}
116+
disableProps={disableProps?.response}
112117
/>
113118
)}
114119
{data.callbacks?.length ? <Callbacks callbacks={data.callbacks} isCompact={isCompact} /> : null}

0 commit comments

Comments
 (0)