[bugfix] Fix account roles (#1542)

* Change account role from string to object

* Update tests

* small fixes + swagger docs

---------

Co-authored-by: zowhoey <11893985+zowhoey@users.noreply.github.com>
This commit is contained in:
tobi 2023-02-20 17:00:44 +01:00 committed by GitHub
commit e8a04b7ce1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 160 additions and 73 deletions

View file

@ -55,7 +55,7 @@ const nav = {
const { sidebar, panelRouter } = require("./lib/get-views")(nav);
function App({ account }) {
const isAdmin = account.role == "admin";
const isAdmin = account.role.name == "admin";
const [logoutQuery] = query.useLogoutMutation();
return (

View file

@ -90,7 +90,7 @@ function UserProfileForm({ data: profile }) {
header={form.header.previewValue ?? profile.header}
display_name={form.displayName.value ?? profile.username}
username={profile.username}
role={profile.role}
role={profile.role.name}
/>
<div className="files">
<div>

View file

@ -34,7 +34,7 @@
<div class="usernamecontainer">
<div class="username">@{{ .account.Username }}@{{ .instance.AccountDomain }}</div>
{{- /* Only render account role if 1. it's present and 2. it's not equal to the standard 'user' role */ -}}
{{ if and (.account.Role) (ne .account.Role "user") }}<div class="role {{ .account.Role }}">{{ .account.Role }}</div>{{ end }}
{{ if and (.account.Role) (ne .account.Role.Name "user") }}<div class="role {{ .account.Role.Name }}">{{ .account.Role.Name }}</div>{{ end }}
</div>
</div>
<div class="detailed">