|
1 | | -import { me } from "@goauthentik/common/users"; |
2 | 1 | import { AKElement } from "@goauthentik/elements/Base"; |
3 | 2 | import { paramURL } from "@goauthentik/elements/router/RouterOutlet"; |
4 | 3 |
|
5 | 4 | import { t } from "@lingui/macro"; |
6 | 5 |
|
7 | 6 | import { css, html } from "lit"; |
8 | | -import { customElement, state } from "lit/decorators.js"; |
| 7 | +import { customElement, property } from "lit/decorators.js"; |
9 | 8 |
|
10 | 9 | import PFContent from "@patternfly/patternfly/components/Content/content.css"; |
11 | 10 | import PFEmptyState from "@patternfly/patternfly/components/EmptyState/empty-state.css"; |
12 | 11 | import PFBase from "@patternfly/patternfly/patternfly-base.css"; |
13 | 12 | import PFSpacing from "@patternfly/patternfly/utilities/Spacing/spacing.css"; |
14 | 13 |
|
15 | | -import { SessionUser } from "@goauthentik/api"; |
16 | | - |
17 | 14 | /** |
18 | 15 | * Library Page Application List Empty |
19 | 16 | * |
20 | 17 | * Display a message if there are no applications defined in the current instance. If the user is an |
21 | 18 | * administrator, provide a link to the "Create a new application" page. |
22 | 19 | */ |
23 | 20 |
|
| 21 | +const styles = [ |
| 22 | + PFBase, |
| 23 | + PFEmptyState, |
| 24 | + PFContent, |
| 25 | + PFSpacing, |
| 26 | + css` |
| 27 | + .cta { |
| 28 | + display: inline-block; |
| 29 | + font-weight: bold; |
| 30 | + color: black; |
| 31 | + border: 3px solid var(--pf-c-empty-state__icon--Color); |
| 32 | + padding: var(--pf-global--spacer--sm); |
| 33 | + } |
| 34 | + `, |
| 35 | +]; |
| 36 | + |
24 | 37 | @customElement("ak-library-application-empty-list") |
25 | 38 | export class LibraryPageApplicationEmptyList extends AKElement { |
26 | | - static styles = [ |
27 | | - PFBase, |
28 | | - PFEmptyState, |
29 | | - PFContent, |
30 | | - PFSpacing, |
31 | | - css` |
32 | | - .cta { |
33 | | - display: inline-block; |
34 | | - font-weight: bold; |
35 | | - color: black; |
36 | | - border: 3px solid var(--pf-c-empty-state__icon--Color); |
37 | | - padding: var(--pf-global--spacer--sm); |
38 | | - } |
39 | | - `, |
40 | | - ]; |
41 | | - |
42 | | - @state() isSuperUser = false; |
| 39 | + static styles = styles; |
43 | 40 |
|
44 | | - connectedCallback() { |
45 | | - super.connectedCallback(); |
46 | | - me().then((me: SessionUser) => { |
47 | | - this.isSuperUser = me.user.isSuperuser; |
48 | | - }); |
49 | | - } |
| 41 | + @property({ attribute: "isadmin", type: Boolean }) |
| 42 | + isAdmin = false; |
50 | 43 |
|
51 | 44 | renderNewAppButton() { |
52 | 45 | const href = paramURL("/core/applications", { |
@@ -74,7 +67,7 @@ export class LibraryPageApplicationEmptyList extends AKElement { |
74 | 67 | <div class="pf-c-empty-state__body"> |
75 | 68 | ${t`Either no applications are defined, or you don’t have access to any.`} |
76 | 69 | </div> |
77 | | - ${this.isSuperUser ? this.renderNewAppButton() : html``} |
| 70 | + ${this.isAdmin ? this.renderNewAppButton() : html``} |
78 | 71 | </div> |
79 | 72 | </div>`; |
80 | 73 | } |
|
0 commit comments