This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/web/src/elements
Ken Sternberg a2dce3fb63
web: Replace calls to `rootInterface()?.tenant?` with a contextual `this.tenant` object (#7778)
* This commit abstracts access to the object `rootInterface()?.config?` into a single accessor,
`authentikConfig`, that can be mixed into any AKElement object that requires access to it.

Since access to `rootInterface()?.config?` is _universally_ used for a single (and repetitive)
boolean check, a separate accessor has been provided that converts all calls of the form:

``` javascript
rootInterface()?.config?.capabilities.includes(CapabilitiesEnum.CanImpersonate)
```

into:

``` javascript
this.can(CapabilitiesEnum.CanImpersonate)
```

It does this via a Mixin, `WithCapabilitiesConfig`, which understands that these calls only make
sense in the context of a running, fully configured authentik instance, and that their purpose is to
inform authentik components of a user’s capabilities. The latter is why I don’t feel uncomfortable
turning a function call into a method; we should make it explicit that this is a relationship
between components.

The mixin has a single single field, `[WCC.capabilitiesConfig]`, where its association with the
upper-level configuration is made. If that syntax looks peculiar to you, good! I’ve used an explict
unique symbol as the field name; it is inaccessable an innumerable in the object list. The debugger
shows it only as:

    Symbol(): {
        cacheTimeout: 300
        cacheTimeoutFlows: 300
        cacheTimeoutPolicies: 300
        cacheTimeoutReputation: 300
        capabilities: (5) ['can_save_media', 'can_geo_ip', 'can_impersonate', 'can_debug', 'is_enterprise']
    }

Since you can’t reference it by identity, you can’t write to it. Until every browser supports actual
private fields, this is the best we can do; it does guarantee that field name collisions are
impossible, which is a win.

The mixin takes a second optional boolean; setting this to true will cause any web component using
the mixin to automatically schedule a re-render if the capabilities list changes.

The mixin is also generic; despite the "...into a Lit-Context" in the title, the internals of the
Mixin can be replaced with anything so long as the signature of `.can()` is preserved.

Because this work builds off the work I did to give the Sidebar access to the configuration without
ad-hoc retrieval or prop-drilling, it wasn’t necessary to create a new context for it. That will be
necessary for the following:

TODO:

``` javascript
rootInterface()?.uiConfig;
rootInterface()?.tenant;
me();
```

* This commit abstracts access to the object `rootInterface()?.tenant?` into a single accessor,
`tenant`, that can be mixed into any AKElement object that requires access to it.

Like `WithCapabilitiesConfig` and `WithAuthentikConfig`, this one is named `WithTenantConfig`.

TODO:

``` javascript
rootInterface()?.uiConfig;
me();
```

* web: Added a README with a description of the applications' "mental model," essentially an architectural description.

* web: prettier did a thing

* web: prettier had opinions about the README

* web: Jens requested that subscription be  by default, and it's the right call.

* web: Jens requested that the default subscription state for contexts be , and it's the right call.

* web: prettier having opinions after merging with dependent branch

* web: prettier still having opinions.
2024-01-08 13:03:00 -08:00
..
Interface web: Replace calls to `rootInterface()?.tenant?` with a contextual `this.tenant` object (#7778) 2024-01-08 13:03:00 -08:00
ak-locale-context web: update some locale details (#8090) 2024-01-08 17:27:09 +00:00
buttons sources/ldap: add check command to verify ldap connectivity (#7263) 2023-11-13 15:01:40 +01:00
cards enterprise: initial enterprise (#5721) 2023-07-17 17:57:08 +02:00
charts core: Initial RBAC (#6806) 2023-10-16 17:31:50 +02:00
chips web: rework and expand tooltips (#6435) 2023-07-31 19:35:09 +02:00
enterprise enterprise/providers/rac: add alert that enterprise is required for RAC (#8057) 2024-01-04 16:18:12 +01:00
forms web/admin: revise wizard form handling (#7331) 2023-12-06 13:28:19 +02:00
messages web: Replace lingui.js with lit-localize (#5761) 2023-06-02 08:08:36 -07:00
notifications web: Detangling some circular dependencies in Admin and User (#6852) 2023-09-13 10:16:24 -07:00
oauth web: refactor status label to separate component (#7407) 2023-11-20 11:24:48 -08:00
rbac web/admin: add preview banner to RBAC pages (#7295) 2023-10-25 20:15:28 +02:00
router web: Replace lingui.js with lit-localize (#5761) 2023-06-02 08:08:36 -07:00
sidebar web: Replace calls to `rootInterface()?.tenant?` with a contextual `this.tenant` object (#7778) 2024-01-08 13:03:00 -08:00
table enterprise/providers: Add RAC [AUTH-15] (#7291) 2023-12-30 21:33:14 +01:00
user web: remove `./element`⇢`./user` references (#6866) 2023-09-14 10:15:15 -07:00
utils web: abstract `rootInterface()?.config?.capabilities.includes()` into `.can()` (#7737) 2024-01-08 10:22:52 -08:00
wizard web: laying the groundwork for future expansion (#7045) 2023-10-02 13:33:27 -07:00
Alert.ts web: toggle dark/light theme manually (#4876) 2023-03-09 23:17:53 +01:00
AuthentikContexts.ts web: Replace calls to `rootInterface()?.tenant?` with a contextual `this.tenant` object (#7778) 2024-01-08 13:03:00 -08:00
Base.ts web: abstract `rootInterface()?.config?.capabilities.includes()` into `.can()` (#7737) 2024-01-08 10:22:52 -08:00
CodeMirror.ts web/admin: fix prompt form and codemirror mode (#7231) 2023-10-19 23:53:04 +02:00
Diagram.ts security: cure53 fix (#6039) 2023-06-22 22:25:04 +02:00
Divider.ts web: toggle dark/light theme manually (#4876) 2023-03-09 23:17:53 +01:00
EmptyState.ts web: toggle dark/light theme manually (#4876) 2023-03-09 23:17:53 +01:00
Expand.ts web: app icons v2 (#6410) 2023-07-28 14:25:56 +02:00
Label.ts web: toggle dark/light theme manually (#4876) 2023-03-09 23:17:53 +01:00
LoadingOverlay.ts enterprise/providers: Add RAC [AUTH-15] (#7291) 2023-12-30 21:33:14 +01:00
Markdown.ts web: toggle dark/light theme manually (#4876) 2023-03-09 23:17:53 +01:00
PageHeader.ts web: Replace calls to `rootInterface()?.tenant?` with a contextual `this.tenant` object (#7778) 2024-01-08 13:03:00 -08:00
Spinner.ts web: Replace lingui.js with lit-localize (#5761) 2023-06-02 08:08:36 -07:00
Tabs.ts web/user: fix user settings colours on dark theme (#6499) 2023-08-08 00:58:57 +02:00
TreeView.ts web: Replace lingui.js with lit-localize (#5761) 2023-06-02 08:08:36 -07:00
types.ts web: abstract `rootInterface()?.config?.capabilities.includes()` into `.can()` (#7737) 2024-01-08 10:22:52 -08:00