From a31af13c84cab0ca0bb42b8acd028c7dd6281ddd Mon Sep 17 00:00:00 2001 From: Dmitri Date: Tue, 31 Mar 2026 10:37:41 +0400 Subject: [PATCH] fixed global styles issue --- ...4-cleanup-invalid-element-type-defaults.js | 80 +++++++++ .../CarouselSettingsSection.tsx | 130 +++++++-------- .../GallerySettingsSection.tsx | 156 +++++++++--------- 3 files changed, 219 insertions(+), 147 deletions(-) create mode 100644 backend/src/db/migrations/20260331063424-cleanup-invalid-element-type-defaults.js diff --git a/backend/src/db/migrations/20260331063424-cleanup-invalid-element-type-defaults.js b/backend/src/db/migrations/20260331063424-cleanup-invalid-element-type-defaults.js new file mode 100644 index 0000000..a23cff9 --- /dev/null +++ b/backend/src/db/migrations/20260331063424-cleanup-invalid-element-type-defaults.js @@ -0,0 +1,80 @@ +'use strict'; + +/** + * Remove invalid element_type_defaults entries. + * Only valid element types defined in DEFAULT_ROWS should exist. + */ +module.exports = { + async up(queryInterface, Sequelize) { + // Valid element types as defined in element_type_defaults.js DEFAULT_ROWS + const validTypes = [ + 'navigation_next', + 'navigation_prev', + 'tooltip', + 'description', + 'gallery', + 'carousel', + 'video_player', + 'audio_player', + 'spot', + 'logo', + 'popup', + ]; + + // Find invalid entries + const invalidEntries = await queryInterface.sequelize.query( + `SELECT id, element_type, name + FROM element_type_defaults + WHERE element_type NOT IN (:validTypes) + AND "deletedAt" IS NULL`, + { + replacements: { validTypes }, + type: Sequelize.QueryTypes.SELECT, + }, + ); + + if (invalidEntries.length === 0) { + console.log('No invalid element_type_defaults found.'); + return; + } + + console.log( + `Found ${invalidEntries.length} invalid element_type_defaults:`, + ); + invalidEntries.forEach((entry) => { + console.log(` - ${entry.name} (${entry.element_type})`); + }); + + // Delete invalid entries + const idsToDelete = invalidEntries.map((e) => e.id); + await queryInterface.sequelize.query( + `DELETE FROM element_type_defaults WHERE id IN (:ids)`, + { replacements: { ids: idsToDelete } }, + ); + + // Also delete from project_element_defaults + const deletedProjectDefaults = await queryInterface.sequelize.query( + `DELETE FROM project_element_defaults + WHERE element_type NOT IN (:validTypes) + RETURNING id, element_type`, + { + replacements: { validTypes }, + type: Sequelize.QueryTypes.SELECT, + }, + ); + + console.log( + `Deleted ${idsToDelete.length} invalid element_type_defaults.`, + ); + console.log( + `Deleted ${deletedProjectDefaults.length} invalid project_element_defaults.`, + ); + }, + + async down(_queryInterface, _Sequelize) { + // Cannot restore deleted invalid entries + console.log( + 'Down migration not applicable - invalid entries cannot be restored.', + ); + }, +}; diff --git a/frontend/src/components/ElementSettings/CarouselSettingsSection.tsx b/frontend/src/components/ElementSettings/CarouselSettingsSection.tsx index 5807cbf..d2c973a 100644 --- a/frontend/src/components/ElementSettings/CarouselSettingsSection.tsx +++ b/frontend/src/components/ElementSettings/CarouselSettingsSection.tsx @@ -106,76 +106,70 @@ const CarouselSettingsSection: React.FC = ({ -
-

Carousel slides

- -
+ {/* Slides editor only shown in constructor - slides are instance-specific */} + {isConstructor && ( + <> +
+

Carousel slides

+ +
-
- {carouselSlides.length === 0 ? ( -

No slides yet.

- ) : ( - carouselSlides.map((slide, index) => ( - -
-

Slide {index + 1}

- onRemoveSlide(slide.id)} - /> -
-
- {isConstructor ? ( - - - - ) : ( - - - onUpdateSlide(slide.id, 'imageUrl', event.target.value) - } +
+ {carouselSlides.length === 0 ? ( +

No slides yet.

+ ) : ( + carouselSlides.map((slide, index) => ( + +
+

Slide {index + 1}

+ onRemoveSlide(slide.id)} /> - - )} - - - onUpdateSlide(slide.id, 'caption', event.target.value) - } - /> - -
-
- )) - )} -
+
+
+ + + + + + onUpdateSlide(slide.id, 'caption', event.target.value) + } + /> + +
+
+ )) + )} +
+ + )} ); }; diff --git a/frontend/src/components/ElementSettings/GallerySettingsSection.tsx b/frontend/src/components/ElementSettings/GallerySettingsSection.tsx index e3cce15..bb2ba5f 100644 --- a/frontend/src/components/ElementSettings/GallerySettingsSection.tsx +++ b/frontend/src/components/ElementSettings/GallerySettingsSection.tsx @@ -63,87 +63,85 @@ const GallerySettingsSection: React.FC = ({ -
-

Gallery cards

- -
+ {/* Cards editor only shown in constructor - cards are instance-specific */} + {isConstructor && ( + <> +
+

Gallery cards

+ +
-
- {galleryCards.length === 0 ? ( -

No cards yet.

- ) : ( - galleryCards.map((card, index) => ( - -
-

Card {index + 1}

- onRemoveCard(card.id)} - /> -
-
- {isConstructor ? ( - - - - ) : ( - - - onUpdateCard(card.id, 'imageUrl', event.target.value) - } +
+ {galleryCards.length === 0 ? ( +

No cards yet.

+ ) : ( + galleryCards.map((card, index) => ( + +
+

Card {index + 1}

+ onRemoveCard(card.id)} /> - - )} - - - onUpdateCard(card.id, 'title', event.target.value) - } - /> - -
- -