Skip to content

Commit

Permalink
Addressing PR Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
SonicScrewdriver committed Nov 14, 2024
1 parent 18880b5 commit 502f602
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions packages/perseus-editor/src/article-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,21 @@ export default class ArticleEditor extends React.Component<Props, State> {
super(props);

// Check if the json needs to be converted
const conversionWarningRequired = conversionRequired(
props.json as PerseusRenderer,
);
const conversionWarningRequired =
props.json instanceof Array
? props.json
.map(conversionRequired)
.reduce((p, v) => p && v, false)
: conversionRequired(props.json);

let json = props.json;

// Convert the json if needed
if (conversionWarningRequired) {
json = Array.isArray(props.json)
? props.json.map(convertDeprecatedWidgets)
: convertDeprecatedWidgets(props.json as PerseusRenderer);
json =
props.json instanceof Array
? props.json.map(convertDeprecatedWidgets)
: convertDeprecatedWidgets(props.json);
}

this.state = {
Expand Down Expand Up @@ -439,7 +444,7 @@ export default class ArticleEditor extends React.Component<Props, State> {
{this.state.conversionWarningRequired && (
<div style={{marginBottom: 10}}>
<Banner
text="Pre-existing Input Number Widgets have been converted to Numeric Inputs. Please review the changes before publishing."
text="Deprecated Input Number Widgets were found, and have been automatically upgraded to Numeric Inputs. Please review the changes before publishing."
kind="warning"
layout="floating"
/>
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus-editor/src/editor-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class EditorPage extends React.Component<Props, State> {
{this.state.conversionWarningRequired && (
<div style={{marginBottom: 10}}>
<Banner
text="Pre-existing Input Number Widgets have been converted to Numeric Inputs. Please review the changes before publishing."
text="Deprecated Input Number Widgets were found, and have been automatically upgraded to Numeric Inputs. Please review the changes before publishing."
kind="warning"
layout="floating"
/>
Expand Down

0 comments on commit 502f602

Please sign in to comment.