Skip to content

Commit

Permalink
feat: hide extension preferences if only 1 extension available
Browse files Browse the repository at this point in the history
  • Loading branch information
kulmann committed Apr 2, 2024
1 parent 42bfaf8 commit 433a726
Showing 1 changed file with 43 additions and 18 deletions.
61 changes: 43 additions & 18 deletions packages/web-runtime/src/pages/account.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,26 @@
</oc-button>
</div>
<dl class="account-page-info oc-flex oc-flex-wrap">
<div class="account-page-info-username oc-mb oc-width-1-2@s">
<div class="account-page-info-username oc-mb oc-width-1-2@m oc-width-1-1@s">
<dt class="oc-text-normal oc-text-muted" v-text="$gettext('Username')" />
<dd>
{{ user.onPremisesSamAccountName }}
</dd>
</div>
<div class="account-page-info-displayname oc-mb oc-width-1-2@s">
<div class="account-page-info-displayname oc-mb oc-width-1-2@m oc-width-1-1@s">
<dt class="oc-text-normal oc-text-muted" v-text="$gettext('First and last name')" />
<dd>
{{ user.displayName }}
</dd>
</div>
<div class="account-page-info-email oc-mb oc-width-1-2@s">
<div class="account-page-info-email oc-mb oc-width-1-2@m oc-width-1-1@s">
<dt class="oc-text-normal oc-text-muted" v-text="$gettext('Email')" />
<dd>
<template v-if="user.mail">{{ user.mail }}</template>
<span v-else v-text="$gettext('No email has been set up')" />
</dd>
</div>
<div class="account-page-info-groups oc-mb oc-width-1-2@s">
<div class="account-page-info-groups oc-mb oc-width-1-2@m oc-width-1-1@s">
<dt class="oc-text-normal oc-text-muted" v-text="$gettext('Group memberships')" />
<dd data-testid="group-names">
<span v-if="groupNames">{{ groupNames }}</span>
Expand All @@ -48,7 +48,10 @@
/>
</dd>
</div>
<div v-if="showLogout" class="account-page-logout-all-devices oc-mb oc-width-1-2@s">
<div
v-if="showLogout"
class="account-page-logout-all-devices oc-mb oc-width-1-2@m oc-width-1-1@s"
>
<dt
class="oc-text-normal oc-text-muted"
v-text="$gettext('Logout from active devices')"
Expand All @@ -65,7 +68,10 @@
</oc-button>
</dd>
</div>
<div v-if="showChangePassword" class="account-page-password oc-mb oc-width-1-2@s">
<div
v-if="showChangePassword"
class="account-page-password oc-mb oc-width-1-2@m oc-width-1-1@s"
>
<dt class="oc-text-normal oc-text-muted" v-text="$gettext('Password')" />
<dd data-testid="password">
<oc-button
Expand All @@ -85,9 +91,9 @@
<h2 class="oc-text-bold" v-text="$gettext('Preferences')" />
</div>
<dl class="account-page-preferences oc-flex oc-flex-wrap">
<div class="account-page-info-language oc-mb oc-width-1-2@s">
<div class="account-page-info-language oc-mb oc-width-1-2@m oc-width-1-1@s">
<dt class="oc-text-normal oc-text-muted" v-text="$gettext('Language')" />
<dd data-testid="language" class="oc-width-1-3">
<dd data-testid="language" class="oc-width-1-3@l oc-width-1-2@m oc-width-1-1@s">
<oc-select
v-if="languageOptions"
:placeholder="$gettext('Please choose...')"
Expand All @@ -98,13 +104,16 @@
/>
</dd>
</div>
<div class="account-page-info-theme oc-mb oc-width-1-2@s">
<div class="account-page-info-theme oc-mb oc-width-1-2@m oc-width-1-1@s">
<dt class="oc-text-normal oc-text-muted" v-text="$gettext('Theme')" />
<dd data-testid="theme" class="oc-width-1-3">
<dd data-testid="theme" class="oc-width-1-3@l oc-width-1-2@m oc-width-1-1@s">
<theme-switcher />
</dd>
</div>
<div v-if="showNotifications" class="account-page-notification oc-mb oc-width-1-2@s">
<div
v-if="showNotifications"
class="account-page-notification oc-mb oc-width-1-2@m oc-width-1-1@s"
>
<dt class="oc-text-normal oc-text-muted" v-text="$gettext('Notifications')" />
<dd data-testid="notification-mails">
<oc-checkbox
Expand All @@ -116,7 +125,10 @@
/>
</dd>
</div>
<div v-if="showWebDavDetails" class="account-page-view-options oc-mb oc-width-1-2@s">
<div
v-if="showWebDavDetails"
class="account-page-view-options oc-mb oc-width-1-2@m oc-width-1-1@s"
>
<dt class="oc-text-normal oc-text-muted" v-text="$gettext('View options')" />
<dd data-testid="view-options">
<oc-checkbox
Expand All @@ -141,20 +153,27 @@
<div
v-for="extensionPoint in extensionPointsWithUserPreferences"
:key="`extension-point-preference-${extensionPoint.id}`"
class="oc-mb oc-width-1-1"
>
<dt class="oc-text-normal oc-text-muted" v-text="extensionPoint.userPreference.label" />
<dd>
<dd class="oc-width-1-6@l oc-width-1-3@m oc-width-1-1@s">
<extension-preference :extension-point="extensionPoint" />
</dd>
</div>
</dl>
</div>
<div v-if="showGdprExport" class="account-page-gdpr-export oc-width-1-1">
<h2 class="oc-text-bold oc-mb" v-text="$gettext('GDPR')" />
<dt class="oc-text-normal oc-text-muted" v-text="$gettext('GDPR export')" />
<dd data-testid="gdpr-export">
<gdpr-export />
</dd>
<div class="oc-flex oc-width-1-1">
<h2 class="oc-text-bold oc-mb" v-text="$gettext('GDPR')" />
</div>
<dl class="account-page-gdpr-export">
<div class="oc-mb">
<dt class="oc-text-normal oc-text-muted" v-text="$gettext('GDPR export')" />
<dd data-testid="gdpr-export">
<gdpr-export />
</dd>
</div>
</dl>
</div>
</main>
</template>
Expand Down Expand Up @@ -434,6 +453,12 @@ export default defineComponent({
return extensionRegistry
.getExtensionPoints<ExtensionPoint>()
.filter((extensionPoint: ExtensionPoint) => extensionPoint.userPreference)
.filter((extensionPoint: ExtensionPoint) => {
const extensions = extensionRegistry.requestExtensions(extensionPoint.type, {
extensionPointIds: [extensionPoint.id]
})
return !!extensions.length
})
})
onMounted(async () => {
Expand Down

0 comments on commit 433a726

Please sign in to comment.