-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
web: refactor the table renderer for legibility #7433
Conversation
This commit changes the way the root node of the web application shell is discovered by child components, such that the base class shared by both no longer results in a circular dependency between the two models. I've run this in isolation and have seen no failures of discovery; the identity token exists as soon as the Interface is constructed and is found by every item on the page.
* main: (57 commits) stages/email: Fix query parameters getting lost in Email links (#5376) core/rbac: fix missing field when removing perm, add delete from object page (#7226) website/integrations: grafana: add Helm and Terraform config examples (#7121) web: bump @types/codemirror from 5.60.11 to 5.60.12 in /web (#7223) translate: Updates for file web/xliff/en.xlf in zh_CN (#7224) translate: Updates for file web/xliff/en.xlf in zh-Hans (#7225) website/blogs: blog about sso tax (#7202) web: Application wizard v2 with tests (#7004) web: bump API Client version (#7220) core: bump goauthentik.io/api/v3 from 3.2023083.7 to 3.2023083.8 (#7221) providers/radius: TOTP MFA support (#7217) web: bump API Client version (#7218) stage/deny: add custom message (#7144) docs: update full-dev-setup docs (#7205) enterprise: bump license usage task frequency (#7215) web: bump the storybook group in /web with 5 updates (#7212) web: bump the sentry group in /web with 2 updates (#7211) Revert "web: Updates to the Context and Tasks libraries from lit. (#7168)" web: bump @types/codemirror from 5.60.10 to 5.60.11 in /web (#7209) web: bump @types/chart.js from 2.9.38 to 2.9.39 in /web (#7206) ...
* main: web: bump API Client version (#7246) sources/oauth: include default JWKS URLs for OAuth sources (#6992) sources/oauth: periodically update OAuth sources' OIDC configuration (#7245) website/blogs: Fix sso blog to remove 3rd reason (#7230) lifecycle: fix otp_merge migration again (#7244) web: bump core-js from 3.33.0 to 3.33.1 in /web (#7243) core: bump node from 20 to 21 (#7237) web: fix bad comment that was confusing lit-analyze (#7234) translate: Updates for file web/xliff/en.xlf in zh_CN (#7235) core: bump ruff from 0.1.0 to 0.1.1 (#7238) core: bump twilio from 8.9.1 to 8.10.0 (#7239) web: bump the storybook group in /web with 5 updates (#7240) web: bump the wdio group in /tests/wdio with 4 updates (#7241) translate: Updates for file web/xliff/en.xlf in zh-Hans (#7236) web: isolate clipboard handling (#7229)
This built... and then it didn't? Anyway, the current fix is to provide type information the AkInterface for the data that consumers require.
* main: core: bump pylint-django from 2.5.3 to 2.5.4 (#7255) core: bump goauthentik.io/api/v3 from 3.2023083.9 to 3.2023083.10 (#7256) web: bump the wdio group in /tests/wdio with 1 update (#7258) web: bump the eslint group in /tests/wdio with 1 update (#7257) sources/oauth: fix name clash (#7253) web: bump the eslint group in /web with 1 update (#7250) web: bump mermaid from 10.5.0 to 10.5.1 in /web (#7247) web: break circular dependency between AKElement & Interface. (#7165)
* main: (28 commits) web: fix typo in traefik name web/admin: disable wizard banner for now (#7294) web/admin: small fixes (#7292) core: Use branding_title in the end session page (#7282) web: bump pyright from 1.1.332 to 1.1.333 in /web (#7287) website: bump react-tooltip from 5.21.5 to 5.21.6 in /website (#7283) web: bump the sentry group in /web with 2 updates (#7285) web: bump the eslint group in /web with 1 update (#7286) core: bump ruff from 0.1.1 to 0.1.2 (#7289) core: bump pytest from 7.4.2 to 7.4.3 (#7288) web: bump the wdio group in /tests/wdio with 3 updates (#7290) website/blogs: fixed typo in blog (#7281) core: bump pylint from 2.17.7 to 3.0.2 (#7270) web: bump the eslint group in /tests/wdio with 2 updates (#7274) translate: Updates for file web/xliff/en.xlf in zh-Hans (#7278) translate: Updates for file web/xliff/en.xlf in zh_CN (#7277) ci: bump actions/setup-node from 3 to 4 (#7268) core: bump pylint-django from 2.5.4 to 2.5.5 (#7271) web: bump the eslint group in /web with 2 updates (#7269) web: bump @trivago/prettier-plugin-sort-imports from 4.2.0 to 4.2.1 in /tests/wdio (#7275) ...
* main: (38 commits) crypto: fix race conditions when creating self-signed certificates on startup (#7344) blueprints: fix entries with state: absent not being deleted if their serializer has errors (#7345) web/admin: fix @change handler for ak-radio elements (#7348) rbac: handle lookup error (#7341) website/docs: add warning about upgrading to 2023.10 (#7340) web/admin: fix role form reacting to enter (#7330) core: bump github.com/google/uuid from 1.3.1 to 1.4.0 (#7333) core: bump goauthentik.io/api/v3 from 3.2023083.10 to 3.2023101.1 (#7334) core: bump ruff from 0.1.2 to 0.1.3 (#7335) core: bump pydantic-scim from 0.0.7 to 0.0.8 (#7336) website/blogs: Blog dockers (#7328) providers/proxy: attempt to fix duplicate cookie (#7324) stages/email: fix sending emails from task (#7325) web: bump API Client version (#7321) website/docs: update release notes for 2023.10.1 (#7316) release: 2023.10.1 lifecycle: fix otp merge migration (#7315) root: fix pylint errors (#7312) web: bump API Client version (#7311) release: 2023.10.0 ...
* main: web: bump rollup from 4.1.4 to 4.1.5 in /web (#7370) website/integrations: add SonarQube (#7167) web: bump the storybook group in /web with 5 updates (#7382) core: bump goauthentik.io/api/v3 from 3.2023101.1 to 3.2023102.1 (#7378) web: bump ts-lit-plugin from 2.0.0 to 2.0.1 in /web (#7379) web: bump @rollup/plugin-replace from 5.0.4 to 5.0.5 in /web (#7380) web: bump API Client version (#7365) website/docs: add 2023.8.4 release notes release: 2023.10.2 security: fix oobe-flow reuse when akadmin is deleted (#7361) website/docs: prepare 2023.10.2 release notes (#7362) website/docs: add missing breaking change due to APPEND_SLASH (#7360) lifecycle: rework otp_merge migration (#7359) translate: Updates for file web/xliff/en.xlf in zh-Hans (#7354) translate: Updates for file web/xliff/en.xlf in zh_CN (#7353) website/docs: add warning about Helm breaking change in 2024.x (#7351)
* main: website/integrations: argocd: add missing url in ArgoCD configuration (#7404) core: bump sentry-sdk from 1.32.0 to 1.33.1 (#7397) core: bump webauthn from 1.11.0 to 1.11.1 (#7399) core: bump github.com/redis/go-redis/v9 from 9.2.1 to 9.3.0 (#7396) core: bump twisted from 23.8.0 to 23.10.0 (#7398) web: bump the sentry group in /web with 2 updates (#7401) web: bump pyright from 1.1.333 to 1.1.334 in /web (#7402) web: bump rollup from 4.1.5 to 4.2.0 in /web (#7403) core: bump pytest-django from 4.5.2 to 4.6.0 (#7387) web: bump the eslint group in /tests/wdio with 2 updates (#7388) web: bump the sentry group in /web with 2 updates (#7366) web: bump the eslint group in /web with 2 updates (#7389) web: bump core-js from 3.33.1 to 3.33.2 in /web (#7390) stages/email: fix duplicate querystring encoding (#7386) web/admin: fix html error on oauth2 provider page (#7384)
* main: translate: Updates for file web/xliff/en.xlf in fr (#7416) website: bump react-tooltip from 5.21.6 to 5.22.0 in /website (#7412) core: bump selenium from 4.14.0 to 4.15.0 (#7411) core: bump django from 4.2.6 to 4.2.7 (#7413) web: bump the eslint group in /web with 1 update (#7414) web: bump the eslint group in /tests/wdio with 1 update (#7415) root: Improve multi arch Docker image build speed (#7355)
* main: providers/proxy: fix closed redis client (#7385) ci: explicitly give write permissions to packages (#7428) core: bump selenium from 4.15.0 to 4.15.1 (#7422) web: bump yaml from 2.3.3 to 2.3.4 in /web (#7420) core: bump sentry-sdk from 1.33.1 to 1.34.0 (#7421) web: bump the wdio group in /tests/wdio with 4 updates (#7423) providers/oauth2: set auth_via for token and other endpoints (#7417) website/blog: draft for happy bday blog (#7408)
This commit does not change the functionality of the Table, nor does it require any changes to existing uses of the Table. It will probably be easier to review this by looking at the `View Code` in the upper-right-hand corner of GitHub's reviewer; that or side-by-side, if your monitor is wide-enough. The existing Table component is used 49 times (at last count) in authentik, and those uses are wide-ranging and complex, but they all come down to a couple of entries: - Displaying a row of summary information - Permitting the display of more complex ("expanded") information - Displaying a collection of rows - Displaying a collection of rows grouped by some header - Pagination of many rows - Permitting an action on the visible rows - *Not* blocking events that may happen on a cell or expansion - Providing a toolbar - Providing a display of "selected items" when using the table as a multi-select with many pages of items (chips display) - Providing sort functionality on columns - Providing the ability to filter the table from the back-end This commit changes none of that. What this commit does is re-arrange the innards of Table.ts into smaller units: - The RowGroup's "checkbox" and "expansion" segments are pulled out into their own functions, which makes the RowGroup's actual functionality much easier to see and understand. The same is true of the rowGroup's selection and expansion handlers. - Almost all in-line decisions and event handlers have been extracted and named, to make it easier to see and understand what's happening inside what is otherwise a jumble of HTML. - The TablePagination code was duplicated-- and one of the duplicates was wrong! So I've deduplicated it and fixed the bug. - In many cases, the conditional code grew organically, resulting in some pretty hard-to-understand conditions. - A really good example is the `itemSelectHandler`; there are two possible events that result in a change, and the consequences of that change may be that *all* checkboxes are unchecked. In all cases where there's an add/remove option, I've opted to remove the specific object always (even if it's not present!), and then add it if it's actually an add. Logically coherent as long as the accessors are not also mutators. It was not possible to redefine the `columns()` function to take anything other than a TableColumn object; I wanted to be able to replace all of the `new TableColumn("Foo")` with just `"Foo"`, building the TableColumn dynamically at construction time. Unfortunately, some of our most complex tables dynamically re-arrange the columns (RBAC, for example, draws an empty table, fetches the content, then redraws with the columns based on what was retrieved), and detecting that change and rebuilding those columns proved more difficult than anticipated. I may contemplate an alternative column specification if I find myself building a lot of tables. Likewise, it was not possible to replace all of our uses of the empty `html` declaration with the Lit-preferred `nothing` sigil; hard-coded `TemplateResult` entries scattered throughout the code caused massive type inconsistencies, since a type of `TemplateResult | nothing` is unique thanks to `nothing`'s underlying Symbol. It is for this issue that Typescript itself recommends you "prefer allowing Typescript infer the return type." I may revisit this issue later. I've added a `prequick` command to `package.json`; this one runs *only* the Typescript type checker, lit-analyse, and `eslint:precommit`, the last of which lints only the files touched since the last commit. This is fast, intended to support quick checks of code quality not normally displayed in the IDE.
✅ Deploy Preview for authentik-storybook ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7433 +/- ##
===========================================
+ Coverage 43.71% 92.62% +48.91%
===========================================
Files 588 588
Lines 29200 29200
===========================================
+ Hits 12764 27047 +14283
+ Misses 16436 2153 -14283
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
* main: web/flows: attempt to fix bitwareden android compatibility (#7455) sources/oauth: fix patreon (#7454) website: bump the docusaurus group in /website with 3 updates (#7400) web/admin: fix chart label on dashboard user page (#7434) core: bump github.com/gorilla/sessions from 1.2.1 to 1.2.2 (#7446) core: bump github.com/gorilla/mux from 1.8.0 to 1.8.1 (#7443) core: bump github.com/spf13/cobra from 1.7.0 to 1.8.0 (#7442) core: bump github.com/gorilla/websocket from 1.5.0 to 1.5.1 (#7445) core: bump golang.org/x/sync from 0.4.0 to 0.5.0 (#7441) core: bump github.com/gorilla/securecookie from 1.1.1 to 1.1.2 (#7440) core: bump github.com/gorilla/handlers from 1.5.1 to 1.5.2 (#7444) web: bump rollup from 4.2.0 to 4.3.0 in /web (#7448) web: bump the eslint group in /web with 2 updates (#7447) core: bump uvicorn from 0.23.2 to 0.24.0 (#7450) core: bump selenium from 4.15.1 to 4.15.2 (#7449) core: bump ruff from 0.1.3 to 0.1.4 (#7451) web: bump the eslint group in /tests/wdio with 2 updates (#7452)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couple of questions
web/src/elements/table/Table.ts
Outdated
@@ -107,8 +100,7 @@ export abstract class Table<T> extends AKElement { | |||
return false; | |||
} | |||
|
|||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | |||
renderExpanded(item: T): TemplateResult { | |||
renderExpanded(_item: T): TemplateResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I left the variable name as item
here as that's the default when inheriting from the class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point; I've put it back the way it was.
I was trying to use the "unused variable in abstract code" idiom here, and it shouldn't matter what the name is in the child code, only the position. But leaving the name as-is and commenting out the check is probably better for readability in the long-run.
* main: (125 commits) sources/ldap: clean-up certs written from db (#7617) web: bump the eslint group in /tests/wdio with 1 update (#7635) core: compile backend translations (#7637) core: bump psycopg from 3.1.12 to 3.1.13 (#7625) core: bump ruff from 0.1.5 to 0.1.6 (#7626) core: bump twilio from 8.10.1 to 8.10.2 (#7627) web: bump the eslint group in /web with 1 update (#7629) web: bump the esbuild group in /web with 2 updates (#7630) web: bump rollup from 4.4.1 to 4.5.0 in /web (#7631) web: bump core-js from 3.33.2 to 3.33.3 in /web (#7633) core: bump goauthentik.io/api/v3 from 3.2023103.3 to 3.2023103.4 (#7634) web: bump the wdio group in /tests/wdio with 4 updates (#7636) translate: Updates for file locale/en/LC_MESSAGES/django.po in zh_TW (#7628) root: specify node and python versions in respective config files, deduplicate in CI (#7620) translate: Updates for file web/xliff/en.xlf in zh-Hans (#7619) translate: Updates for file web/xliff/en.xlf in zh_CN (#7618) tests: better per-test timeouts (#7612) web: bump API Client version (#7613) stages/identification: add option to pretend user exists (#7610) events: stop spam (#7611) ...
After talking to Jens, I've put back the positional variable and eslint escape; it's better to document existing practices than try to force something. I also misunderstood the role of `inner` in one bit of code, and have restored its functionality. Looking through the code, though, I can see a case where it will fail; it's expecting `inner` to be either undefined or a TemplateResult; if there's no error message, the error message defaults to a blank TemplateResult, which is _not_ undefined, and will result in a blank table. This will only happen under very weird network failures, but...
* main: (119 commits) web/flows: show logo in card (#7824) blueprints: improve file change handler (#7813) web/user: fix search not updating app (#7825) web: bump the storybook group in /web with 5 updates (#7819) core: compile backend translations (#7827) translate: Updates for file locale/en/LC_MESSAGES/django.po in de (#7812) core: bump github.com/go-openapi/strfmt from 0.21.8 to 0.21.9 (#7814) ci: bump actions/stale from 8 to 9 (#7815) web: bump the wdio group in /tests/wdio with 1 update (#7816) translate: Updates for file web/xliff/en.xlf in zh_CN (#7820) web: bump the sentry group in /web with 2 updates (#7817) web: bump vite-tsconfig-paths from 4.2.1 to 4.2.2 in /web (#7818) translate: Updates for file web/xliff/en.xlf in zh-Hans (#7821) translate: Updates for file locale/en/LC_MESSAGES/django.po in zh-Hans (#7822) translate: Updates for file locale/en/LC_MESSAGES/django.po in zh_CN (#7823) web: bump typescript from 5.3.2 to 5.3.3 in /web (#7806) website: bump typescript from 5.3.2 to 5.3.3 in /website (#7807) web: bump typescript from 5.3.2 to 5.3.3 in /tests/wdio (#7808) core: bump goauthentik.io/api/v3 from 3.2023104.1 to 3.2023104.2 (#7809) ci: bump actions/setup-go from 4 to 5 ...
* main: scripts: postgres, redis: only listen on localhost (#7849) website: bump @types/react from 18.2.42 to 18.2.43 in /website (#7840) web: bump ts-node from 10.9.1 to 10.9.2 in /tests/wdio (#7846) core: bump github.com/go-openapi/runtime from 0.26.0 to 0.26.2 (#7841) website: bump prettier from 3.1.0 to 3.1.1 in /website (#7839) web: bump the esbuild group in /web with 2 updates (#7842) web: bump rollup from 4.6.1 to 4.7.0 in /web (#7843) web: bump prettier from 3.1.0 to 3.1.1 in /web (#7844) web: bump the wdio group in /tests/wdio with 2 updates (#7845) web: bump prettier from 3.1.0 to 3.1.1 in /tests/wdio (#7847) translate: Updates for file web/xliff/en.xlf in fr (#7851) translate: Updates for file locale/en/LC_MESSAGES/django.po in fr (#7850) core: bump python from 3.12.0-slim-bookworm to 3.12.1-slim-bookworm web/flows: update flow background (#7833) web/flows: fix logo height (#7834) Fix cache related image build issues
✅ Deploy Preview for authentik ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
* main: web: dark/light theme fixes (#7872) web: replace 'description-list' with list of descriptions (#7392) web: expressing success (#7830) web: fix turnstile types after update (#7854) core: bump github.com/google/uuid from 1.4.0 to 1.5.0 (#7866) website: bump @types/react from 18.2.43 to 18.2.45 in /website (#7865) web: bump wdio-wait-for from 3.0.9 to 3.0.10 in /tests/wdio (#7867) website/blog: okta part two blog (#7863) web: bump lit-analyzer from 2.0.1 to 2.0.2 in /web (#7858) web: bump the babel group in /web with 4 updates (#7856) web: bump the eslint group in /web with 2 updates (#7857) web: bump rollup from 4.7.0 to 4.8.0 in /web (#7859) web: bump the eslint group in /tests/wdio with 2 updates (#7860) web: refactor the table renderer for legibility (#7433) documentation: Improve explanation of `kubernetes_json_patches` (#7832) root: update security policy to include link to cure53 report (#7853)
Details
Refactor the Table component for legiibility.
This commit does not change the functionality of the Table, nor does it require any changes to existing uses of the Table.
It will probably be easier to review this by looking at the
View Code
in the upper-right-hand corner of GitHub’s reviewer; that or side-by-side, if your monitor is wide-enough.Background
The existing Table component is used 49 times (at last count) in authentik, and those uses are wide-ranging and complex, but they all come down to a couple of entries:
This commit changes none of that.
Actions taken
What this commit does is re-arrange the innards of Table.ts into smaller units:
itemSelectHandler
; there are two possible events that result in a change, and the consequences of that change may be that all checkboxes are unchecked. In all cases where there’s an add/remove option, I’ve opted to remove the specific object always (even if it’s not present!), and then add it if it’s actually an add. Logically coherent as long as the accessors are not also mutators.Conflicts discovered
It was not possible to redefine the
columns()
function to take anything other than a TableColumn object; I wanted to be able to replace all of thenew TableColumn("Foo")
with just"Foo"
, building the TableColumn dynamically at construction time. Unfortunately, some of our most complex tables dynamically re-arrange the columns (RBAC, for example, draws an empty table, fetches the content, then redraws with the columns based on what was retrieved), and detecting that change and rebuilding those columns proved more difficult than anticipated. I may contemplate an alternative column specification if I find myself building a lot of tables.Likewise, it was not possible to replace all of our uses of the empty
html
declaration with the Lit-preferrednothing
sigil; hard-codedTemplateResult
entries scattered throughout the code caused massive type inconsistencies, since a type ofTemplateResult | nothing
is unique thanks tonothing
’s underlying Symbol. It is for this issue that Typescript itself recommends you “prefer allowing Typescript infer the return type.” I may revisit this issue later.Misc
I’ve added a
prequick
command topackage.json
; this one runs only the Typescript type checker, lit-analyse, andeslint:precommit
, the last of which lints only the files touched since the last commit. This is fast, intended to support quick checks of code quality not normally displayed in the IDE.Checklist
ak test authentik/
)make lint-fix
)If an API change has been made
make gen-build
)If changes to the frontend have been made
make web
)make i18n-extract
)If applicable
make website
)