From 7cace3201f32b2719255643f05978e059e2cf44f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 18:00:30 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.6.1 → v0.6.3](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.1...v0.6.3) - [github.com/pre-commit/mirrors-prettier: v2.7.1 → v4.0.0-alpha.8](https://github.com/pre-commit/mirrors-prettier/compare/v2.7.1...v4.0.0-alpha.8) - [github.com/pre-commit/mirrors-eslint: v8.1.0 → v9.9.1](https://github.com/pre-commit/mirrors-eslint/compare/v8.1.0...v9.9.1) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 26205be2..9dfc6575 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,18 +14,18 @@ repos: - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit # keep in sync with .github/workflows/ruff.yml - rev: 'v0.6.1' + rev: 'v0.6.3' hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - id: ruff-format - repo: https://github.com/pre-commit/mirrors-prettier - rev: 'v2.7.1' + rev: 'v4.0.0-alpha.8' hooks: - id: prettier types_or: [markdown, css, scss, javascript, json, yaml, ts, tsx] - repo: https://github.com/pre-commit/mirrors-eslint - rev: 'v8.1.0' + rev: 'v9.9.1' hooks: - id: eslint additional_dependencies: From 346bbe5bec8f435e4ee4727162081d613a9672ac Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 18:01:01 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .github/workflows/nigthly-tests.yml | 56 ++-- .github/workflows/publish.yml | 114 ++++---- .github/workflows/ruff.yml | 30 +- .github/workflows/test.yml | 258 +++++++++--------- docs/concept/content-paths.md | 4 +- docs/concept/segments.md | 6 +- docs/concept/translatable-fields-autogen.md | 16 +- docs/how-to/integrations/pontoon.md | 14 +- docs/tutorial/2-configure-wagtail-localize.md | 4 +- docs/tutorial/3-content.md | 8 +- docs/tutorial/4-templates.md | 4 +- .../components/DocumentChooser/index.tsx | 2 +- .../components/SnippetChooser/index.tsx | 10 +- .../common/components/Tabs/index.tsx | 2 +- .../static_src/component_form/main.tsx | 2 +- .../components/TranslationEditor/footer.tsx | 20 +- .../components/TranslationEditor/index.tsx | 8 +- .../TranslationEditor/legacy-footer.tsx | 12 +- .../components/TranslationEditor/reducer.ts | 6 +- .../components/TranslationEditor/segments.tsx | 40 +-- .../components/TranslationEditor/toolbox.tsx | 2 +- wagtail_localize/static_src/editor/main.tsx | 6 +- wagtail_localize/test/fixtures/test_user.json | 34 +-- webpack.config.js | 10 +- 24 files changed, 334 insertions(+), 334 deletions(-) diff --git a/.github/workflows/nigthly-tests.yml b/.github/workflows/nigthly-tests.yml index b159ce7d..26d5a1cc 100644 --- a/.github/workflows/nigthly-tests.yml +++ b/.github/workflows/nigthly-tests.yml @@ -1,36 +1,36 @@ name: Nightly Wagtail test on: - schedule: - # Nightly at 4am. - - cron: '0 4 * * *' + schedule: + # Nightly at 4am. + - cron: '0 4 * * *' - workflow_dispatch: + workflow_dispatch: jobs: - nightly-test: - # Cannot check the existence of secrets, so limiting to repository name to prevent all forks to run nightly. - # See: https://github.com/actions/runner/issues/520 - if: ${{ github.repository == 'wagtail/wagtail-localize' }} - runs-on: ubuntu-latest + nightly-test: + # Cannot check the existence of secrets, so limiting to repository name to prevent all forks to run nightly. + # See: https://github.com/actions/runner/issues/520 + if: ${{ github.repository == 'wagtail/wagtail-localize' }} + runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - name: Install dependencies - run: | - python -m pip install --upgrade pip tox - - name: Test - id: test - continue-on-error: true - run: tox -e wagtailmain + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Install dependencies + run: | + python -m pip install --upgrade pip tox + - name: Test + id: test + continue-on-error: true + run: tox -e wagtailmain - - name: Send Slack notification on failure - if: steps.test.outcome == 'failure' - run: | - python .github/scripts/report_nightly_build_failure.py - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + - name: Send Slack notification on failure + if: steps.test.outcome == 'failure' + run: | + python .github/scripts/report_nightly_build_failure.py + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6c6e85c7..30029ae6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,62 +1,62 @@ name: Publish to PyPI on: - release: - types: [published] + release: + types: [published] jobs: - build: - runs-on: ubuntu-latest - permissions: - contents: read # to fetch code (actions/checkout) - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set up Node - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - - - name: Install Node dependencies - run: npm ci - - - name: Build static files - run: ./node_modules/.bin/webpack --mode production - - - uses: actions/setup-python@v5 - with: - python-version: '3.12' - cache: 'pip' - cache-dependency-path: '**/pyproject.toml' - - - name: ⬇️ Install build dependencies - run: | - python -m pip install -U flit - - - name: 🏗️ Build - run: python -m flit build - - - uses: actions/upload-artifact@v4 - with: - path: ./dist - - # https://docs.pypi.org/trusted-publishers/using-a-publisher/ - pypi-publish: - needs: build - environment: 'publish' - - name: ⬆️ Upload release to PyPI - runs-on: ubuntu-latest - permissions: - # Mandatory for trusted publishing - id-token: write - steps: - - uses: actions/download-artifact@v4 - - - name: 🚀 Publish package distributions to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - packages-dir: artifact/ - print-hash: true + build: + runs-on: ubuntu-latest + permissions: + contents: read # to fetch code (actions/checkout) + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + + - name: Install Node dependencies + run: npm ci + + - name: Build static files + run: ./node_modules/.bin/webpack --mode production + + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + cache: 'pip' + cache-dependency-path: '**/pyproject.toml' + + - name: ⬇️ Install build dependencies + run: | + python -m pip install -U flit + + - name: 🏗️ Build + run: python -m flit build + + - uses: actions/upload-artifact@v4 + with: + path: ./dist + + # https://docs.pypi.org/trusted-publishers/using-a-publisher/ + pypi-publish: + needs: build + environment: 'publish' + + name: ⬆️ Upload release to PyPI + runs-on: ubuntu-latest + permissions: + # Mandatory for trusted publishing + id-token: write + steps: + - uses: actions/download-artifact@v4 + + - name: 🚀 Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages-dir: artifact/ + print-hash: true diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index 2888cad8..443efcc6 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -1,23 +1,23 @@ name: Ruff on: - push: - branches: - - main - - 'stable/**' - pull_request: - branches: [main] + push: + branches: + - main + - 'stable/**' + pull_request: + branches: [main] jobs: - ruff: - runs-on: ubuntu-latest + ruff: + runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 + steps: + - uses: actions/checkout@v4 - # keep in sync with .pre-commit-config.yaml - - run: python -Im pip install --user ruff==0.6.1 + # keep in sync with .pre-commit-config.yaml + - run: python -Im pip install --user ruff==0.6.1 - - name: Run ruff - working-directory: . - run: ruff check --output-format=github wagtail_localize + - name: Run ruff + working-directory: . + run: ruff check --output-format=github wagtail_localize diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1180beb2..947d3f5c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,140 +1,140 @@ name: Localize CI on: - push: - branches: - - main - - 'stable/**' - pull_request: + push: + branches: + - main + - 'stable/**' + pull_request: concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true permissions: - contents: read # to fetch code (actions/checkout) + contents: read # to fetch code (actions/checkout) env: - FORCE_COLOR: '1' # Make tools pretty. - TOX_TESTENV_PASSENV: FORCE_COLOR - PIP_DISABLE_PIP_VERSION_CHECK: '1' - PIP_NO_PYTHON_VERSION_WARNING: '1' - PYTHON_LATEST: '3.11' + FORCE_COLOR: '1' # Make tools pretty. + TOX_TESTENV_PASSENV: FORCE_COLOR + PIP_DISABLE_PIP_VERSION_CHECK: '1' + PIP_NO_PYTHON_VERSION_WARNING: '1' + PYTHON_LATEST: '3.11' jobs: - test-sqlite: - runs-on: ubuntu-latest - strategy: - matrix: - python: ['3.10', '3.11', '3.12'] - database: ['sqlite'] - - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python }} - - name: Install dependencies - run: | - python -m pip install --upgrade uv - python -m uv pip install setuptools wheel tox tox-gh-actions - - name: Test with tox - run: tox -q -- -v1 - env: - DATABASE: sqlite - - name: ⬆️ Upload coverage data - uses: actions/upload-artifact@v4 - with: - name: coverage-data-${{ matrix.python }}-sqlite - path: .coverage.* - if-no-files-found: ignore - retention-days: 1 - - test-postgres: - runs-on: ubuntu-latest - strategy: - matrix: - python: ['3.9', '3.10', '3.11', '3.12'] - database: ['postgres'] - - services: - postgres: - image: bitnami/postgresql:15 - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: postgres - POSTGRESQL_PASSWORD: postgres - POSTGRESQL_FSYNC: 'off' - POSTGRESQL_DATA_DIR: /dev/shm/pgdata - ports: - - 5432:5432 - options: --health-cmd "pg_isready -d postgres -U postgres -p 5432" --health-interval 10s --health-timeout 5s --health-retries 5 - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Python - id: setup-python - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python }} - - - name: Install dependencies - id: install-dependencies - run: | - python -Im pip install --upgrade uv - python -Im uv pip install setuptools wheel tox tox-gh-actions - - name: Test with tox - run: tox -q -- -v1 - env: - DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres - DATABASE: postgres - - name: ⬆️ Upload coverage data - uses: actions/upload-artifact@v4 - with: - name: coverage-data-${{ matrix.python }}-postgres - path: .coverage.* - if-no-files-found: ignore - retention-days: 1 - - coverage: - runs-on: ubuntu-latest - needs: - - test-sqlite - - test-postgres - strategy: - matrix: - python: ['3.12'] - - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - # Use latest Python, so it understands all syntax. - python-version: ${{env.PYTHON_LATEST}} - - - name: Install dependencies - run: | - python -Im pip install --upgrade uv - python -Im uv pip install "coverage>=7.0,<8.0" - - - name: ⬇️ Download coverage data - uses: actions/download-artifact@v4 - with: - pattern: coverage-data-* - merge-multiple: true - - - name: + Combine coverage - run: | - python -Im coverage combine - python -Im coverage html --skip-covered --skip-empty - python -Im coverage report - - - name: 'Upload coverage to Codecov' - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} - fail_ci_if_error: true + test-sqlite: + runs-on: ubuntu-latest + strategy: + matrix: + python: ['3.10', '3.11', '3.12'] + database: ['sqlite'] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + - name: Install dependencies + run: | + python -m pip install --upgrade uv + python -m uv pip install setuptools wheel tox tox-gh-actions + - name: Test with tox + run: tox -q -- -v1 + env: + DATABASE: sqlite + - name: ⬆️ Upload coverage data + uses: actions/upload-artifact@v4 + with: + name: coverage-data-${{ matrix.python }}-sqlite + path: .coverage.* + if-no-files-found: ignore + retention-days: 1 + + test-postgres: + runs-on: ubuntu-latest + strategy: + matrix: + python: ['3.9', '3.10', '3.11', '3.12'] + database: ['postgres'] + + services: + postgres: + image: bitnami/postgresql:15 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + POSTGRESQL_PASSWORD: postgres + POSTGRESQL_FSYNC: 'off' + POSTGRESQL_DATA_DIR: /dev/shm/pgdata + ports: + - 5432:5432 + options: --health-cmd "pg_isready -d postgres -U postgres -p 5432" --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + id: setup-python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + + - name: Install dependencies + id: install-dependencies + run: | + python -Im pip install --upgrade uv + python -Im uv pip install setuptools wheel tox tox-gh-actions + - name: Test with tox + run: tox -q -- -v1 + env: + DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres + DATABASE: postgres + - name: ⬆️ Upload coverage data + uses: actions/upload-artifact@v4 + with: + name: coverage-data-${{ matrix.python }}-postgres + path: .coverage.* + if-no-files-found: ignore + retention-days: 1 + + coverage: + runs-on: ubuntu-latest + needs: + - test-sqlite + - test-postgres + strategy: + matrix: + python: ['3.12'] + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + # Use latest Python, so it understands all syntax. + python-version: ${{env.PYTHON_LATEST}} + + - name: Install dependencies + run: | + python -Im pip install --upgrade uv + python -Im uv pip install "coverage>=7.0,<8.0" + + - name: ⬇️ Download coverage data + uses: actions/download-artifact@v4 + with: + pattern: coverage-data-* + merge-multiple: true + + - name: + Combine coverage + run: | + python -Im coverage combine + python -Im coverage html --skip-covered --skip-empty + python -Im coverage report + + - name: 'Upload coverage to Codecov' + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: true diff --git a/docs/concept/content-paths.md b/docs/concept/content-paths.md index e4261580..d6c72698 100644 --- a/docs/concept/content-paths.md +++ b/docs/concept/content-paths.md @@ -2,8 +2,8 @@ Content paths are used by Wagtail Localize to reference a field within a page or snippet. They are needed for two purposes: -- They are generated whenever Wagtail Localize extracts segments from an object to provide an address for inserting the translations later on -- They are used in the `msgctxt` field in PO files to allow the same source string to be translated differently for different fields +- They are generated whenever Wagtail Localize extracts segments from an object to provide an address for inserting the translations later on +- They are used in the `msgctxt` field in PO files to allow the same source string to be translated differently for different fields This document describes how content paths are generated. diff --git a/docs/concept/segments.md b/docs/concept/segments.md index 48818d47..fa4adc10 100644 --- a/docs/concept/segments.md +++ b/docs/concept/segments.md @@ -52,9 +52,9 @@ string segments need to be inserted. If you combined the above template with the following string segments: -- `The Heading` -- `A paragraph with some Bold text` -- `A list item` +- `The Heading` +- `A paragraph with some Bold text` +- `A list item` This would produce the following rich text value: diff --git a/docs/concept/translatable-fields-autogen.md b/docs/concept/translatable-fields-autogen.md index 4f7033a2..b589d9ca 100644 --- a/docs/concept/translatable-fields-autogen.md +++ b/docs/concept/translatable-fields-autogen.md @@ -13,18 +13,18 @@ The first step is to loop through all fields defined on the model. This is done The following are excluded: -- Auto fields, such as `id` -- Any field with `editable=False` -- `ManyToManyField` and `ParentalKey` -- Parent link fields, such as `page_ptr` -- Inherited `MP_Node` fields named `path`, `depth`, and `numchild` -- Inherited `Page` fields named `go_live_at`, `expire_at`, `first_published_at`, `content_type` and `owner` +- Auto fields, such as `id` +- Any field with `editable=False` +- `ManyToManyField` and `ParentalKey` +- Parent link fields, such as `page_ptr` +- Inherited `MP_Node` fields named `path`, `depth`, and `numchild` +- Inherited `Page` fields named `go_live_at`, `expire_at`, `first_published_at`, `content_type` and `owner` Next, we look at text fields. All text fields (including `RichTextField` and `StreamField`) are set to translatable, except for the following which are set to synchronised: -- `URLField` and `EmailField` -- `CharField` with `choices` set +- `URLField` and `EmailField` +- `CharField` with `choices` set `ForeignKey` and `OneToOneField` fields are set to translatable if the referenced model inherits from `TranslatableMixin`, otherwise they are set to synchronised. diff --git a/docs/how-to/integrations/pontoon.md b/docs/how-to/integrations/pontoon.md index 6eab45dc..2a698cae 100644 --- a/docs/how-to/integrations/pontoon.md +++ b/docs/how-to/integrations/pontoon.md @@ -26,8 +26,8 @@ It will prompt for a password, leave that blank. Now you need to create a git repo for the PO files to live in. You can use any host for this you like as long as it: -- Is accessible over the network from both Pontoon and Wagtail -- Supports deploy keys that can write to the repository (Both GitHub and Gitlab support this) +- Is accessible over the network from both Pontoon and Wagtail +- Supports deploy keys that can write to the repository (Both GitHub and Gitlab support this) Note that you do not need to make your repo public as both Pontoon and Wagtail Localize can authenticate using a deploy key. @@ -72,13 +72,13 @@ use it. There are instructions on how to do this on Heroku at the end of this gu On your Wagtail server, you'll need to set two Django settings: -- `WAGTAILLOCALIZE_GIT_URL` should be set to the SSH git clone URL of your repository +- `WAGTAILLOCALIZE_GIT_URL` should be set to the SSH git clone URL of your repository -- `WAGTAILLOCALIZE_GIT_CLONE_DIR` needs to be set to a directory that Wagtail Localize can clone the git repository into. +- `WAGTAILLOCALIZE_GIT_CLONE_DIR` needs to be set to a directory that Wagtail Localize can clone the git repository into. - If you're running on an ephermeral file system (such as on Heroku), this can be pointed to a temporary directory. - Wagtail Localize will re-clone the repository if it's ever deleted. It keeps track of what the previous `HEAD` - commit was in the database so it will not lose track of anything if a deletion occurs. + If you're running on an ephermeral file system (such as on Heroku), this can be pointed to a temporary directory. + Wagtail Localize will re-clone the repository if it's ever deleted. It keeps track of what the previous `HEAD` + commit was in the database so it will not lose track of anything if a deletion occurs. For example: diff --git a/docs/tutorial/2-configure-wagtail-localize.md b/docs/tutorial/2-configure-wagtail-localize.md index 588ada18..6ca819d8 100644 --- a/docs/tutorial/2-configure-wagtail-localize.md +++ b/docs/tutorial/2-configure-wagtail-localize.md @@ -87,8 +87,8 @@ Open `tutorial/urls.py` in your text editor. You'll see that there are two group The patterns that need to be made translatable are: -- `path('search/', search_views.search, name='search'),` -- `path("", include(wagtail_urls)),` +- `path('search/', search_views.search, name='search'),` +- `path("", include(wagtail_urls)),` To make these translatable, move the 'search/' pattern into the second block, above the `wagtail_urls` pattern. Then, replace the square brakets around that block with diff --git a/docs/tutorial/3-content.md b/docs/tutorial/3-content.md index 10830520..11efb78c 100644 --- a/docs/tutorial/3-content.md +++ b/docs/tutorial/3-content.md @@ -113,10 +113,10 @@ the following screenshot, and publish it. Then navigate to the new blog index page, click "Add child page" then click "Blog post page". Fill it in how you like, but make sure that you cover the following: -- Upload an image and add it to the "Image" field -- Create a "Blog Category" and select it in the "Category" field -- Add an item in the paragraph block, with some text and a couple of list items. Use some inline formatting - (bold, italic, etc) and add a link +- Upload an image and add it to the "Image" field +- Create a "Blog Category" and select it in the "Category" field +- Add an item in the paragraph block, with some text and a couple of list items. Use some inline formatting + (bold, italic, etc) and add a link ![Blog post page being edited in Wagtail](../assets/tutorial/wagtail-edit-source.png) diff --git a/docs/tutorial/4-templates.md b/docs/tutorial/4-templates.md index ff242761..1bb56703 100644 --- a/docs/tutorial/4-templates.md +++ b/docs/tutorial/4-templates.md @@ -87,7 +87,7 @@ the currently active language which can be found with `Locale.get_active()`. To implement this, open up `search/views.py` in your favourite editor, then modify the following lines: -- Change the import line `from wagtail.models import Page` to `from wagtail.models import Page, Locale` -- Change the query `Page.objects.live().search(search_query)` to `Page.objects.live().filter(locale=Locale.get_active()).search(search_query)` +- Change the import line `from wagtail.models import Page` to `from wagtail.models import Page, Locale` +- Change the query `Page.objects.live().search(search_query)` to `Page.objects.live().filter(locale=Locale.get_active()).search(search_query)` Refresh the search page in the browser, the results should now be filtered. diff --git a/wagtail_localize/static_src/common/components/DocumentChooser/index.tsx b/wagtail_localize/static_src/common/components/DocumentChooser/index.tsx index 5b7f883b..86e20ff7 100644 --- a/wagtail_localize/static_src/common/components/DocumentChooser/index.tsx +++ b/wagtail_localize/static_src/common/components/DocumentChooser/index.tsx @@ -16,7 +16,7 @@ const DocumentChooser: FunctionComponent = ({ documentId, }) => { const [documentInfo, setDocumentInfo] = React.useState( - null + null, ); React.useEffect(() => { diff --git a/wagtail_localize/static_src/common/components/SnippetChooser/index.tsx b/wagtail_localize/static_src/common/components/SnippetChooser/index.tsx index 6a67564d..2abf2246 100644 --- a/wagtail_localize/static_src/common/components/SnippetChooser/index.tsx +++ b/wagtail_localize/static_src/common/components/SnippetChooser/index.tsx @@ -24,7 +24,7 @@ const SnippetChooser: FunctionComponent = ({ snippetId, }) => { const [snippetInfo, setSnippetInfo] = React.useState( - null + null, ); React.useEffect(() => { @@ -32,7 +32,7 @@ const SnippetChooser: FunctionComponent = ({ if (snippetId) { fetch( - `${adminBaseUrl}localize/api/snippets/${snippetModel.app_label}/${snippetModel.model_name}/${snippetId}/` + `${adminBaseUrl}localize/api/snippets/${snippetModel.app_label}/${snippetModel.model_name}/${snippetId}/`, ) .then((response) => response.json()) .then(setSnippetInfo); @@ -58,7 +58,7 @@ const SnippetChooser: FunctionComponent = ({ > {gettext('Edit this %s').replace( '%s', - snippetModel.verbose_name + snippetModel.verbose_name, )} @@ -70,7 +70,7 @@ const SnippetChooser: FunctionComponent = ({

{gettext('Fetching %s information...').replace( '%s', - snippetModel.verbose_name + snippetModel.verbose_name, )}

); @@ -86,7 +86,7 @@ const SnippetChooser: FunctionComponent = ({ > {gettext('Choose a %s').replace( '%s', - snippetModel.verbose_name + snippetModel.verbose_name, )} diff --git a/wagtail_localize/static_src/common/components/Tabs/index.tsx b/wagtail_localize/static_src/common/components/Tabs/index.tsx index 9f0de3dc..cac6e633 100644 --- a/wagtail_localize/static_src/common/components/Tabs/index.tsx +++ b/wagtail_localize/static_src/common/components/Tabs/index.tsx @@ -22,7 +22,7 @@ export const Tabs: FunctionComponent = ({ tabs, children }) => {
{tabs.map((tab) => { const onClick = ( - e: React.MouseEvent + e: React.MouseEvent, ) => { e.preventDefault(); setCurrentTab(tab.slug); diff --git a/wagtail_localize/static_src/component_form/main.tsx b/wagtail_localize/static_src/component_form/main.tsx index 78bc5793..f0acc105 100644 --- a/wagtail_localize/static_src/component_form/main.tsx +++ b/wagtail_localize/static_src/component_form/main.tsx @@ -11,7 +11,7 @@ document.addEventListener('DOMContentLoaded', () => { } const enableInput = componentForm.querySelector( - '.component-form__fieldname-enabled input' + '.component-form__fieldname-enabled input', ) as HTMLInputElement | null; if (enableInput) { enableInput.checked = isChecked; diff --git a/wagtail_localize/static_src/editor/components/TranslationEditor/footer.tsx b/wagtail_localize/static_src/editor/components/TranslationEditor/footer.tsx index 5649fb90..d523c3b4 100644 --- a/wagtail_localize/static_src/editor/components/TranslationEditor/footer.tsx +++ b/wagtail_localize/static_src/editor/components/TranslationEditor/footer.tsx @@ -25,7 +25,7 @@ const EditorFooter: FunctionComponent = ({ data-controller="w-progress" data-action="w-progress#activate" data-w-progress-active-value={gettext( - 'Stopping Synced translation' + 'Stopping Synced translation', )} > @@ -47,7 +47,7 @@ const EditorFooter: FunctionComponent = ({ data-controller="w-progress" data-action="w-progress#activate" data-w-progress-active-value={gettext( - 'Converting to alias page' + 'Converting to alias page', )} > @@ -55,7 +55,7 @@ const EditorFooter: FunctionComponent = ({ {gettext('Convert to alias page')} - + , ); } @@ -64,7 +64,7 @@ const EditorFooter: FunctionComponent = ({ {gettext('Delete')} - + , ); } @@ -84,13 +84,13 @@ const EditorFooter: FunctionComponent = ({ data-controller="w-progress" data-action="w-progress#activate" data-w-progress-active-value={gettext( - 'Applying editor lock' + 'Applying editor lock', )} > {gettext('Lock')} - + , ); } @@ -110,13 +110,13 @@ const EditorFooter: FunctionComponent = ({ data-controller="w-progress" data-action="w-progress#activate" data-w-progress-active-value={gettext( - 'Removing editor lock' + 'Removing editor lock', )} > {gettext('Unlock')} - + , ); } @@ -125,7 +125,7 @@ const EditorFooter: FunctionComponent = ({ {gettext('Unpublish')} - + , ); } @@ -158,7 +158,7 @@ const EditorFooter: FunctionComponent = ({ {gettext('Publish in ') + locale.displayName} - + , ); } diff --git a/wagtail_localize/static_src/editor/components/TranslationEditor/index.tsx b/wagtail_localize/static_src/editor/components/TranslationEditor/index.tsx index b4beec77..a6e62cd5 100644 --- a/wagtail_localize/static_src/editor/components/TranslationEditor/index.tsx +++ b/wagtail_localize/static_src/editor/components/TranslationEditor/index.tsx @@ -231,7 +231,7 @@ const TranslationEditor: FunctionComponent = (props) => { if (state.editingSegments.size > 0) { const onUnload = (event: BeforeUnloadEvent) => { const confirmationMessage = gettext( - 'There are unsaved segments. Please save or cancel them before leaving.' + 'There are unsaved segments. Please save or cancel them before leaving.', ); // eslint-disable-next-line no-param-reassign @@ -249,17 +249,17 @@ const TranslationEditor: FunctionComponent = (props) => { const tabData = props.tabs .map((tab) => { const segments = props.segments.filter( - (segment) => segment.location.tab == tab.slug + (segment) => segment.location.tab == tab.slug, ); const translations = segments.map( (segment) => segment.type == 'string' && - state.stringTranslations.get(segment.id) + state.stringTranslations.get(segment.id), ); return { numErrors: translations.filter( - (translation) => translation && translation.isErrored + (translation) => translation && translation.isErrored, ).length, segments, ...tab, diff --git a/wagtail_localize/static_src/editor/components/TranslationEditor/legacy-footer.tsx b/wagtail_localize/static_src/editor/components/TranslationEditor/legacy-footer.tsx index cf344058..70ce5c76 100644 --- a/wagtail_localize/static_src/editor/components/TranslationEditor/legacy-footer.tsx +++ b/wagtail_localize/static_src/editor/components/TranslationEditor/legacy-footer.tsx @@ -43,7 +43,7 @@ const EditorFooter: FunctionComponent = ({ {gettext('Convert to alias page')} - + , ); } @@ -52,7 +52,7 @@ const EditorFooter: FunctionComponent = ({ {gettext('Delete')} - + , ); } @@ -74,7 +74,7 @@ const EditorFooter: FunctionComponent = ({ {gettext('Lock')} - + , ); } @@ -96,7 +96,7 @@ const EditorFooter: FunctionComponent = ({ {gettext('Unlock')} - + , ); } @@ -105,7 +105,7 @@ const EditorFooter: FunctionComponent = ({ {gettext('Unpublish')} - + , ); } @@ -136,7 +136,7 @@ const EditorFooter: FunctionComponent = ({ {gettext('Publish in ') + locale.displayName} - + , ); } diff --git a/wagtail_localize/static_src/editor/components/TranslationEditor/reducer.ts b/wagtail_localize/static_src/editor/components/TranslationEditor/reducer.ts index d7cc3729..e682a190 100644 --- a/wagtail_localize/static_src/editor/components/TranslationEditor/reducer.ts +++ b/wagtail_localize/static_src/editor/components/TranslationEditor/reducer.ts @@ -143,7 +143,7 @@ export function reducer(state: EditorState, action: EditorAction) { isSaving: false, isErrored: true, comment: gettext('Server error'), - }) + }), ); } break; @@ -168,7 +168,7 @@ export function reducer(state: EditorState, action: EditorAction) { action.segmentId, Object.assign({}, override, { isSaving: true, - }) + }), ); } break; @@ -194,7 +194,7 @@ export function reducer(state: EditorState, action: EditorAction) { action.segmentId, Object.assign({}, override, { isSaving: false, - }) + }), ); } break; diff --git a/wagtail_localize/static_src/editor/components/TranslationEditor/segments.tsx b/wagtail_localize/static_src/editor/components/TranslationEditor/segments.tsx index c5efa681..66cc04b1 100644 --- a/wagtail_localize/static_src/editor/components/TranslationEditor/segments.tsx +++ b/wagtail_localize/static_src/editor/components/TranslationEditor/segments.tsx @@ -40,7 +40,7 @@ function saveTranslation( segment: StringSegment, value: string, csrfToken: string, - dispatch: React.Dispatch + dispatch: React.Dispatch, ) { dispatch({ type: EDIT_STRING_TRANSLATION, @@ -108,7 +108,7 @@ function saveOverride( segment: SynchronisedValueSegment, value: any, csrfToken: string, - dispatch: React.Dispatch + dispatch: React.Dispatch, ) { dispatch({ type: EDIT_OVERRIDE, @@ -153,7 +153,7 @@ function saveOverride( function deleteOverride( segment: SynchronisedValueSegment, csrfToken: string, - dispatch: React.Dispatch + dispatch: React.Dispatch, ) { dispatch({ type: DELETE_OVERRIDE, @@ -416,7 +416,7 @@ const EditorStringSegment: FunctionComponent = ({ csrfToken, }) => { const [editingValue, setEditingValue] = React.useState( - (translation && translation.value) || '' + (translation && translation.value) || '', ); let comment = <>; @@ -501,7 +501,7 @@ const EditorStringSegment: FunctionComponent = ({ {translation ? gettext('Edit') : gettext('Translate')} - + , ); } @@ -584,7 +584,7 @@ const EditorSynchronisedValueSegment: FunctionComponent< <> {gettext('Uses %s version').replace( '%s', - sourceLocale.displayName + sourceLocale.displayName, )}{' '} @@ -594,7 +594,7 @@ const EditorSynchronisedValueSegment: FunctionComponent< const widget = segment.location.widget; if (widget.type == 'text') { const [editingValue, setEditingValue] = React.useState( - (override && override.value) || segment.value + (override && override.value) || segment.value, ); if (isEditing && !isLocked) { @@ -634,7 +634,7 @@ const EditorSynchronisedValueSegment: FunctionComponent< buttons.push( {gettext('Edit')} - + , ); } @@ -654,7 +654,7 @@ const EditorSynchronisedValueSegment: FunctionComponent< segment, responseData.id, csrfToken, - dispatch + dispatch, ); }, }, @@ -664,7 +664,7 @@ const EditorSynchronisedValueSegment: FunctionComponent< buttons.push( {gettext('Change page')} - + , ); } @@ -685,7 +685,7 @@ const EditorSynchronisedValueSegment: FunctionComponent< segment, responseData.id, csrfToken, - dispatch + dispatch, ); }, }, @@ -695,7 +695,7 @@ const EditorSynchronisedValueSegment: FunctionComponent< buttons.push( {gettext('Change image')} - + , ); } @@ -716,7 +716,7 @@ const EditorSynchronisedValueSegment: FunctionComponent< segment, responseData.id, csrfToken, - dispatch + dispatch, ); }, }, @@ -726,7 +726,7 @@ const EditorSynchronisedValueSegment: FunctionComponent< buttons.push( {gettext('Change document')} - + , ); } @@ -750,7 +750,7 @@ const EditorSynchronisedValueSegment: FunctionComponent< segment, responseData.id, csrfToken, - dispatch + dispatch, ); }, }, @@ -761,9 +761,9 @@ const EditorSynchronisedValueSegment: FunctionComponent< {gettext('Change %s').replace( '%s', - widget.snippet_model.verbose_name + widget.snippet_model.verbose_name, )} - + , ); } @@ -786,9 +786,9 @@ const EditorSynchronisedValueSegment: FunctionComponent< {gettext('Revert to %s version').replace( '%s', - sourceLocale.displayName + sourceLocale.displayName, )} - + , ); } @@ -991,7 +991,7 @@ const EditorSegmentList: FunctionComponent = ({ {segmentsRendered} ); - } + }, ); return {segmentRendered}; diff --git a/wagtail_localize/static_src/editor/components/TranslationEditor/toolbox.tsx b/wagtail_localize/static_src/editor/components/TranslationEditor/toolbox.tsx index 9397e137..67ebab2e 100644 --- a/wagtail_localize/static_src/editor/components/TranslationEditor/toolbox.tsx +++ b/wagtail_localize/static_src/editor/components/TranslationEditor/toolbox.tsx @@ -95,7 +95,7 @@ const EditorToolbox: FunctionComponent = ({

{gettext( - 'Upload translated PO file to submit translations' + 'Upload translated PO file to submit translations', )}