From ebe01530e64ab1db9dfd80f13256c6869e497683 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Mon, 19 Feb 2024 23:47:57 +0000 Subject: [PATCH 001/175] Bump CI/pre-commit versions (#6522) * bump CI versions and run new autofixes * fix reqs --- .pre-commit-config.yaml | 6 +++--- InvenTree/InvenTree/templatetags/inventree_extras.py | 2 +- InvenTree/order/api.py | 2 +- InvenTree/plugin/builtin/labels/label_sheet.py | 2 +- ci/check_js_templates.py | 6 +++--- requirements.txt | 9 ++------- tasks.py | 2 +- 7 files changed, 12 insertions(+), 17 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8c359ac93d..e13ca21401 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ repos: - id: check-yaml - id: mixed-line-ending - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.2.1 + rev: v0.2.2 hooks: - id: ruff-format args: [--preview] @@ -26,7 +26,7 @@ repos: --preview ] - repo: https://github.com/jazzband/pip-tools - rev: 7.3.0 + rev: 7.4.0 hooks: - id: pip-compile name: pip-compile requirements-dev.in @@ -60,7 +60,7 @@ repos: - "prettier@^2.4.1" - "@trivago/prettier-plugin-sort-imports" - repo: https://github.com/pre-commit/mirrors-eslint - rev: "v9.0.0-alpha.2" + rev: "v9.0.0-beta.0" hooks: - id: eslint additional_dependencies: diff --git a/InvenTree/InvenTree/templatetags/inventree_extras.py b/InvenTree/InvenTree/templatetags/inventree_extras.py index 3c37fce6e6..c7bb9f4162 100644 --- a/InvenTree/InvenTree/templatetags/inventree_extras.py +++ b/InvenTree/InvenTree/templatetags/inventree_extras.py @@ -421,7 +421,7 @@ def progress_bar(val, max_val, *args, **kwargs): style_tags.append(f'max-width: {max_width};') html = f""" -
+
{val} / {max_val}
diff --git a/InvenTree/order/api.py b/InvenTree/order/api.py index db62dfb6ea..e10e74cf81 100644 --- a/InvenTree/order/api.py +++ b/InvenTree/order/api.py @@ -1482,7 +1482,7 @@ class OrderCalendarExport(ICalFeed): def item_guid(self, item): """Return globally unique UID for event.""" - return f'po_{item.pk}_{item.reference.replace(" ","-")}@{self.instance_url}' + return f'po_{item.pk}_{item.reference.replace(" ", "-")}@{self.instance_url}' def item_link(self, item): """Set the item link.""" diff --git a/InvenTree/plugin/builtin/labels/label_sheet.py b/InvenTree/plugin/builtin/labels/label_sheet.py index 1e0007d1c9..5f6ca952e4 100644 --- a/InvenTree/plugin/builtin/labels/label_sheet.py +++ b/InvenTree/plugin/builtin/labels/label_sheet.py @@ -261,7 +261,7 @@ class InvenTreeLabelSheetPlugin(LabelPrintingMixin, SettingsMixin, InvenTreePlug }} .label-sheet-cell {{ - border: {"1px solid #000;" if border else "0mm;"} + border: {'1px solid #000;' if border else '0mm;'} width: {label_width}mm; height: {label_height}mm; padding: 0mm; diff --git a/ci/check_js_templates.py b/ci/check_js_templates.py index bcb91ce81a..df5e302605 100644 --- a/ci/check_js_templates.py +++ b/ci/check_js_templates.py @@ -35,7 +35,7 @@ def check_invalid_tag(data): for result in results: err_count += 1 - print(f' - Error on line {idx+1}: %{{{result[0]}') + print(f' - Error on line {idx + 1}: %{{{result[0]}') return err_count @@ -62,7 +62,7 @@ def check_prohibited_tags(data): for idx, line in enumerate(data): for tag in re.findall(pattern, line): if tag not in allowed_tags: - print(f" > Line {idx+1} contains prohibited template tag '{tag}'") + print(f" > Line {idx + 1} contains prohibited template tag '{tag}'") err_count += 1 return err_count @@ -94,7 +94,7 @@ for filename in pathlib.Path(js_dynamic_dir).rglob('*.js'): if tag in line: err_count += 1 - print(f" > Error on line {idx+1}: Prohibited tag '{tag}' found") + print(f" > Error on line {idx + 1}: Prohibited tag '{tag}' found") if errors > 0: diff --git a/requirements.txt b/requirements.txt index a0e209616e..6f4611a816 100644 --- a/requirements.txt +++ b/requirements.txt @@ -22,9 +22,7 @@ backoff==2.2.1 # opentelemetry-exporter-otlp-proto-grpc # opentelemetry-exporter-otlp-proto-http bleach[css]==6.1.0 - # via - # bleach - # django-markdownify + # via django-markdownify brotli==1.1.0 # via fonttools certifi==2024.2.2 @@ -175,9 +173,7 @@ et-xmlfile==1.1.0 feedparser==6.0.11 # via -r requirements.in fonttools[woff]==4.47.2 - # via - # fonttools - # weasyprint + # via weasyprint googleapis-common-protos==1.62.0 # via # opentelemetry-exporter-otlp-proto-grpc @@ -304,7 +300,6 @@ pyjwt[crypto]==2.8.0 # via # django-allauth # djangorestframework-simplejwt - # pyjwt pyphen==0.14.0 # via weasyprint pypng==0.20220715.0 diff --git a/tasks.py b/tasks.py index 53a71b3344..4e474db561 100644 --- a/tasks.py +++ b/tasks.py @@ -1165,7 +1165,7 @@ Then try continuing by running: invoke frontend-download --file Date: Tue, 20 Feb 2024 01:32:19 +0100 Subject: [PATCH 002/175] Make Category tree theme-aware (#6523) --- .../src/components/nav/PartCategoryTree.tsx | 65 ++++++++++++++++++- 1 file changed, 62 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/components/nav/PartCategoryTree.tsx b/src/frontend/src/components/nav/PartCategoryTree.tsx index fecaba7f19..6fe2bd8bd4 100644 --- a/src/frontend/src/components/nav/PartCategoryTree.tsx +++ b/src/frontend/src/components/nav/PartCategoryTree.tsx @@ -1,6 +1,13 @@ import { t } from '@lingui/macro'; -import { Drawer, Group, LoadingOverlay, Stack, Text } from '@mantine/core'; -import { ReactTree } from '@naisutech/react-tree'; +import { + Drawer, + Group, + LoadingOverlay, + Stack, + Text, + useMantineTheme +} from '@mantine/core'; +import { ReactTree, ThemeSettings } from '@naisutech/react-tree'; import { IconSitemap } from '@tabler/icons-react'; import { useQuery } from '@tanstack/react-query'; import { useNavigate } from 'react-router-dom'; @@ -37,7 +44,7 @@ export function PartCategoryTree({ }) ) .catch((error) => { - console.error('Error fetching part categpry tree:', error); + console.error('Error fetching part category tree:', error); return error; }), refetchOnMount: true @@ -59,6 +66,56 @@ export function PartCategoryTree({ ); } + const mantineTheme = useMantineTheme(); + const currentTheme = + mantineTheme.colorScheme === 'dark' + ? mantineTheme.colorScheme + : mantineTheme.primaryColor; + + const themes: ThemeSettings = { + dark: { + text: { + ...mantineTheme.fn.fontStyles() + }, + nodes: { + height: '2.5rem', + folder: { + selectedBgColor: mantineTheme.colors[currentTheme][4], + hoverBgColor: mantineTheme.colors[currentTheme][6] + }, + leaf: { + selectedBgColor: mantineTheme.colors[currentTheme][4], + hoverBgColor: mantineTheme.colors[currentTheme][6] + }, + icons: { + folderColor: mantineTheme.colors[currentTheme][3], + leafColor: mantineTheme.colors[currentTheme][3] + } + } + }, + light: { + text: { + ...mantineTheme.fn.fontStyles() + }, + nodes: { + height: '2.5rem', + folder: { + selectedBgColor: mantineTheme.colors[currentTheme][4], + hoverBgColor: mantineTheme.colors[currentTheme][2] + }, + leaf: { + bgColor: 'initial', + selectedBgColor: mantineTheme.colors[currentTheme][4], + hoverBgColor: mantineTheme.colors[currentTheme][2] + }, + icons: { + folderColor: mantineTheme.colors[currentTheme][8], + leafColor: mantineTheme.colors[currentTheme][6] + } + } + } + }; + return ( From 3eb1914f1ef4ff6bd9b2a18b5561e6bd01e47088 Mon Sep 17 00:00:00 2001 From: Lavissa Date: Tue, 20 Feb 2024 01:33:56 +0100 Subject: [PATCH 003/175] Make API form Select Field theme-aware (#6521) --- .../forms/fields/RelatedModelField.tsx | 59 ++++++++++++++++++- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/components/forms/fields/RelatedModelField.tsx b/src/frontend/src/components/forms/fields/RelatedModelField.tsx index ece395346b..3bdf4513e6 100644 --- a/src/frontend/src/components/forms/fields/RelatedModelField.tsx +++ b/src/frontend/src/components/forms/fields/RelatedModelField.tsx @@ -1,5 +1,5 @@ import { t } from '@lingui/macro'; -import { Input } from '@mantine/core'; +import { Input, useMantineTheme } from '@mantine/core'; import { useDebouncedValue } from '@mantine/hooks'; import { useId } from '@mantine/hooks'; import { useQuery } from '@tanstack/react-query'; @@ -209,8 +209,54 @@ export function RelatedModelField({ [pk, data] ); + // Field doesn't follow Mantine theming + // Define color theme to pass to field based on Mantine theme + const th = useMantineTheme(); + let colors: any; + if (th.colorScheme === 'dark') { + colors = { + neutral0: th.colors[th.colorScheme][6], + neutral5: th.colors[th.colorScheme][4], + neutral10: th.colors[th.colorScheme][4], + neutral20: th.colors[th.colorScheme][4], + neutral30: th.colors[th.colorScheme][3], + neutral40: th.colors[th.colorScheme][2], + neutral50: th.colors[th.colorScheme][1], + neutral60: th.colors[th.colorScheme][0], + neutral70: th.colors[th.colorScheme][0], + neutral80: th.colors[th.colorScheme][0], + neutral90: th.colors[th.colorScheme][0], + primary: th.colors[th.primaryColor][7], + primary25: th.colors[th.primaryColor][6], + primary50: th.colors[th.primaryColor][5], + primary75: th.colors[th.primaryColor][4] + }; + } else { + colors = { + neutral0: th.white, + neutral5: th.fn.darken(th.white, 0.05), + neutral10: th.fn.darken(th.white, 0.1), + neutral20: th.fn.darken(th.white, 0.2), + neutral30: th.fn.darken(th.white, 0.3), + neutral40: th.fn.darken(th.white, 0.4), + neutral50: th.fn.darken(th.white, 0.5), + neutral60: th.fn.darken(th.white, 0.6), + neutral70: th.fn.darken(th.white, 0.7), + neutral80: th.fn.darken(th.white, 0.8), + neutral90: th.fn.darken(th.white, 0.9), + primary: th.colors[th.primaryColor][7], + primary25: th.colors[th.primaryColor][4], + primary50: th.colors[th.primaryColor][5], + primary75: th.colors[th.primaryColor][6] + }; + } + return ( - +