Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SWI-4827 Update Prism and Add read-only Label #38

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
407 changes: 353 additions & 54 deletions src/common-elements/PrismDiv.tsx

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions src/common-elements/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ export const RequiredLabel = styled(FieldLabel).attrs({
line-height: 1;
`;

export const ReadOnlyLabel = styled(FieldLabel).attrs({
as: 'div',
})`
color: ${props => props.theme.schema.readOnlyLabelColor};
font-size: ${props => props.theme.schema.labelsTextSize};
font-weight: normal;
margin-left: 20px;
line-height: 1;
`;

export const PropertyLabel = styled(RequiredLabel)`
color: ${props => props.theme.colors.primary.light};
`;
Expand Down
3 changes: 3 additions & 0 deletions src/components/Fields/Field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as React from 'react';
import {
ClickablePropertyNameCell,
PropertyLabel,
ReadOnlyLabel,
RequiredLabel,
} from '../../common-elements/fields';
import { FieldDetails } from './FieldDetails';
Expand Down Expand Up @@ -52,6 +53,7 @@ export class Field extends React.Component<FieldProps> {
const { className = '', field, isLast, expandByDefault } = this.props;
const { name, deprecated, required, kind } = field;
const withSubSchema = !field.schema.isPrimitive && !field.schema.isCircular;
const readOnly = field.schema?.readOnly;

const expanded = field.expanded === undefined ? expandByDefault : field.expanded;

Expand All @@ -60,6 +62,7 @@ export class Field extends React.Component<FieldProps> {
{kind === 'additionalProperties' && <PropertyLabel>additional property</PropertyLabel>}
{kind === 'patternProperties' && <PropertyLabel>pattern property</PropertyLabel>}
{required && <RequiredLabel>required</RequiredLabel>}
{readOnly && <ReadOnlyLabel>read-only</ReadOnlyLabel>}
</>
);

Expand Down

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions src/components/__tests__/__snapshots__/FieldDetails.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ exports[`FieldDetailsComponent renders correctly 1`] = `
>

<span
class="sc-kpDqfm sc-gFqAkR cGRfjn fYEICH"
class="sc-kpDqfm sc-ikkxIA cGRfjn bPXQUO"
>

</span>
Expand All @@ -39,7 +39,7 @@ exports[`FieldDetailsComponent renders correctly 1`] = `
</span>

<span
class="sc-kpDqfm sc-eldPxv cGRfjn ehWiAn field-example"
class="sc-kpDqfm sc-fPXMVe cGRfjn hvfdZk field-example"
>
[]
</span>
Expand All @@ -53,14 +53,14 @@ exports[`FieldDetailsComponent renders correctly 1`] = `
</span>

<span
class="sc-kpDqfm sc-eldPxv cGRfjn ehWiAn field-example"
class="sc-kpDqfm sc-fPXMVe cGRfjn hvfdZk field-example"
>
"example"
</span>
</div>
<div>
<div
class="sc-lcIPJg sc-hknOHE gBHqkN jFBMaE"
class="sc-kdBSHD sc-uVWWZ iOlzdo cdRLuO"
>
<p>
test description
Expand Down Expand Up @@ -95,7 +95,7 @@ exports[`FieldDetailsComponent renders correctly when default value is object in
>

<span
class="sc-kpDqfm sc-gFqAkR cGRfjn fYEICH"
class="sc-kpDqfm sc-ikkxIA cGRfjn bPXQUO"
>

</span>
Expand All @@ -109,7 +109,7 @@ exports[`FieldDetailsComponent renders correctly when default value is object in
</span>

<span
class="sc-kpDqfm sc-eldPxv cGRfjn ehWiAn field-example"
class="sc-kpDqfm sc-fPXMVe cGRfjn hvfdZk field-example"
>
{"properties":{}}
</span>
Expand All @@ -123,14 +123,14 @@ exports[`FieldDetailsComponent renders correctly when default value is object in
</span>

<span
class="sc-kpDqfm sc-eldPxv cGRfjn ehWiAn field-example"
class="sc-kpDqfm sc-fPXMVe cGRfjn hvfdZk field-example"
>
"example"
</span>
</div>
<div>
<div
class="sc-lcIPJg sc-hknOHE gBHqkN jFBMaE"
class="sc-kdBSHD sc-uVWWZ iOlzdo cdRLuO"
>
<p>
test description
Expand Down Expand Up @@ -165,17 +165,17 @@ exports[`FieldDetailsComponent renders correctly when field items have string ty
>

<span
class="sc-kpDqfm sc-gFqAkR cGRfjn fYEICH"
class="sc-kpDqfm sc-ikkxIA cGRfjn bPXQUO"
>

</span>
</span>
<span
class="sc-kpDqfm sc-dAlyuH sc-dxcDKg cGRfjn gHomYR gXntsr"
class="sc-kpDqfm sc-dAlyuH sc-gvZAcH cGRfjn gHomYR eXivNJ"
>
[
<span
class="sc-kpDqfm sc-eDPEul cGRfjn cCKYVD field-pattern"
class="sc-kpDqfm sc-eldPxv cGRfjn beMlYF field-pattern"
>
^see regex[0-9]$
</span>
Expand All @@ -191,14 +191,14 @@ exports[`FieldDetailsComponent renders correctly when field items have string ty
</span>

<span
class="sc-kpDqfm sc-eldPxv cGRfjn ehWiAn field-example"
class="sc-kpDqfm sc-fPXMVe cGRfjn hvfdZk field-example"
>
"example"
</span>
</div>
<div>
<div
class="sc-lcIPJg sc-hknOHE gBHqkN jFBMaE"
class="sc-kdBSHD sc-uVWWZ iOlzdo cdRLuO"
>
<p>
test description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ exports[`Components SchemaView OneOf deprecated should match snapshot 1`] = `

<div>
<div
class="sc-eeDRCY sc-eBMEME gTGgei fbXBig"
class="sc-eeDRCY sc-eBMEME kNSrQS fbXBig"
/>
</div>
</div>
Expand Down
Loading
Loading