Skip to content

Commit f516eeb

Browse files
authored
Merge pull request #60191 from nextcloud/fix/account-style
fix(settings): apply consistent style by using proper components
2 parents bca11ce + 19e11c4 commit f516eeb

4 files changed

Lines changed: 25 additions & 34 deletions

File tree

apps/settings/src/views/UserManagementNavigation.vue

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,10 @@
1717
</template>
1818
</NcAppNavigationNew>
1919

20-
<div class="account-management__search" role="search" :aria-label="t('settings', 'Search accounts and groups')">
21-
<NcInputField
22-
ref="searchField"
23-
v-model="searchInput"
24-
:label="t('settings', 'Search accounts and groups…')"
25-
:show-trailing-button="searchInput !== ''"
26-
:trailingButtonLabel="t('settings', 'Clear search')"
27-
@trailing-button-click="clearSearch">
28-
<template #icon>
29-
<NcIconSvgWrapper :path="mdiMagnify" />
30-
</template>
31-
<template #trailing-button-icon>
32-
<NcIconSvgWrapper :path="mdiClose" />
33-
</template>
34-
</NcInputField>
35-
</div>
20+
<NcAppNavigationSearch
21+
ref="searchField"
22+
v-model="searchInput"
23+
:label="t('settings', 'Search accounts and groups…')" />
3624

3725
<NcAppNavigationList
3826
class="account-management__system-list"
@@ -112,19 +100,22 @@
112100
<NcButton
113101
class="account-management__settings-toggle"
114102
variant="tertiary"
103+
wide
115104
@click="isDialogOpen = true">
116105
<template #icon>
117106
<NcIconSvgWrapper :path="mdiCogOutline" />
118107
</template>
119-
{{ t('settings', 'Account management settings') }}
108+
<span class="account-management__settings-toggle-text">
109+
{{ t('settings', 'Account management settings') }}
110+
</span>
120111
</NcButton>
121112
<UserSettingsDialog :open.sync="isDialogOpen" />
122113
</template>
123114
</NcAppNavigation>
124115
</template>
125116

126117
<script setup lang="ts">
127-
import { mdiAccountOffOutline, mdiAccountOutline, mdiClose, mdiCogOutline, mdiHistory, mdiMagnify, mdiPlus, mdiShieldAccountOutline } from '@mdi/js'
118+
import { mdiAccountOffOutline, mdiAccountOutline, mdiCogOutline, mdiHistory, mdiPlus, mdiShieldAccountOutline } from '@mdi/js'
128119
import { translate as t } from '@nextcloud/l10n'
129120
import { useHotKey } from '@nextcloud/vue/composables/useHotKey'
130121
import debounce from 'debounce'
@@ -134,10 +125,10 @@ import NcAppNavigation from '@nextcloud/vue/components/NcAppNavigation'
134125
import NcAppNavigationItem from '@nextcloud/vue/components/NcAppNavigationItem'
135126
import NcAppNavigationList from '@nextcloud/vue/components/NcAppNavigationList'
136127
import NcAppNavigationNew from '@nextcloud/vue/components/NcAppNavigationNew'
128+
import NcAppNavigationSearch from '@nextcloud/vue/components/NcAppNavigationSearch'
137129
import NcButton from '@nextcloud/vue/components/NcButton'
138130
import NcCounterBubble from '@nextcloud/vue/components/NcCounterBubble'
139131
import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper'
140-
import NcInputField from '@nextcloud/vue/components/NcInputField'
141132
import AppNavigationGroupList from '../components/AppNavigationGroupList.vue'
142133
import UserSettingsDialog from '../components/Users/UserSettingsDialog.vue'
143134
import { useFormatGroups } from '../composables/useGroupsNavigation.js'
@@ -146,23 +137,19 @@ import { useStore } from '../store/index.js'
146137
const route = useRoute()
147138
const store = useStore()
148139
149-
const searchField = ref<InstanceType<typeof NcInputField>>()
140+
const searchField = ref<InstanceType<typeof NcAppNavigationSearch>>()
150141
const searchInput = ref('')
151142
const commitSearch = debounce((query: string) => {
152143
store.commit('setSearchQuery', query)
153144
}, 300)
154145
watch(searchInput, (value) => commitSearch(value))
155-
function clearSearch() {
156-
commitSearch.clear()
157-
searchInput.value = ''
158-
store.commit('setSearchQuery', '')
159-
}
146+
160147
onBeforeUnmount(() => commitSearch.clear())
161148
162149
// Intercept Ctrl/Cmd+F to focus the local search. useHotKey ignores the
163150
// event when an input/textarea is already focused, so a second press falls
164151
// through to the browser's native find-in-page.
165-
useHotKey('f', () => searchField.value?.focus(), { ctrl: true, stop: true, prevent: true })
152+
useHotKey('f', () => searchField.value?.$refs.inputElement?.focus(), { ctrl: true, stop: true, prevent: true })
166153
167154
/** State of the 'new-account' dialog */
168155
const isDialogOpen = ref(false)
@@ -216,7 +203,11 @@ function showNewUserMenu() {
216203
}
217204
218205
&__settings-toggle {
219-
margin-bottom: 12px;
206+
margin-bottom: var(--body-container-margin);
207+
208+
&-text {
209+
font-weight: 500;
210+
}
220211
}
221212
}
222213
</style>

cypress/e2e/settings/users_search.cy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ describe('Settings: Unified search for accounts and groups', { testIsolation: fa
6868
})
6969

7070
it('shows the search input in the navigation sidebar', () => {
71-
accountNav().findByRole('textbox', { name: /search accounts and groups/i })
71+
accountNav().findByRole('searchbox', { name: /search accounts and groups/i })
7272
.should('be.visible')
7373
.and('have.value', '')
7474
})
7575

7676
it('dispatches the query to both the users and groups API', () => {
77-
accountNav().findByRole('textbox', { name: /search accounts and groups/i })
77+
accountNav().findByRole('searchbox', { name: /search accounts and groups/i })
7878
.type(alice.userId)
7979

8080
// A single keystroke sequence debounces once (300ms), then fans out
@@ -88,7 +88,7 @@ describe('Settings: Unified search for accounts and groups', { testIsolation: fa
8888
})
8989

9090
it('filters the group list when the query matches a group name', () => {
91-
accountNav().findByRole('textbox', { name: /search accounts and groups/i })
91+
accountNav().findByRole('searchbox', { name: /search accounts and groups/i })
9292
.clear()
9393
.type(matchingGroup)
9494

@@ -102,7 +102,7 @@ describe('Settings: Unified search for accounts and groups', { testIsolation: fa
102102
it('resets both lists when the clear button is clicked', () => {
103103
accountNav().findByRole('button', { name: /clear search/i }).click()
104104

105-
accountNav().findByRole('textbox', { name: /search accounts and groups/i })
105+
accountNav().findByRole('searchbox', { name: /search accounts and groups/i })
106106
.should('have.value', '')
107107

108108
waitForSearchRequest('@loadUsers', '')

dist/settings-vue-settings-users-management.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/settings-vue-settings-users-management.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)