web/user: refactor LibraryPage for testing, add CTA#5665
Conversation
authentik translations instructionsThanks for your pull request! authentik translations are handled using Transifex. Please edit translations over there and they'll be included automatically. |
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## main #5665 +/- ##
==========================================
+ Coverage 92.49% 92.62% +0.13%
==========================================
Files 547 547
Lines 26227 26227
==========================================
+ Hits 24256 24289 +33
+ Misses 1971 1938 -33
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
authentik PR Installation instructions Instructions for docker-composeAdd the following block to your AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-BUG-5171-revised-package-json-1684790489-d0415c1
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)sFor arm64, use these values: AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-BUG-5171-revised-package-json-1684790489-d0415c1-arm64
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)sAfterwards, run the upgrade commands from the latest release notes. Instructions for KubernetesAdd the following block to your authentik:
outposts:
container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
image:
repository: ghcr.io/goauthentik/dev-server
tag: gh-BUG-5171-revised-package-json-1684790489-d0415c1For arm64, use these values: authentik:
outposts:
container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
image:
repository: ghcr.io/goauthentik/dev-server
tag: gh-BUG-5171-revised-package-json-1684790489-d0415c1-arm64Afterwards, run the upgrade commands from the latest release notes. |
| `, | ||
| ]; | ||
|
|
||
| @state() isSuperUser = false; |
There was a problem hiding this comment.
I'm personally more of a fan of having it like
@state()
foo = "bar";but that's also very much a nitpick
There was a problem hiding this comment.
But a good one. Consistency is important.
| @@ -0,0 +1,2 @@ | |||
| export const SEARCH_UPDATED = "authentik.search-updated"; | |||
There was a problem hiding this comment.
should maybe be in web/src/common/constants.ts? especially if we want to re-use the same event for different places
There was a problem hiding this comment.
It's very local to this, and the parent object that listens for it does a stopPropagation, so the name could be re-used in other places without confusion. I'll think on it much more, but my main goal is not polluting a global namespace if I don't have to.
| export type AppGroupEntry = [string, Application[]]; | ||
| export type AppGroupList = AppGroupEntry[]; | ||
|
|
||
| export type PageUIConfig = { |
There was a problem hiding this comment.
do we want to have another type for this? Any reason that UIConfig in web/src/common/ui/config.ts doesn't work?
There was a problem hiding this comment.
It's not that it doesn't work, it's that it's too much. There are only three settings we care about and I want to document those. I'm caught between the "Don't pass to child components info they don't need" vs "Don't calculate what is already stored," but I think the duplication here reduces confusion about what styles this component uses. Down in the components that use these I would have to invoke the Demeter-defying strings of dereferences anyway; putting them here centralizes that effort, makes them easy to find, and gives them names.
There was a problem hiding this comment.
Yeah thats a fair point, allthough maybe it would be better to go the other way around and compose UIConfig of smaller interfaces, and we don't have to add things in two places, but that can be a later PR if we want to do that
✅ Deploy Preview for authentik ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
I'm pretty impressed that that worked. Good on Jens for having that in the prettier rules.
Removed the migration and web/README.md file. The former should not have been included; the latter is currently unprofessional in tone.
TL;DR:
- Separated LibraryPage into a bunch of different, independent parts, none of which require
Authentik running to be testable or viewable.
- This made adding the "Add an Application" CTA easier.
- This sets the stage for unit and view testing of the UI
This commit revises the LibraryPage, devolving it into a couple of independent components that have
to asynchronous dependencies, with a single asynchronous master:
- LibraryPage: Loads the UIConfig, UserConfig, and CoreApi, and once those are loaded, launches the
LibraryPageImpl.
- LibraryPageImpl: the ListView of applications available, and updates the ListView according to
search criteria it receives via an event listener.
- LibraryPageImpl.css: The stylesheet. Put here because it's visual clutter.
- LibraryPageImpl.utils: defines static functions used to filter the view. Here because, again, it
would otherwise be visual clutter of the LibraryPageImpl.
- ApplicationEmptyState: Shows the "You have no applications" and, if the user is a superuser, the
"Add an application" button.
- ApplicationSearch: Contains the Fuse implementation and, as the search result is updated, sends
the selected and filtered app list to the LibraryPage via an event. Also controls the "Choose an
application by pressing Enter" event.
- ApplicationList: Displays the list of applications.
All of these components are _responsive_ to changes in the Apps collection via the LibraryPage
itself, but none of them invoke the Apps collection, UIConfig, and CoreApi directly, so it should be
possible to create Storybook implementations that view the LibraryPageImpl itself without having to
have an instance of Authentik running.
If the user is a superuser, the "You have no applications" panel now shows the "Add an Application"
button and a link to the documentation on how to add an application.
\#\# Details - Resolves #5171 \#\# Changes This just updates the prettier and eslint passes.
- Resolves #5171 \#\# Changes Removed unused declarations.
- web: refactor LibraryPage, resolves #5171 \#\# Changes Some changes found in code review, including an embarassing failure to both remove the old internal accessor and propagate the new one for "isAdmin". A pattern is emerging that a LitComponent class should consist of: - styles - properties - states - queries - other object fields - constructor() - connectedCallBack() - disconnectedCallBack() - event listeners - callback helpers - render helpers - render() ... in that order.
854531e to
83807f2
Compare
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
| PFEmptyState, | ||
| PFContent, | ||
| PFSpacing, | ||
| css` |
There was a problem hiding this comment.
This is one of the few things that really bothers me about this change. I could not figure out how to make the "button" (it's really an anchor) look like the mock-up without hacking my own CSS, and I don't think I should have had to do that.
Also, this is a bit inconsistent with my usual "Define the styles outside of the class because they're static" principle. I may revisit this in the future, if the opportunity presents itself.
| `, | ||
| ]; | ||
|
|
||
| @state() isSuperUser = false; |
There was a problem hiding this comment.
But a good one. Consistency is important.
| @@ -0,0 +1,2 @@ | |||
| export const SEARCH_UPDATED = "authentik.search-updated"; | |||
There was a problem hiding this comment.
It's very local to this, and the parent object that listens for it does a stopPropagation, so the name could be re-used in other places without confusion. I'll think on it much more, but my main goal is not polluting a global namespace if I don't have to.
| export type AppGroupEntry = [string, Application[]]; | ||
| export type AppGroupList = AppGroupEntry[]; | ||
|
|
||
| export type PageUIConfig = { |
There was a problem hiding this comment.
It's not that it doesn't work, it's that it's too much. There are only three settings we care about and I want to document those. I'm caught between the "Don't pass to child components info they don't need" vs "Don't calculate what is already stored," but I think the duplication here reduces confusion about what styles this component uses. Down in the components that use these I would have to invoke the Demeter-defying strings of dereferences anyway; putting them here centralizes that effort, makes them easy to find, and gives them names.
|
Thanks @kensternberg-authentik for adding CTA here! One request: can you change the wording about the Docs to "Refer to documentation"? |
As requested by @tana.
* 5171: Fixed README to comply with Prettier rules.
I'm pretty impressed that that worked. Good on Jens for having that
in the prettier rules.
* web: revised package.json
Removed the migration and web/README.md file. The former should not have
been included; the latter is currently unprofessional in tone.
* web: revise LibraryPage, add CTA
TL;DR:
- Separated LibraryPage into a bunch of different, independent parts, none of which require
Authentik running to be testable or viewable.
- This made adding the "Add an Application" CTA easier.
- This sets the stage for unit and view testing of the UI
This commit revises the LibraryPage, devolving it into a couple of independent components that have
to asynchronous dependencies, with a single asynchronous master:
- LibraryPage: Loads the UIConfig, UserConfig, and CoreApi, and once those are loaded, launches the
LibraryPageImpl.
- LibraryPageImpl: the ListView of applications available, and updates the ListView according to
search criteria it receives via an event listener.
- LibraryPageImpl.css: The stylesheet. Put here because it's visual clutter.
- LibraryPageImpl.utils: defines static functions used to filter the view. Here because, again, it
would otherwise be visual clutter of the LibraryPageImpl.
- ApplicationEmptyState: Shows the "You have no applications" and, if the user is a superuser, the
"Add an application" button.
- ApplicationSearch: Contains the Fuse implementation and, as the search result is updated, sends
the selected and filtered app list to the LibraryPage via an event. Also controls the "Choose an
application by pressing Enter" event.
- ApplicationList: Displays the list of applications.
All of these components are _responsive_ to changes in the Apps collection via the LibraryPage
itself, but none of them invoke the Apps collection, UIConfig, and CoreApi directly, so it should be
possible to create Storybook implementations that view the LibraryPageImpl itself without having to
have an instance of Authentik running.
If the user is a superuser, the "You have no applications" panel now shows the "Add an Application"
button and a link to the documentation on how to add an application.
* web: lint and prettier updates
\#\# Details
- Resolves goauthentik#5171
\#\# Changes
This just updates the prettier and eslint passes.
* \#\# Details
- Resolves goauthentik#5171
\#\# Changes
Removed unused declarations.
* \#\# Details
- web: refactor LibraryPage, resolves goauthentik#5171
\#\# Changes
Some changes found in code review, including an embarassing failure
to both remove the old internal accessor and propagate the new
one for "isAdmin".
A pattern is emerging that a LitComponent class should consist of:
- styles
- properties
- states
- queries
- other object fields
- constructor()
- connectedCallBack()
- disconnectedCallBack()
- event listeners
- callback helpers
- render helpers
- render()
... in that order.
* actually remove LibraryPage that got re-added in the rebase
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
* fix router import
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
* use pf-c-button for CTA
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
* fix different alignment compared to old version
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
* use docLink() for documentation link
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
* also open docs in new tab
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
* web: minor language changes
As requested by @tana.
---------
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
Co-authored-by: Jens Langhammer <jens@goauthentik.io>
Details
Changes
web: revise LibraryPage, add CTA
Summary
TL;DR:
Description
Refactored
This commit revises the LibraryPage, devolving it into a couple of independent components that have to asynchronous dependencies, with a single asynchronous master:
All of these components are responsive to changes in the Apps collection via the LibraryPage itself, but none of them invoke the Apps collection, UIConfig, and CoreApi directly, so it should be possible to create Storybook implementations that view the LibraryPageImpl itself without having to have an instance of Authentik running.
Extension and Bugfix
If the user is a superuser, the “You have no applications” panel now shows the “Add an Application” button and a link to the documentation on how to add an application.
New Features
Breaking Changes
No breaking changes.
Checklist
ak test authentik/)make lint-fix)If an API change has been made
If changes to the frontend have been made
make web)make i18n-extract)No documentation changes were made.