-
Notifications
You must be signed in to change notification settings - Fork 350
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
Addition of new alert when json is converted. #1859
Conversation
GeraldRequired Reviewers
Don't want to be involved in this pull request? Comment |
if (!conversionRequired(json)) { | ||
return json; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need to check here any more, as we're doing it directly in the editors. This allows us to know when the json has been updated! :)
npm Snapshot: PublishedGood news!! We've packaged up the latest commit from this PR (502f602) and published it to npm. You Example: yarn add @khanacademy/perseus@PR1859 If you are working in Khan Academy's webapp, you can run: ./dev/tools/bump_perseus_version.sh -t PR1859 |
Size Change: +350 B (+0.04%) Total Size: 872 kB
ℹ️ View Unchanged
|
? props.json.map(convertDeprecatedWidgets) | ||
: convertDeprecatedWidgets(props.json as PerseusRenderer); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I felt it was better to keep this a little verbose to help with legibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. :)
const conversionWarningRequired = conversionRequired( | ||
props.json as PerseusRenderer, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably not be safe. I'm pretty sure there are places in webapp where it passes in ReadonlyArray<PerseusRenderer>
(essentially the PeprseusArticle
type). I think it can be fixed fairly easily though with:
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh great catch, thank you! I forgot to check for the sections as part of the conversionRequired check
|
||
// Convert the json if needed | ||
if (conversionWarningRequired) { | ||
json = Array.isArray(props.json) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use props.json instanceof Array
. That will still do array checking but properly narrow props.json
so you don't need the as
.
{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." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "Pre-existing" threw me... where did they exist before? :)
Perhaps "Deprecated Input Number widgets were found in this article! They have been automatically upgraded to Numeric Inputs. Please review the changes before publishing."
{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." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same nit about "pre-existing". 😄
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @khanacademy/[email protected] ### Minor Changes - [#1731](#1731) [`27126aa00`](27126aa) Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Conversion of Input Number to Numeric Input ### Patch Changes - [#1846](#1846) [`8eb1ff5d1`](8eb1ff5) Thanks [@benchristel](https://github.com/benchristel)! - Internal: add widget parsers for ADR 773. - [#1839](#1839) [`150888870`](1508888) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Labels] Util function to generate spoken math + use it within Locked Point aria labels ## @khanacademy/[email protected] ### Minor Changes - [#1859](#1859) [`dcf1fbe35`](dcf1fbe) Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Addition of a new alert for the content editors when Input numbers are converted to Numeric Inputs - [#1731](#1731) [`27126aa00`](27126aa) Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Conversion of Input Number to Numeric Input ### Patch Changes - [#1839](#1839) [`150888870`](1508888) Thanks [@nishasy](https://github.com/nishasy)! - [Locked Figure Labels] Util function to generate spoken math + use it within Locked Point aria labels - Updated dependencies \[[`8eb1ff5d1`](8eb1ff5), [`150888870`](1508888), [`27126aa00`](27126aa)]: - @khanacademy/[email protected]
This reverts commit dcf1fbe.
… logic (#1905) ## Summary: In order to unblock Perseus, we are reverting the following commits: - [x] [#1888](#1888) [d0e7a03](d0e7a03) Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Fixing issue with Input Numbers that have a value of 0 - [x] [#1884](#1884) [b4cf444](b4cf444) Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Ensuring UserInput and Rubric widget keys match for edge cases - [x] [#1879](#1879) [04d6e60](04d6e60) Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Fixing conflicts that arose from scoring and widget conversion efforts - [x] [#1753](#1753) [c1ba55f](c1ba55f) Thanks [@handeyeco](https://github.com/handeyeco)! - Change ServerItemRenderer scoring APIs to externalize scoring - [x] [#1866](#1866) [94eba15](94eba15) Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Fixing a regression and a bug in the Input Conversion Logic - [x] [#1859](#1859) [dcf1fbe](dcf1fbe) Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Addition of a new alert for the content editors when Input numbers are converted to Numeric Inputs - [x] [#1731](#1731) [27126aa](27126aa) Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Conversion of Input Number to Numeric Input ## Test plan: - manual testing Author: SonicScrewdriver Reviewers: catandthemachines, #perseus Required Reviewers: Approved By: catandthemachines Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ gerald, 🚫 Publish npm snapshot (ubuntu-latest, 20.x), 🚫 Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), 🚫 Check for .changeset entries for all changed files (ubuntu-latest, 20.x), 🚫 Check builds for changes in size (ubuntu-latest, 20.x), 🚫 Cypress (ubuntu-latest, 20.x), ✅ gerald, ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ gerald Pull Request URL: #1905
… logic (#1905) ## Summary: In order to unblock Perseus, we are reverting the following commits: - [x] [#1888](#1888) [d0e7a03](d0e7a03) Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Fixing issue with Input Numbers that have a value of 0 - [x] [#1884](#1884) [b4cf444](b4cf444) Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Ensuring UserInput and Rubric widget keys match for edge cases - [x] [#1879](#1879) [04d6e60](04d6e60) Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Fixing conflicts that arose from scoring and widget conversion efforts - [x] [#1753](#1753) [c1ba55f](c1ba55f) Thanks [@handeyeco](https://github.com/handeyeco)! - Change ServerItemRenderer scoring APIs to externalize scoring - [x] [#1866](#1866) [94eba15](94eba15) Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Fixing a regression and a bug in the Input Conversion Logic - [x] [#1859](#1859) [dcf1fbe](dcf1fbe) Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Addition of a new alert for the content editors when Input numbers are converted to Numeric Inputs - [x] [#1731](#1731) [27126aa](27126aa) Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Conversion of Input Number to Numeric Input ## Test plan: - manual testing Author: SonicScrewdriver Reviewers: catandthemachines, #perseus Required Reviewers: Approved By: catandthemachines Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ gerald, 🚫 Publish npm snapshot (ubuntu-latest, 20.x), 🚫 Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), 🚫 Check for .changeset entries for all changed files (ubuntu-latest, 20.x), 🚫 Check builds for changes in size (ubuntu-latest, 20.x), 🚫 Cypress (ubuntu-latest, 20.x), ✅ gerald, ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ gerald Pull Request URL: #1905
Summary:
This PR adds an alert banner to the editors to notify Content Editors when pre-existing content has been converted into modern widgets. (ie Input Number has become Numeric Input)
Screenshot:
Test plan: