From 6700a4625d7754d9fdbe3a6a8e168977b116fc94 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Wed, 8 May 2024 09:42:57 +0200 Subject: [PATCH] WIP [PUI] Migrate to Mantine v7 (#7028) * bump deps * upgrade all deps * adapt theme context * add vanilla extract * add basic theme * reformat global state * fix imports * fix spotlight * update args * adapt arg names * fix more arg renames * fix italic * switch sx to style * fix types * fix theme refs * misc fixes * misc fixes * fix type * fix selects * misc fixes * bug fix * update to new style * set text args * fix spotlight * dumb spotlight down * change ActionIcons back to default * fix name * fix test * adjust test to new spotlight * package fix * fix new code to v7 * fix building * fix group aligment * remove unneeded imports * add new type * import cleanups * add notification style * move context to loadable * reorder contexts * make test less flaky * fix missing theming * fix color schema switcher * increase timeouts * update package refs * add missing style for datatables * fix missing nesting * organize imports * move language context around * make sure license keys are unique * add keys to badges * fix import * fix missing keys * fix missing key issue in badge section * update packages * fix new code to v7 style * dummy change * fix up test * fix btn style * fix merge issues * remove placeholders * fix color schema usage * fix usage of ColorScheme * fix style issues * fix test * fix choice field to fit stricter validation * make test more reproducible * wait for dash before proceeding * bump deps * add missing style * do loops * fix css * change carousel sizing * fix merge for v7 * fix image ratio * Revert "bump deps" This reverts commit 91cdae5a3ee21dc9dd753460d8ebf2d745d5418e. * fix userstate to ensure it always renders * await dashboard loading before resuming wiht wuick login * fix spotlight and remove testing changes * Catch API error * Update breadcrumb list * Update panel icon * Cleanup notification drawer * Some more tweaks * Fix for notification count indicator * Fix stack prop * fix type error * fix double timeout key * use div instead of text --------- Co-authored-by: Oliver Walters --- src/frontend/package.json | 66 +- src/frontend/playwright.config.ts | 1 - .../src/components/buttons/ActionButton.tsx | 5 +- .../src/components/buttons/ButtonMenu.tsx | 2 +- .../src/components/buttons/CopyButton.tsx | 2 +- .../src/components/buttons/EditButton.tsx | 6 +- .../src/components/buttons/SSOButton.tsx | 2 +- .../src/components/buttons/ScanButton.tsx | 1 + .../src/components/buttons/SplitButton.css.ts | 19 + .../src/components/buttons/SplitButton.tsx | 23 +- .../components/buttons/SpotlightButton.tsx | 9 +- .../src/components/details/Details.tsx | 16 +- .../src/components/details/DetailsImage.tsx | 25 +- .../editors/TemplateEditor/TemplateEditor.tsx | 10 +- src/frontend/src/components/forms/ApiForm.tsx | 8 +- .../components/forms/AuthenticationForm.tsx | 10 +- .../src/components/forms/HostOptionsForm.tsx | 15 +- .../src/components/forms/InstanceOptions.tsx | 2 +- .../components/forms/fields/ApiFormField.tsx | 5 +- .../components/forms/fields/ChoiceField.tsx | 8 +- .../src/components/forms/fields/DateField.tsx | 2 +- .../forms/fields/NestedObjectField.tsx | 4 +- .../forms/fields/RelatedModelField.tsx | 73 +- .../src/components/images/ApiImage.tsx | 13 +- .../src/components/images/Thumbnail.tsx | 15 +- .../src/components/items/ActionDropdown.tsx | 2 +- .../src/components/items/AttachmentLink.tsx | 2 +- .../src/components/items/ColorToggle.tsx | 15 +- .../src/components/items/DashboardItem.tsx | 10 +- .../src/components/items/DocTooltip.tsx | 4 +- .../items/GettingStartedCarousel.css.ts | 30 + .../items/GettingStartedCarousel.tsx | 48 +- .../src/components/items/InfoItem.tsx | 2 +- .../src/components/items/InvenTreeLogo.tsx | 2 +- .../src/components/items/LanguageSelect.tsx | 4 +- .../src/components/items/LanguageToggle.tsx | 8 +- .../src/components/items/MenuLinks.tsx | 4 +- .../src/components/items/Placeholder.tsx | 4 +- .../src/components/items/ProgressBar.tsx | 4 +- .../src/components/items/StylishText.tsx | 3 +- .../components/modals/AboutInvenTreeModal.tsx | 4 +- .../src/components/modals/LicenseModal.tsx | 6 +- .../src/components/modals/QrCodeModal.tsx | 10 +- .../src/components/modals/ServerInfoModal.tsx | 2 +- .../src/components/nav/BreadcrumbList.tsx | 10 +- .../src/components/nav/DetailDrawer.css.ts | 6 + .../src/components/nav/DetailDrawer.tsx | 25 +- src/frontend/src/components/nav/Footer.tsx | 5 +- src/frontend/src/components/nav/Header.tsx | 47 +- src/frontend/src/components/nav/Layout.tsx | 52 +- src/frontend/src/components/nav/MainMenu.tsx | 43 +- .../src/components/nav/NavHoverMenu.tsx | 25 +- .../src/components/nav/NavigationDrawer.tsx | 5 +- .../src/components/nav/NotificationDrawer.tsx | 115 +- .../src/components/nav/PageDetail.tsx | 26 +- .../src/components/nav/PanelGroup.tsx | 14 +- .../src/components/nav/PartCategoryTree.tsx | 55 +- .../src/components/nav/SearchDrawer.tsx | 12 +- .../src/components/nav/SettingsHeader.tsx | 2 +- .../src/components/nav/StockLocationTree.tsx | 8 +- .../src/components/render/Instance.tsx | 6 +- .../src/components/settings/SettingItem.tsx | 15 +- .../src/components/settings/SettingList.tsx | 6 +- .../src/components/widgets/FeedbackWidget.tsx | 17 +- .../components/widgets/WidgetLayout.css.ts | 16 + .../src/components/widgets/WidgetLayout.tsx | 29 +- src/frontend/src/contexts/BaseContext.tsx | 5 +- src/frontend/src/contexts/ThemeContext.tsx | 45 +- src/frontend/src/contexts/colorSchema.tsx | 67 + src/frontend/src/defaults/actions.tsx | 53 +- src/frontend/src/defaults/formatters.tsx | 3 + src/frontend/src/forms/BuildForms.tsx | 2 +- src/frontend/src/forms/StockForms.tsx | 2 +- src/frontend/src/functions/forms.tsx | 2 +- src/frontend/src/functions/loading.tsx | 17 +- src/frontend/src/globalStyle.tsx | 184 --- src/frontend/src/hooks/UseForm.tsx | 7 +- src/frontend/src/hooks/UseModal.tsx | 5 +- src/frontend/src/main.css.ts | 180 +++ src/frontend/src/main.tsx | 5 + src/frontend/src/pages/Auth/Logged-In.tsx | 2 +- src/frontend/src/pages/Auth/Login.tsx | 5 +- src/frontend/src/pages/Auth/Logout.tsx | 2 +- src/frontend/src/pages/Index/Playground.tsx | 20 +- src/frontend/src/pages/Index/Scan.tsx | 105 +- .../AccountSettings/AccountDetailPanel.tsx | 6 +- .../AccountSettings/SecurityContent.tsx | 8 +- .../AccountSettings/UserThemePanel.tsx | 20 +- .../Index/Settings/AdminCenter/Index.tsx | 6 +- .../AdminCenter/MachineManagementPanel.tsx | 6 +- .../AdminCenter/UserManagementPanel.tsx | 4 +- .../pages/Index/Settings/SystemSettings.tsx | 2 +- .../src/pages/Index/Settings/UserSettings.tsx | 2 +- src/frontend/src/pages/build/BuildDetail.tsx | 2 +- .../src/pages/company/CompanyDetail.tsx | 5 +- .../pages/company/ManufacturerPartDetail.tsx | 3 +- .../src/pages/company/SupplierPartDetail.tsx | 3 +- .../src/pages/part/CategoryDetail.tsx | 2 +- src/frontend/src/pages/part/PartDetail.tsx | 4 +- .../src/pages/part/PartPricingPanel.tsx | 2 +- .../pages/part/pricing/BomPricingPanel.tsx | 8 +- .../part/pricing/PricingOverviewPanel.tsx | 14 +- .../src/pages/part/pricing/PricingPanel.tsx | 6 +- .../part/pricing/PurchaseHistoryPanel.tsx | 4 +- .../part/pricing/VariantPricingPanel.tsx | 2 +- .../pages/purchasing/PurchaseOrderDetail.tsx | 3 +- .../src/pages/sales/ReturnOrderDetail.tsx | 2 +- .../src/pages/sales/SalesOrderDetail.tsx | 3 +- src/frontend/src/states/LocalState.tsx | 11 +- src/frontend/src/tables/Column.tsx | 2 +- src/frontend/src/tables/ColumnRenderers.tsx | 4 +- src/frontend/src/tables/ColumnSelect.tsx | 2 +- src/frontend/src/tables/DownloadAction.tsx | 2 +- src/frontend/src/tables/Filter.tsx | 2 +- .../src/tables/FilterSelectDrawer.tsx | 14 +- src/frontend/src/tables/InvenTreeTable.tsx | 24 +- src/frontend/src/tables/RowActions.tsx | 2 +- src/frontend/src/tables/Search.tsx | 2 +- src/frontend/src/tables/TableHoverCard.tsx | 8 +- src/frontend/src/tables/bom/BomTable.tsx | 16 +- src/frontend/src/tables/bom/UsedInTable.tsx | 4 +- .../src/tables/build/BuildLineTable.tsx | 12 +- .../src/tables/build/BuildOrderTable.tsx | 2 + .../src/tables/build/BuildOutputTable.tsx | 6 +- .../src/tables/company/CompanyTable.tsx | 2 +- .../src/tables/general/AttachmentTable.tsx | 8 +- .../src/tables/machine/MachineListTable.tsx | 38 +- .../src/tables/machine/MachineTypeTable.tsx | 38 +- .../src/tables/part/ParametricPartTable.tsx | 4 +- .../tables/part/PartCategoryTemplateTable.tsx | 2 +- .../src/tables/part/PartParameterTable.tsx | 6 +- src/frontend/src/tables/part/PartTable.tsx | 4 +- .../src/tables/part/PartTestTemplateTable.tsx | 8 +- .../src/tables/part/PartThumbTable.tsx | 2 +- .../src/tables/part/RelatedPartTable.tsx | 4 +- .../src/tables/plugin/PluginListTable.tsx | 34 +- .../purchasing/SupplierPriceBreakTable.tsx | 4 +- .../tables/settings/ScheduledTasksTable.tsx | 2 +- .../src/tables/settings/TemplateTable.tsx | 4 +- .../src/tables/stock/StockItemTable.tsx | 4 +- .../tables/stock/StockItemTestResultTable.tsx | 14 +- .../src/tables/stock/StockLocationTable.tsx | 2 + src/frontend/src/theme.ts | 5 + src/frontend/src/views/MainView.tsx | 1 + src/frontend/src/views/MobileAppView.tsx | 2 +- src/frontend/tests/login.ts | 4 +- src/frontend/tests/modals.spec.ts | 12 +- src/frontend/tests/pages/pui_index.spec.ts | 4 +- src/frontend/tests/pui_command.spec.ts | 12 +- src/frontend/tests/pui_general.spec.ts | 5 +- src/frontend/tests/pui_stock.spec.ts | 1 + src/frontend/vite.config.ts | 2 + src/frontend/yarn.lock | 1278 ++++++++++------- 153 files changed, 1936 insertions(+), 1556 deletions(-) create mode 100644 src/frontend/src/components/buttons/SplitButton.css.ts create mode 100644 src/frontend/src/components/items/GettingStartedCarousel.css.ts create mode 100644 src/frontend/src/components/nav/DetailDrawer.css.ts create mode 100644 src/frontend/src/components/widgets/WidgetLayout.css.ts create mode 100644 src/frontend/src/contexts/colorSchema.tsx delete mode 100644 src/frontend/src/globalStyle.tsx create mode 100644 src/frontend/src/main.css.ts create mode 100644 src/frontend/src/theme.ts diff --git a/src/frontend/package.json b/src/frontend/package.json index 9d9e755234..ccea297ca0 100644 --- a/src/frontend/package.json +++ b/src/frontend/package.json @@ -11,66 +11,78 @@ "compile": "lingui compile --typescript" }, "dependencies": { + "@codemirror/autocomplete": ">=6.0.0", "@codemirror/lang-liquid": "^6.2.1", + "@codemirror/language": ">=6.0.0", + "@codemirror/lint": ">=6.0.0", + "@codemirror/search": ">=6.0.0", + "@codemirror/state": "^6.0.0", + "@codemirror/theme-one-dark": ">=6.0.0", + "@codemirror/view": ">=6.0.0", "@emotion/react": "^11.11.4", "@fortawesome/fontawesome-svg-core": "^6.5.2", "@fortawesome/free-regular-svg-icons": "^6.5.2", "@fortawesome/free-solid-svg-icons": "^6.5.2", "@fortawesome/react-fontawesome": "^0.2.0", - "@lingui/core": "^4.7.1", + "@lingui/core": "^4.10.0", "@lingui/react": "^4.10.0", - "@mantine/carousel": "<7", - "@mantine/core": "<7", - "@mantine/dates": "<7", - "@mantine/dropzone": "<7", - "@mantine/form": "<8", - "@mantine/hooks": "<7", - "@mantine/modals": "<7", - "@mantine/notifications": "<7", - "@mantine/spotlight": "<7", + "@mantine/carousel": "^7.8.0", + "@mantine/core": "^7.8.0", + "@mantine/dates": "^7.8.0", + "@mantine/dropzone": "^7.8.0", + "@mantine/form": "^7.8.0", + "@mantine/hooks": "^7.8.0", + "@mantine/modals": "^7.8.0", + "@mantine/notifications": "^7.8.0", + "@mantine/spotlight": "^7.8.0", + "@mantine/vanilla-extract": "^7.8.0", "@naisutech/react-tree": "^3.1.0", - "@sentry/react": "^7.109.0", - "@tabler/icons-react": "^3.1.0", - "@tanstack/react-query": "^5.28.14", + "@sentry/react": "^7.110.0", + "@tabler/icons-react": "^3.2.0", + "@tanstack/react-query": "^5.29.2", "@uiw/codemirror-theme-vscode": "^4.21.25", "@uiw/react-codemirror": "^4.21.25", "@uiw/react-split": "^5.9.3", - "axios": "^1.6.7", + "@vanilla-extract/css": "^1.14.2", + "axios": "^1.6.8", + "clsx": "^2.1.0", + "codemirror": ">=6.0.0", "dayjs": "^1.11.10", "easymde": "^2.18.0", "embla-carousel-react": "^8.0.2", "html5-qrcode": "^2.3.8", - "mantine-datatable": "<7", + "mantine-datatable": "^7.8.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-grid-layout": "^1.4.4", "react-hook-form": "^7.51.3", "react-is": "^18.2.0", - "react-router-dom": "^6.22.1", + "react-router-dom": "^6.22.3", "react-select": "^5.8.0", "react-simplemde-editor": "^5.2.0", "recharts": "^2.12.4", - "styled-components": "^5.3.6", - "zustand": "^4.5.1" + "styled-components": "^6.1.8", + "zustand": "^4.5.2" }, "devDependencies": { - "@babel/core": "^7.23.9", - "@babel/preset-react": "^7.23.3", - "@babel/preset-typescript": "^7.23.3", - "@lingui/cli": "^4.7.2", + "@babel/core": "^7.24.4", + "@babel/preset-react": "^7.24.1", + "@babel/preset-typescript": "^7.24.1", + "@lingui/cli": "^4.10.0", "@lingui/macro": "^4.10.0", "@playwright/test": "^1.43.1", - "@types/node": "^20.12.3", - "@types/react": "^18.2.74", - "@types/react-dom": "^18.2.23", + "@types/node": "^20.12.7", + "@types/react": "^18.2.79", + "@types/react-dom": "^18.2.25", "@types/react-grid-layout": "^1.3.5", "@types/react-router-dom": "^5.3.3", + "@vanilla-extract/vite-plugin": "^4.0.7", "@vitejs/plugin-react": "^4.2.1", "babel-plugin-macros": "^3.1.0", "nyc": "^15.1.0", "rollup-plugin-license": "^3.3.1", - "typescript": "^5.3.3", - "vite": "^5.2.7", + "typescript": "^5.4.5", + "vite": "^5.2.8", "vite-plugin-babel-macros": "^1.0.6", "vite-plugin-istanbul": "^6.0.0" } diff --git a/src/frontend/playwright.config.ts b/src/frontend/playwright.config.ts index fb339d6c4b..f24b94d323 100644 --- a/src/frontend/playwright.config.ts +++ b/src/frontend/playwright.config.ts @@ -5,7 +5,6 @@ export default defineConfig({ fullyParallel: true, timeout: 60000, forbidOnly: !!process.env.CI, - timeout: 5 * 60 * 1000, retries: process.env.CI ? 1 : 0, workers: process.env.CI ? 2 : undefined, reporter: process.env.CI ? [['html', { open: 'never' }], ['github']] : 'list', diff --git a/src/frontend/src/components/buttons/ActionButton.tsx b/src/frontend/src/components/buttons/ActionButton.tsx index caa5bf1363..1a4eb08a31 100644 --- a/src/frontend/src/components/buttons/ActionButton.tsx +++ b/src/frontend/src/components/buttons/ActionButton.tsx @@ -1,5 +1,4 @@ -import { ActionIcon, Group, Tooltip } from '@mantine/core'; -import { FloatingPosition } from '@mantine/core/lib/Floating'; +import { ActionIcon, FloatingPosition, Group, Tooltip } from '@mantine/core'; import { ReactNode } from 'react'; import { notYetImplemented } from '../../functions/notifications'; @@ -41,7 +40,7 @@ export function ActionButton(props: ActionButtonProps) { onClick={props.onClick ?? notYetImplemented} variant={props.variant ?? 'light'} > - + {props.icon} diff --git a/src/frontend/src/components/buttons/ButtonMenu.tsx b/src/frontend/src/components/buttons/ButtonMenu.tsx index 47192ad20f..42feeb0718 100644 --- a/src/frontend/src/components/buttons/ButtonMenu.tsx +++ b/src/frontend/src/components/buttons/ButtonMenu.tsx @@ -18,7 +18,7 @@ export function ButtonMenu({ return ( - + {icon} diff --git a/src/frontend/src/components/buttons/CopyButton.tsx b/src/frontend/src/components/buttons/CopyButton.tsx index d1ebb8dacb..bf51eebd0b 100644 --- a/src/frontend/src/components/buttons/CopyButton.tsx +++ b/src/frontend/src/components/buttons/CopyButton.tsx @@ -17,7 +17,7 @@ export function CopyButton({ onClick={copy} title={t`Copy to clipboard`} variant="subtle" - compact + size="compact-md" > {label &&
 
} diff --git a/src/frontend/src/components/buttons/EditButton.tsx b/src/frontend/src/components/buttons/EditButton.tsx index 82a1cc02c2..a64aa41cc9 100644 --- a/src/frontend/src/components/buttons/EditButton.tsx +++ b/src/frontend/src/components/buttons/EditButton.tsx @@ -14,7 +14,11 @@ export function EditButton({ }) { saveIcon = saveIcon || ; return ( - setEditing()} disabled={disabled}> + setEditing()} + disabled={disabled} + variant="default" + > {editing ? saveIcon : } ); diff --git a/src/frontend/src/components/buttons/SSOButton.tsx b/src/frontend/src/components/buttons/SSOButton.tsx index 503f5dafd5..08f9fd44da 100644 --- a/src/frontend/src/components/buttons/SSOButton.tsx +++ b/src/frontend/src/components/buttons/SSOButton.tsx @@ -50,7 +50,7 @@ export function SsoButton({ provider }: { provider: Provider }) { return ( {values.length == 0 ? ( - + No scans yet! ) : ( - + {values.map((value, index) => (
{value}
))} diff --git a/src/frontend/src/components/modals/ServerInfoModal.tsx b/src/frontend/src/components/modals/ServerInfoModal.tsx index 572d7167b6..f74e4a6ec5 100644 --- a/src/frontend/src/components/modals/ServerInfoModal.tsx +++ b/src/frontend/src/components/modals/ServerInfoModal.tsx @@ -137,7 +137,7 @@ export function ServerInfoModal({ - +