goauthentik / authentik

The authentication glue you need.
https://goauthentik.io
Other
13.67k stars 916 forks source link

web/admin: bugfix: dual select initialization revision #12051

Open kensternberg-authentik opened 6 days ago

kensternberg-authentik commented 6 days ago

web/bugfix/dual-select-full-options

What

How

In the previous iteration, each dual select controller gets a provider and a selector; the latter keeps the keys of all the objects a specific instance may have, and marks those objects as “selected” when they appear in the dual-selects “selected” panel.

In order to distinguish between “selected on the existing instance” and “selected by the user,” the selector only runs at construction time, creating a unified “selected” list; this is standard and allows for a uniform experience of adding and deleting items. Unfortunately, this means that the “selected” items, because their displays are crafted bespoke, are only chosen from those available at construction. If there are selected items later in the paginated collection, they will not be marked as selected.

This defeats the purpose of having a paginated multi-select!

The correct way to do this is to retrieve every item for which the key is passed to the selector and use the same algorithm to craft the views in both windows.

For every instance of Dual Select with dynamic selection, the provider and selector have been put in a separate file (usually suffixed as a *FormHelper.ts file); the algorithm by which an item is crafted for use by DualSelect has been broken out into a small function (usually named *toSelect()). The provider works as before. The selector takes every instance key passed to it and runs a Promise.allSettled(...*Retrieve({ uuid: instanceId })) on them, mapping them onto the selected collection using the same *toSelect(), so they resemble the possibilities in every way.

Lessons

This exercise emphasizes just how much sheer repetition the Django REST API creates on the client side. Every Helper file is a copy-pasta of a sibling, with only a few minor changes:

There are 19 *FormHelper files, and each one is 50 lines long. That’s 950 lines of code. Of those 950 lines of code, 874 of those lines are complete duplicates of those in the other FormHelper files. Only 76 lines are unique.

This language really needs macros. That, or I need to seriously level up my Typescript and figure out how to make this whole thing a lot smarter.

netlify[bot] commented 6 days ago

Deploy Preview for authentik-docs ready!

Name Link
Latest commit e89585eb6465c0921387bc092a6626a9de0c80a1
Latest deploy log https://app.netlify.com/sites/authentik-docs/deploys/6740b16a7cd7950008e55b9e
Deploy Preview https://deploy-preview-12051--authentik-docs.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] commented 6 days ago

Deploy Preview for authentik-storybook ready!

Name Link
Latest commit e89585eb6465c0921387bc092a6626a9de0c80a1
Latest deploy log https://app.netlify.com/sites/authentik-storybook/deploys/6740b16ae760e0000765e1d9
Deploy Preview https://deploy-preview-12051--authentik-storybook.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

codecov[bot] commented 6 days ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 92.68%. Comparing base (785403d) to head (e89585e).

:white_check_mark: All tests successful. No failed tests found.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #12051 +/- ## ========================================== - Coverage 92.68% 92.68% -0.01% ========================================== Files 761 761 Lines 38025 38025 ========================================== - Hits 35244 35243 -1 - Misses 2781 2782 +1 ``` | [Flag](https://app.codecov.io/gh/goauthentik/authentik/pull/12051/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goauthentik) | Coverage Δ | | |---|---|---| | [e2e](https://app.codecov.io/gh/goauthentik/authentik/pull/12051/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goauthentik) | `49.21% <ø> (-0.01%)` | :arrow_down: | | [integration](https://app.codecov.io/gh/goauthentik/authentik/pull/12051/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goauthentik) | `24.83% <ø> (ø)` | | | [unit](https://app.codecov.io/gh/goauthentik/authentik/pull/12051/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goauthentik) | `90.21% <ø> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goauthentik#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.


🚨 Try these New Features:

github-actions[bot] commented 6 days ago

authentik PR Installation instructions

Instructions for docker-compose Add the following block to your `.env` file: ```shell AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server AUTHENTIK_TAG=gh-e89585eb6465c0921387bc092a6626a9de0c80a1 AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s ``` For arm64, use these values: ```shell AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server AUTHENTIK_TAG=gh-e89585eb6465c0921387bc092a6626a9de0c80a1-arm64 AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s ``` Afterwards, run the upgrade commands from the latest release notes.
Instructions for Kubernetes Add the following block to your `values.yml` file: ```yaml authentik: outposts: container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s global: image: repository: ghcr.io/goauthentik/dev-server tag: gh-e89585eb6465c0921387bc092a6626a9de0c80a1 ``` For arm64, use these values: ```yaml authentik: outposts: container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s global: image: repository: ghcr.io/goauthentik/dev-server tag: gh-e89585eb6465c0921387bc092a6626a9de0c80a1-arm64 ``` Afterwards, run the upgrade commands from the latest release notes.