From c6a79ceeeca40214a48f0de0d9d92edfb269a66d Mon Sep 17 00:00:00 2001 From: Monika-Dangar Date: Thu, 7 Nov 2024 13:14:19 +0530 Subject: [PATCH] fix(BB-806): add validation for float values in width, height, and depth fields Previously, the form rejected decimal values for dimensions without any visual feedback. --- .gitignore | 1 + config/config.json.example | 49 ---------- .../2024-02-07-credit-section/up.sql | 92 +++++++++++++++++++ .../edition-section/edition-section-merge.tsx | 6 +- .../edition-section/edition-section.tsx | 6 +- .../submission-section/actions.ts | 1 - 6 files changed, 99 insertions(+), 56 deletions(-) delete mode 100644 config/config.json.example diff --git a/.gitignore b/.gitignore index 9226617888..30b85fa547 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ /reports /config/config.json /config/config.local.json +/config.json # Directory designated to store local compose overrides and related files /local/ diff --git a/config/config.json.example b/config/config.json.example deleted file mode 100644 index ae0ea80505..0000000000 --- a/config/config.json.example +++ /dev/null @@ -1,49 +0,0 @@ -{ - "site": { - "proxyTrust": true, - "log": "debug", - "forceExitAfterMs": 5000 - }, - "musicbrainz": { - "clientID": null, - "clientSecret": null, - "callbackURL": "http://localhost:9099/cb" - }, - "critiquebrainz": { - "clientID": null, - "clientSecret": null, - "callbackURL": "http://localhost:9099/external-service/critiquebrainz/callback" - }, - "session": { - "maxAge": 2592000000, - "secret": "Something here!", - "secure": false, - "redis": { - "host": "redis", - "port": 6379 - } - }, - "database": { - "client": "pg", - "connection": { - "host": "postgres", - "database": "bookbrainz", - "user": "bookbrainz", - "password": "" - } - }, - "search": { - "node": "http://elasticsearch:9200", - "requestTimeout": 30000 - }, - "mailConfig" :{ - "host":"", - "port":"", - - "auth":{ - "user":"", - "pass":"" - } - - } -} diff --git a/sql/migrations/2024-02-07-credit-section/up.sql b/sql/migrations/2024-02-07-credit-section/up.sql index 4834320997..803da317b2 100644 --- a/sql/migrations/2024-02-07-credit-section/up.sql +++ b/sql/migrations/2024-02-07-credit-section/up.sql @@ -3,6 +3,98 @@ ------------------------------------------------------------------------ +---------------------- ****** NOTICE ****** ---------------------- +-- Don't forget to run the create_trigger.sql script afterwards -- +------------------------------------------------------------------ + +BEGIN TRANSACTION; + +-- Adding credit_section column in edition_data and edition_group_data table and intitalizing it with true +ALTER TABLE bookbrainz.edition_data ADD COLUMN credit_section BOOLEAN DEFAULT TRUE; +ALTER TABLE bookbrainz.edition_group_data ADD COLUMN credit_section BOOLEAN DEFAULT TRUE; + +DROP VIEW IF EXISTS + bookbrainz.edition, + bookbrainz.edition_group; + +-- Recreate the view with the new definition +-- Adding credit_section column in edition view and edition_group view +CREATE VIEW bookbrainz.edition AS +SELECT e.bbid, + edd.id AS data_id, + edr.id AS revision_id, + edr.id = edh.master_revision_id AS master, + edd.annotation_id, + edd.disambiguation_id, + dis.comment AS disambiguation, + als.default_alias_id, + al.name, + al.sort_name, + edd.edition_group_bbid, + edd.author_credit_id, + edd.width, + edd.height, + edd.depth, + edd.weight, + edd.pages, + edd.format_id, + edd.status_id, + edd.alias_set_id, + edd.identifier_set_id, + edd.relationship_set_id, + edd.language_set_id, + edd.release_event_set_id, + edd.publisher_set_id, + edd.credit_section, + e.type + FROM bookbrainz.edition_revision edr + LEFT JOIN bookbrainz.entity e ON e.bbid = edr.bbid + LEFT JOIN bookbrainz.edition_header edh ON edh.bbid = e.bbid + LEFT JOIN bookbrainz.edition_data edd ON edr.data_id = edd.id + LEFT JOIN bookbrainz.alias_set als ON edd.alias_set_id = als.id + LEFT JOIN bookbrainz.alias al ON al.id = als.default_alias_id + LEFT JOIN bookbrainz.disambiguation dis ON dis.id = edd.disambiguation_id + WHERE e.type = 'Edition'; + +CREATE VIEW bookbrainz.edition_group AS +SELECT e.bbid, + egd.id AS data_id, + pcr.id AS revision_id, + pcr.id = egh.master_revision_id AS master, + egd.annotation_id, + egd.disambiguation_id, + dis.comment AS disambiguation, + als.default_alias_id, + al.name, + al.sort_name, + egd.type_id, + egtype.label AS edition_group_type, + egd.author_credit_id, + egd.alias_set_id, + egd.identifier_set_id, + egd.relationship_set_id, + egd.credit_section, + e.type + FROM bookbrainz.edition_group_revision pcr + LEFT JOIN bookbrainz.entity e ON e.bbid = pcr.bbid + LEFT JOIN bookbrainz.edition_group_header egh ON egh.bbid = e.bbid + LEFT JOIN bookbrainz.edition_group_data egd ON pcr.data_id = egd.id + LEFT JOIN bookbrainz.alias_set als ON egd.alias_set_id = als.id + LEFT JOIN bookbrainz.alias al ON al.id = als.default_alias_id + LEFT JOIN bookbrainz.disambiguation dis ON dis.id = egd.disambiguation_id + LEFT JOIN bookbrainz.edition_group_type egtype ON egtype.id = egd.type_id + WHERE e.type = 'EditionGroup'; + +---------------------- ****** NOTICE ****** ---------------------- +-- Don't forget to run the create_trigger.sql script afterwards -- +------------------------------------------------------------------ + +COMMIT TRANSACTION; +----------------------------------------------------------------------- +-- Adds a credit_section boolean column to edition_data and edition_group_data to make author credits optional -- +------------------------------------------------------------------------ + + ---------------------- ****** NOTICE ****** ---------------------- -- Don't forget to run the create_trigger.sql script afterwards -- ------------------------------------------------------------------ diff --git a/src/client/entity-editor/edition-section/edition-section-merge.tsx b/src/client/entity-editor/edition-section/edition-section-merge.tsx index 95901a76eb..d8b2bf8f24 100644 --- a/src/client/entity-editor/edition-section/edition-section-merge.tsx +++ b/src/client/entity-editor/edition-section/edition-section-merge.tsx @@ -333,13 +333,13 @@ function mapDispatchToProps(dispatch: Dispatch): DispatchProps { dispatch(updateAuthorCredit(selectedAuthorCredit)); }, onDepthChange: (event) => dispatch(debouncedUpdateDepth( - event.target.value ? parseInt(event.target.value, 10) : null + event.target.value ? parseFloat(event.target.value) : null )), onEditionGroupChange: (value) => dispatch(updateEditionGroup(value)), onFormatChange: (value: number) => dispatch(updateFormat(value)), onHeightChange: (event) => dispatch(debouncedUpdateHeight( - event.target.value ? parseInt(event.target.value, 10) : null + event.target.value ? parseFloat(event.target.value) : null )), onPagesChange: (event) => dispatch(debouncedUpdatePages( event.target.value ? parseInt(event.target.value, 10) : null @@ -353,7 +353,7 @@ function mapDispatchToProps(dispatch: Dispatch): DispatchProps { event.target.value ? parseInt(event.target.value, 10) : null )), onWidthChange: (event) => dispatch(debouncedUpdateWidth( - event.target.value ? parseInt(event.target.value, 10) : null + event.target.value ? parseFloat(event.target.value) : null )) }; } diff --git a/src/client/entity-editor/edition-section/edition-section.tsx b/src/client/entity-editor/edition-section/edition-section.tsx index 6a70bf1153..2bd333cf63 100644 --- a/src/client/entity-editor/edition-section/edition-section.tsx +++ b/src/client/entity-editor/edition-section/edition-section.tsx @@ -513,7 +513,7 @@ function mapStateToProps(rootState: RootState): StateProps { function mapDispatchToProps(dispatch: Dispatch): DispatchProps { return { onDepthChange: (event) => dispatch(debouncedUpdateDepth( - event.target.value ? parseInt(event.target.value, 10) : null + event.target.value ? parseFloat(event.target.value) : null )), onEditionGroupChange: (value, action) => { // If the user selected a new edition group, we need to clear the old one @@ -532,7 +532,7 @@ function mapDispatchToProps(dispatch: Dispatch): DispatchProps { } }, onHeightChange: (event) => dispatch(debouncedUpdateHeight( - event.target.value ? parseInt(event.target.value, 10) : null + event.target.value ? parseFloat(event.target.value) : null )), onLanguagesChange: (values: Array) => dispatch(updateLanguages(values)), @@ -554,7 +554,7 @@ function mapDispatchToProps(dispatch: Dispatch): DispatchProps { event.target.value ? parseInt(event.target.value, 10) : null )), onWidthChange: (event) => dispatch(debouncedUpdateWidth( - event.target.value ? parseInt(event.target.value, 10) : null + event.target.value ? parseFloat(event.target.value) : null )) }; } diff --git a/src/client/entity-editor/submission-section/actions.ts b/src/client/entity-editor/submission-section/actions.ts index 974f9add5c..4a62059c47 100644 --- a/src/client/entity-editor/submission-section/actions.ts +++ b/src/client/entity-editor/submission-section/actions.ts @@ -23,7 +23,6 @@ import _ from 'lodash'; import {filterObject} from '../../../common/helpers/utils'; import request from 'superagent'; - export const SET_SUBMIT_ERROR = 'SET_SUBMIT_ERROR'; export const UPDATE_REVISION_NOTE = 'UPDATE_REVISION_NOTE'; export const SET_SUBMITTED = 'SET_SUBMITTED';