user panel: Add admin interface button
This commit is contained in:
parent
8f362172db
commit
6d48261876
2 changed files with 22 additions and 1 deletions
|
|
@ -31,6 +31,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
{{ $showAdminURLs := .ShowAdminURLs }}
|
||||||
<div class="pure-u-1">
|
<div class="pure-u-1">
|
||||||
<h2>Your WissKIs</h2>
|
<h2>Your WissKIs</h2>
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -53,6 +54,11 @@
|
||||||
<th>
|
<th>
|
||||||
Admin
|
Admin
|
||||||
</th>
|
</th>
|
||||||
|
{{ if $showAdminURLs }}
|
||||||
|
<th>
|
||||||
|
Distillery Admin Link
|
||||||
|
</th>
|
||||||
|
{{ end }}
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
@ -69,6 +75,13 @@
|
||||||
<td>
|
<td>
|
||||||
{{ $grant.DrupalAdminRole }}
|
{{ $grant.DrupalAdminRole }}
|
||||||
</td>
|
</td>
|
||||||
|
{{ if $showAdminURLs }}
|
||||||
|
<td>
|
||||||
|
<a href="{{ $grant.AdminURL }}" class="pure-button" target="_blank" rel="noopener noreferer">
|
||||||
|
{{ $grant.AdminURL }}
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
{{ end }}
|
||||||
</tr>
|
</tr>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import (
|
||||||
|
|
||||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
|
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
|
||||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/auth"
|
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/auth"
|
||||||
|
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/auth/scopes"
|
||||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/server/assets"
|
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/server/assets"
|
||||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/server/templating"
|
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/server/templating"
|
||||||
"github.com/FAU-CDI/wisski-distillery/internal/models"
|
"github.com/FAU-CDI/wisski-distillery/internal/models"
|
||||||
|
|
@ -26,7 +27,8 @@ type userContext struct {
|
||||||
templating.RuntimeFlags
|
templating.RuntimeFlags
|
||||||
*auth.AuthUser
|
*auth.AuthUser
|
||||||
|
|
||||||
Grants []GrantWithURL
|
ShowAdminURLs bool
|
||||||
|
Grants []GrantWithURL
|
||||||
}
|
}
|
||||||
|
|
||||||
type GrantWithURL struct {
|
type GrantWithURL struct {
|
||||||
|
|
@ -34,6 +36,10 @@ type GrantWithURL struct {
|
||||||
URL template.URL
|
URL template.URL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g GrantWithURL) AdminURL() template.URL {
|
||||||
|
return template.URL("/admin/instance/" + g.Slug)
|
||||||
|
}
|
||||||
|
|
||||||
func (panel *UserPanel) routeUser(ctx context.Context) http.Handler {
|
func (panel *UserPanel) routeUser(ctx context.Context) http.Handler {
|
||||||
|
|
||||||
tpl := userTemplate.Prepare(
|
tpl := userTemplate.Prepare(
|
||||||
|
|
@ -55,6 +61,8 @@ func (panel *UserPanel) routeUser(ctx context.Context) http.Handler {
|
||||||
return uc, nil, err
|
return uc, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uc.ShowAdminURLs = panel.Dependencies.Auth.CheckScope("", scopes.ScopeAdminLoggedIn, r) == nil
|
||||||
|
|
||||||
// replace the totp action in the menu
|
// replace the totp action in the menu
|
||||||
var totpAction component.MenuItem
|
var totpAction component.MenuItem
|
||||||
if uc.AuthUser.IsTOTPEnabled() {
|
if uc.AuthUser.IsTOTPEnabled() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue