Skip to content

Commit

Permalink
Properly use useCapabilitySpacesEnabled, adjust space title according…
Browse files Browse the repository at this point in the history
… to it
  • Loading branch information
JammingBen committed May 8, 2023
1 parent 6ca8b0a commit 9b97eff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 25 deletions.
23 changes: 9 additions & 14 deletions packages/web-runtime/src/pages/account.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@confirm="editPassword"
></edit-password-modal>
<oc-button
v-if="isChangePasswordEnabled"
v-if="spacesEnabled"
variation="primary"
data-testid="account-page-edit-url-btn"
@click="showEditPasswordModal"
Expand Down Expand Up @@ -69,10 +69,7 @@
/>
</dd>
</div>
<div
v-if="isSettingsServiceSupported"
class="account-page-info-language oc-mb oc-width-1-2@s"
>
<div v-if="spacesEnabled" class="account-page-info-language oc-mb oc-width-1-2@s">
<dt class="oc-text-normal oc-text-muted" v-text="$gettext('Language')" />
<dd data-testid="language">
<oc-select
Expand Down Expand Up @@ -105,7 +102,7 @@
<gdpr-export />
</dd>
</div>
<div v-if="isSettingsServiceSupported" class="account-page-notification oc-mb oc-width-1-2@s">
<div v-if="spacesEnabled" class="account-page-notification oc-mb oc-width-1-2@s">
<dt class="oc-text-normal oc-text-muted" v-text="$gettext('Notifications')" />
<dd data-testid="notification-mails">
<oc-checkbox
Expand Down Expand Up @@ -159,8 +156,7 @@ export default defineComponent({
const disableEmailNotificationsValue = ref<boolean>()
// FIXME: Use graph capability when we have it
const isSettingsServiceSupported = useCapabilitySpacesEnabled()
const isChangePasswordEnabled = useCapabilitySpacesEnabled()
const spacesEnabled = useCapabilitySpacesEnabled()
const isPersonalDataExportEnabled = useCapabilityGraphPersonalDataExport()
const user = computed(() => {
return store.getters.user
Expand Down Expand Up @@ -209,7 +205,7 @@ export default defineComponent({
}).restartable()
const isLoading = computed(() => {
if (!unref(isSettingsServiceSupported)) {
if (!unref(spacesEnabled)) {
return false
}
return (
Expand All @@ -230,7 +226,7 @@ export default defineComponent({
})
const groupNames = computed(() => {
if (unref(useCapabilitySpacesEnabled())) {
if (unref(spacesEnabled)) {
return unref(user)
.groups.map((group) => group.displayName)
.join(', ')
Expand Down Expand Up @@ -303,7 +299,7 @@ export default defineComponent({
store.commit('runtime/spaces/UPDATE_SPACE_FIELD', {
id: unref(personalSpace).id,
field: 'name',
value: $gettext('Personal')
value: unref(spacesEnabled) ? $gettext('Personal') : $gettext('All files')
})
}
store.dispatch('showMessage', {
Expand Down Expand Up @@ -338,7 +334,7 @@ export default defineComponent({
}
onMounted(async () => {
if (unref(isSettingsServiceSupported)) {
if (unref(spacesEnabled)) {
await loadAccountBundleTask.perform()
await loadValuesListTask.perform()
Expand Down Expand Up @@ -368,9 +364,8 @@ export default defineComponent({
updateSelectedLanguage,
updateDisableEmailNotifications,
accountEditLink: store.getters.configuration?.options?.accountEditLink,
isChangePasswordEnabled,
spacesEnabled,
showGdprExport,
isSettingsServiceSupported,
groupNames,
user,
logoutUrl: configurationManager.logoutUrl,
Expand Down
11 changes: 0 additions & 11 deletions packages/web-runtime/tests/unit/pages/account.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,6 @@ describe('account page', () => {
expect(showMessageStub).toHaveBeenCalled()
})
})

describe('computed method "isChangePasswordEnabled"', () => {
it('should be true if capability is enabled', () => {
const { wrapper } = getWrapper({ capabilities: { spaces: { enabled: true } } })
expect(wrapper.vm.isChangePasswordEnabled).toBeTruthy()
})
it('should be false if capability is not enabled', () => {
const { wrapper } = getWrapper()
expect(wrapper.vm.isChangePasswordEnabled).toBeFalsy()
})
})
describe('Logout from all devices link', () => {
it('should render the logout from active devices if logoutUrl is provided', () => {
const { wrapper } = getWrapper()
Expand Down

0 comments on commit 9b97eff

Please sign in to comment.