ToolJet/server/data-migrations/1765313746517-BackfillDefaultComponentStyles.ts
Shaurya Sharma 67b4722acc
Style enhancements (#14627)
* feat: add migration for app_history table and update entity structure

* feat: refactor AppHistory module imports and add new services and guards

* Fix: Vertical page menu minor enhancements

* feat: add stream history feature and update related permissions and constants

* feat: add AppStateRepository to AppHistoryModule imports and providers

* feat: add NameResolverRepository to AppHistoryModule imports and providers

* feat: implement NameResolverRepository and NameResolverService for component and page name resolution

* feat: remove QueueHistoryIntegrationService and update AppHistoryModule to reflect changes

* feat: update AppHistoryModule and AppHistoryRepository with new methods and refactor imports

* feat: refactor AppHistoryModule and related services to streamline name resolution and history capture

* feat: add AppStateRepository and HistoryQueueProcessor, refactor AppStateAggregatorService to utilize repository methods

* feat: rename methods in AppStateRepository for clarity and update AppStateAggregatorService to reflect changes

* feat: refactor history capture logic to use synchronous execution and improve error handling across services

* Fix: Mobile view page menu UI enhancements

* feat: enhance ability guards and repository methods for app history validation

* Update submodule references

* Migrate to shadcn sidebar component

* plan

* Fix: Components not getting pasted at correct position if user scrolled and pasted inside container components

* Fix: Group components not getting pasted at correct position horizontally inside container components

* POC for removing overlap prevention logic if not enough space present,  incase user clicks somewhere to respect click position

* Update frontend/src/AppBuilder/AppCanvas/Container.jsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* modules and customGroup

* feat: enhance AppHistoryModule registration with isMainImport flag

* feat: update settings method to queue history capture after successful update

* chore: update subproject commit reference in frontend/ee

* feat: add function to delete app history for structural migrations

* Refactor imports and enhance code organization across multiple files

- Updated import paths to reflect the new directory structure in TooljetDatabase and AppBuilder components.
- Consolidated utility functions in appUtils.js, removing redundant code and improving readability.
- Enhanced error handling and state management in dataQueriesStore and resolverStore.
- Added Bundle Analyzer plugin to webpack configuration for better performance insights.
- Improved chunking strategy in webpack to optimize loading of libraries and components.
- Refactored ErrorBoundary imports to maintain consistency across UI components.

* feat: enhance UI components with new icons and styling adjustments

* refactor: remove unused components and icons from QueryManager

- Deleted QueryManagerHeader component and its associated logic.
- Removed SuccessNotificationInputs component and its functionality.
- Eliminated Transformation component and related code.
- Deleted BreadcrumbsIcon, CreateIcon, PreviewIcon, RenameIcon, RunIcon, and ToggleQueryEditorIcon.
- Updated imports in appUtils.js to reflect new icon paths.

* Refactor editorHelpers and utils: Remove unused functions and imports, streamline background update logic, and adjust state handling. Comment out or delete handleReferenceTransactions and related logic in various stores to simplify data flow and improve maintainability.

* Refactor queryPanelStore and storeHelper by commenting out unused imports and code. This cleanup improves code readability and maintainability.

* builder roggle

* role name

* revert: Reverted the lazy loading changes

* revert: Reverted the changes on App & AppRoute

* Fix: Inside side effects, get the correct canvas element, disable page scrolling and reposition modal container when modal is opened

* Fix: Use the side effects when modal is opened and closed

* Update submodule references

* struct

* fix

* sus

* field fix

* create app btn

* fix: Corrected zustandDevTools enabled option logic

* module visible

* refactor: update license validation logic and improve feature access checks

* app module

* feat: Added modules support for public apps

* update ee-frontend submodule ref

* Enhance: Vertical page menu default styles

* refactor: migrate license management to a new store and update related components

* workflow enabled

* feat: integrate license validation into Viewer component and remove deprecated license check

* Revert "feat: integrate license validation into Viewer component and remove deprecated license check"

This reverts commit b4b5218079.

* Revert "refactor: migrate license management to a new store and update related components"

This reverts commit cd2936bb12.

* chore: update subproject commit reference in server/ee

* chore: merged with lts

* chore: moved components from Editor to AppBuilder folder

* chore: cleaned up the appbuilder imports

* refactor: update license checks in PageSettingsTab components to use appPermissionPages feature flag

* refactor: update license checks in QueryCardMenu and Inspector components to use appPermission feature flags

* chore: update subproject commit reference

* update submodule ref

* Enhance: Horizontal page menu default styles

* fix: Global search for multiselect column

* Fix: More button on pages overflow is getting cropped and remove unnecessary calculations related to it

* Refactor page menu code

* Integrate shadcn navigation menu component for horizontal page menu

* Update submodule ref

* refactor: add license checks for page, query, and component permissions in app-permissions feature configuration

* chore: update subproject commit reference in server/ee to latest version

* chore: update subproject commit reference in server/ee to latest version

* update submodule ref

* Fix: Minimum width of the popup in horizontal page menu

* Fixed UI issues

* Removed commented code

* Removed wrapper and unwanted code

* Fix: Minor page menu bugs inside Editor

* Fix: popover overflow issue and other minor bugs

* Remove unnecessary package.json change

* chore: fix import path casing for RealTimeEditor

* Fix: Grid resizing issue and component selector overflow

* Fix: Increased transition duration to 200

* Removed the classname change

* Fix: Scrollbar visible in viewer in vertical page menu

* Fix: Remove arbitrary variant chains since not supported in Tailwind v3 to fix animations in horizontal page menu

* chore: update subproject commits for frontend and server

* Refactored code

* Update ee-frontend submodule reference

* Removed leading and trailing icon width

* chore: update subproject commit reference in server/ee to latest version

* Refactor page menu styling part to make it reusable for mobile view

* Integrate Shacn Sidebar component in page menu for mobile view

* Update submodule references

* fix: merge issues and minor bugs

* Update frontend/src/_styles/pages-sidebar.scss

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* update submodule ref

* fixed: custom validation working for dropdown inside the listview

* update submodule references

* Fix: Broken app logo in editor incase app logo url is incorrect

* Fix: Default styles

* update submodule reference

* Fix: Implement changes for legacy modal as well

* Fix: Change state logic to dom manipulation logic on canvas scroll to prevent unnecessary re-renders

* Fix: Change default border color to cc-Border/weak

* Fix: Remove max width on overflow menu in horizontal page menu and prevent right sidebar to open on toggling page groups in overflow menu

* Fix: Box shadow should only be visible for horizontal page menu only when canvas is scrolled and not on top

* Update submodule references

* Feat: Add support for icon in modal trigger

* Update frontend/src/AppBuilder/Widgets/ModalV2/ModalV2.jsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update frontend/src/AppBuilder/Widgets/ModalV2/helpers/stylesFactory.js

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* chore: update subproject commit reference in frontend/ee

* refactor: clean up controller methods and remove unused streamHistory and getEvents methods

* chore: update subproject commit reference in frontend/ee

* update submodule references

* Fix: Scrollbar behaviour in vertical page menu

* Fix: Group closes on selecting a page on vertical page menu

* Remove log

* fix: update BoundedBox widget styles and fix class names; add datepicker styles

* feat: add permission checks based on selected data source scope in QueryCard component

* Border weak added to containers

* Added border weak to table and code editor

* fix: enhance error handling in streamHistoryUpdates and update subproject reference

* fix: fixed the bug on app history in capturing the query deletion

* fix: Fixed unknown component issue while adding an event in query and pages. Added resolveEntityName method to handle entity name resolution for components, queries, and pages

* feat: Add captureSettingsUpdateHistory method to log app version settings updates

* fix: pageSettings were not properly restored while restoring the app history and version change

* fix: Enhance settings update history capture with action type differentiation

* feat: Optimize layout updates by batching component layout changes

* fix: Prevent redundant canvasHeight updates when the value is unchanged

* Changed default size of container based components to that of form

* Organized accordians for ModalV2, Form and Container and added divider colors

* Added container styles to some components

* style: Update padding and spacing in app history styles for improved layout

* chore: Update subproject commit reference for frontend/ee

* chore: Update subproject commit references for frontend and server

* Fix: update hover effect for app name display in EditAppName component

* Fix: remove redundant darkMode prop from FormField component

* fix: add !important to primary color for rc-slider track and handle

* feat: implement batching for form component updates and layout changes

* feat: enhance form component handling with batching and parent ID extraction

* Update submodule references

* Fix: Page of type app or url gets converted to default page on app import

* feat: enhance page cloning with history capture functionality

* fix: optimize parent change detection to prevent unnecessary batch updates during drag operations

* feat: optimize query saving logic to skip unnecessary updates for name changes

* Fix: Group not selected after nested page selection until hovered in horizontal menu

* Revert "Revert "[refactor]: Fix leftsidebar on opening disturbing the scroll""

This reverts commit d712c47f9c.

* Fix: Navigation menu disappears when view switched between desktop and mobile view in editor

* update ee-server submodule ref

* update submodule references

* Fix: Icon alignment issue

* Reverted default sizes for calendar & kanban and made header title center aligned for form and container

* feat: implement bulk creation of event handlers and optimize component event handling

* chore: update subproject commit reference in frontend/ee

* Revert "POC for removing overlap prevention logic if not enough space present,  incase user clicks somewhere to respect click position"

This reverts commit 8aec525e9a.

* feat: disable client overlay in webpack configuration

* update the submodule refs

* update submodule refs

* update submodule reference for server/ee

* refactor: rename `defaultDataSources` prop to `staticDataSources` in `DataSourceSelect` component.

* update submodule refs

* feat: add AppHistoryStreamService to manage app history streaming

* update submodule reference for server/ee

* update submodule reference for server/ee

* fix: add null check in onHideSideEffects and remove unnecessary !important from sidebar height

* fix: update submodule reference for server/ee

* Fix: Page menu header overflowing the canvas on app mode change

* Fix: Canvas width changes on opening left and right sidebar when page menu is side aligned and opened

* Fix: App logo and name getting wrapped to new line in mobile view

* chore: update submodule to latest commit ddc3418f for server/ee

* Fix: Released app mobile view

* Fix: sidebar footer getting cutoff in mobile view

* chore: update submodules for frontend and server to latest commits

* Update ee-server submodule reference

* Update ee-server submodule reference

* Button accordian renamed to trigger button

* Migrations added

* Migrations added

* Submodule update

* Comments resolved

---------

Co-authored-by: Kavin Venkatachalam <kavin.saratha@gmail.com>
Co-authored-by: devanshu052000 <devanshu.rastogi05@gmail.com>
Co-authored-by: Rudhra Deep Biswas <rudra21ultra@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: manishkushare <kushare.manish9@gmail.com>
Co-authored-by: Johnson Cherian <johnsonc.dev@gmail.com>
Co-authored-by: Nishidh Jain <nishidhjain909@gmail.com>
Co-authored-by: Kavin Venkatachalam <50441969+kavinvenkatachalam@users.noreply.github.com>
2025-12-19 14:31:49 +05:30

79 lines
2.3 KiB
TypeScript

import { MigrationInterface, QueryRunner } from 'typeorm';
const DEFAULT_STYLES: Record<string, Record<string, { value: string | number }>> = {
CodeEditor: {
backgroundColor: { value: 'var(--cc-surface1-surface)' },
borderColor: { value: 'var(--cc-weak-border)' },
},
PDF: {
borderRadius: { value: 0 },
borderColor: { value: '#00000000' },
},
Calendar: {
borderRadius: { value: 0 },
borderColor: { value: '#00000000' },
},
Chat: {
borderRadius: { value: 6 },
},
CustomComponent: {
boxShadow: { value: '0px 0px 0px 0px #00000040' },
borderColor: { value: 'var(--cc-default-border)' },
},
};
export class BackfillDefaultComponentStyles1765313746517 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const batchSize = 100;
let offset = 0;
let hasMoreData = true;
while (hasMoreData) {
// Fetch components in batches using raw SQL
const components = await queryRunner.query(
`SELECT id, properties, styles, general_properties, general_styles, type
FROM components
WHERE type = ANY($1)
ORDER BY "created_at" ASC
LIMIT $2 OFFSET $3`,
[Object.keys(DEFAULT_STYLES), batchSize, offset]
);
if (components.length === 0) {
hasMoreData = false;
break;
}
await this.processUpdates(queryRunner, components);
offset += batchSize;
}
}
private applyDefaultStyles(styles: Record<string, any>, componentType: string): void {
const defaults = DEFAULT_STYLES[componentType];
if (!defaults) return;
for (const [key, value] of Object.entries(defaults)) {
if (!styles[key]) {
styles[key] = value;
}
}
}
private async processUpdates(queryRunner: QueryRunner, components: any[]) {
for (const component of components) {
const styles = component.styles ? { ...component.styles } : {};
const componentType = component.type;
this.applyDefaultStyles(styles, componentType);
// Updating component using raw query
await queryRunner.query(`UPDATE components SET styles = $1 WHERE id = $2`, [
JSON.stringify(styles),
component.id,
]);
}
}
public async down(queryRunner: QueryRunner): Promise<void> {}
}