Skip to content

Commit

Permalink
Admin settings fix mark problems, remove memberOf from list users que…
Browse files Browse the repository at this point in the history
…ry (#10090)
  • Loading branch information
AlexAndBear authored Nov 29, 2023
1 parent 684eda2 commit 5b93e5e
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
/>
</div>
<oc-table
ref="tableRef"
:sort-by="sortBy"
:sort-dir="sortDir"
:fields="fields"
Expand Down Expand Up @@ -107,18 +106,16 @@
</template>

<script lang="ts">
import {
defineComponent,
PropType,
ref,
unref,
ComponentPublicInstance,
computed,
watch
} from 'vue'
import { defineComponent, PropType, ref, unref, computed, watch } from 'vue'
import Fuse from 'fuse.js'
import Mark from 'mark.js'
import { displayPositionedDropdown, eventBus, SortDir } from '@ownclouders/web-pkg'
import {
displayPositionedDropdown,
eventBus,
SortDir,
useRoute,
useRouter
} from '@ownclouders/web-pkg'
import { SideBarEventTopics } from '@ownclouders/web-pkg'
import { Group } from '@ownclouders/web-client/src/generated'
import { ContextMenuQuickAction } from '@ownclouders/web-pkg'
Expand Down Expand Up @@ -155,6 +152,9 @@ export default defineComponent({
const sortBy = ref<string>('displayName')
const sortDir = ref<string>(SortDir.Asc)
const filterTerm = ref<string>('')
const router = useRouter()
const route = useRoute()
const markInstance = ref(null)
const lastSelectedGroupIndex = ref(0)
const lastSelectedGroupId = ref(null)
Expand Down Expand Up @@ -285,6 +285,18 @@ export default defineComponent({
emit('unSelectAllGroups')
})
watch(filterTerm, async () => {
await unref(router).push({ ...unref(route), query: { ...unref(route).query, page: '1' } })
})
watch([filterTerm, paginatedItems], () => {
unref(markInstance)?.unmark()
unref(markInstance)?.mark(unref(filterTerm), {
element: 'span',
className: 'highlight-mark'
})
})
return {
showDetails,
rowClicked,
Expand All @@ -304,12 +316,8 @@ export default defineComponent({
currentPage,
totalPages,
filter,
orderBy
}
},
data() {
return {
markInstance: null
orderBy,
markInstance
}
},
computed: {
Expand Down Expand Up @@ -366,23 +374,9 @@ export default defineComponent({
return this.selectedGroups.map((group) => group.id)
}
},
watch: {
async filterTerm() {
if (!this.markInstance) {
return
}
await this.$router.push({ ...this.$route, query: { ...this.$route.query, page: '1' } })
this.markInstance.unmark()
this.markInstance.mark(this.filterTerm, {
element: 'span',
className: 'highlight-mark',
exclude: ['th *', 'tfoot *']
})
}
},
mounted() {
this.$nextTick(() => {
this.markInstance = new Mark((this.$refs.tableRef as ComponentPublicInstance).$el)
this.markInstance = new Mark('td.oc-table-data-cell-displayName')
})
},
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
/>
</div>
<oc-table
ref="tableRef"
class="spaces-table"
:sort-by="sortBy"
:sort-dir="sortDir"
Expand Down Expand Up @@ -63,9 +62,9 @@
<template #members="{ item }">
{{ getMemberCount(item) }}
</template>
<template #totalQuota="{ item }"> {{ getTotalQuota(item) }} </template>
<template #usedQuota="{ item }"> {{ getUsedQuota(item) }} </template>
<template #remainingQuota="{ item }"> {{ getRemainingQuota(item) }} </template>
<template #totalQuota="{ item }"> {{ getTotalQuota(item) }}</template>
<template #usedQuota="{ item }"> {{ getUsedQuota(item) }}</template>
<template #remainingQuota="{ item }"> {{ getRemainingQuota(item) }}</template>
<template #mdate="{ item }">
<span
v-oc-tooltip="formatDate(item.mdate)"
Expand Down Expand Up @@ -93,7 +92,8 @@
appearance="raw"
class="spaces-table-btn-details"
@click.stop.prevent="showDetailsForSpace(item)"
><oc-icon name="information" fill-type="line" />
>
<oc-icon name="information" fill-type="line" />
</oc-button>
<context-menu-quick-action
ref="contextMenuButtonRef"
Expand Down Expand Up @@ -174,7 +174,6 @@ export default defineComponent({
const sortDir = ref(SortDir.Asc)
const filterTerm = ref('')
const markInstance = ref(undefined)
const tableRef = ref(undefined)
const lastSelectedSpaceIndex = ref(0)
const lastSelectedSpaceId = ref(null)
Expand Down Expand Up @@ -386,21 +385,19 @@ export default defineComponent({
onMounted(() => {
nextTick(() => {
markInstance.value = new Mark(unref(tableRef).$el)
markInstance.value = new Mark('td.oc-table-data-cell-name')
})
})
watch(filterTerm, async () => {
const instance = unref(markInstance)
if (!instance) {
return
}
await router.push({ ...unref(route), query: { ...unref(route).query, page: '1' } })
instance.unmark()
instance.mark(unref(filterTerm), {
await unref(router).push({ ...unref(route), query: { ...unref(route).query, page: '1' } })
})
watch([filterTerm, paginatedItems], () => {
unref(markInstance)?.unmark()
unref(markInstance)?.mark(unref(filterTerm), {
element: 'span',
className: 'highlight-mark',
exclude: ['th *', 'tfoot *']
className: 'highlight-mark'
})
})
Expand Down Expand Up @@ -491,7 +488,6 @@ export default defineComponent({
footerTextFilter,
fields,
highlighted,
tableRef,
filter,
getManagerNames,
formatDate,
Expand Down Expand Up @@ -545,6 +541,7 @@ export default defineComponent({
display: table-cell;
}
}
.oc-table-header-cell-totalQuota,
.oc-table-data-cell-totalQuota,
.oc-table-header-cell-usedQuota,
Expand All @@ -555,6 +552,7 @@ export default defineComponent({
display: table-cell;
}
}
&-squashed {
.oc-table-header-cell-manager,
.oc-table-data-cell-manager,
Expand All @@ -564,6 +562,7 @@ export default defineComponent({
.oc-table-data-cell-usedQuota {
display: none;
}
.oc-table-header-cell-remainingQuota,
.oc-table-data-cell-remainingQuota,
.oc-table-header-cell-mdate,
Expand Down
58 changes: 26 additions & 32 deletions packages/web-app-admin-settings/src/components/Users/UsersList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
</no-content-message>
<oc-table
v-else
ref="tableRef"
class="users-table"
:sort-by="sortBy"
:sort-dir="sortDir"
Expand Down Expand Up @@ -79,8 +78,9 @@
class="oc-mr-xs quick-action-button oc-p-xs users-table-btn-details"
@click="showDetails(item)"
>
<oc-icon name="information" fill-type="line" /></oc-button
><oc-button
<oc-icon name="information" fill-type="line" />
</oc-button>
<oc-button
v-oc-tooltip="$gettext('Edit')"
appearance="raw"
class="oc-mr-xs quick-action-button oc-p-xs users-table-btn-edit"
Expand Down Expand Up @@ -112,22 +112,16 @@

<script lang="ts">
import { useGettext } from 'vue3-gettext'
import {
defineComponent,
PropType,
ref,
unref,
ComponentPublicInstance,
watch,
computed
} from 'vue'
import { defineComponent, PropType, ref, unref, watch, nextTick, onMounted, computed } from 'vue'
import Fuse from 'fuse.js'
import Mark from 'mark.js'
import {
defaultFuseOptions,
displayPositionedDropdown,
eventBus,
SortDir
SortDir,
useRoute,
useRouter
} from '@ownclouders/web-pkg'
import { SideBarEventTopics } from '@ownclouders/web-pkg'
import { AppRole, User } from '@ownclouders/web-client/src/generated'
Expand Down Expand Up @@ -169,6 +163,9 @@ export default defineComponent({
const sortBy = ref<string>('onPremisesSamAccountName')
const sortDir = ref<string>(SortDir.Asc)
const { y: fileListHeaderY } = useFileListHeaderPosition('#admin-settings-app-bar')
const router = useRouter()
const route = useRoute()
const markInstance = ref(null)
const lastSelectedUserIndex = ref(0)
const lastSelectedUserId = ref(null)
Expand Down Expand Up @@ -254,7 +251,7 @@ export default defineComponent({
}
const usersSearchEngine = new Fuse(users, {
...defaultFuseOptions,
keys: ['displayName', 'mail', 'onPremisesSamAccountName', 'role.displayName']
keys: ['displayName']
})
return usersSearchEngine.search(filterTerm).map((r) => r.item)
Expand Down Expand Up @@ -306,8 +303,21 @@ export default defineComponent({
total: totalPages
} = usePagination({ items, perPageDefault, perPageStoragePrefix })
watch(currentPage, () => {
emit('unSelectAllUsers')
onMounted(async () => {
await nextTick()
markInstance.value = new Mark('td.oc-table-data-cell-displayName')
})
watch(filterTerm, async () => {
await unref(router).push({ ...unref(route), query: { ...unref(route).query, page: '1' } })
})
watch([filterTerm, paginatedItems], () => {
unref(markInstance)?.unmark()
unref(markInstance)?.mark(unref(filterTerm), {
element: 'span',
className: 'highlight-mark'
})
})
const keyActions = useKeyboardActions()
Expand Down Expand Up @@ -430,22 +440,6 @@ export default defineComponent({
return this.selectedUsers.map((user) => user.id)
}
},
watch: {
async filterTerm() {
if (!this.$refs.tableRef) {
return
}
await this.$router.push({ ...this.$route, query: { ...this.$route.query, page: '1' } })
this.markInstance = new Mark((this.$refs.tableRef as ComponentPublicInstance).$el)
this.markInstance.unmark()
this.markInstance.mark(this.filterTerm, {
element: 'span',
className: 'highlight-mark',
exclude: ['th *', 'tfoot *']
})
}
},
methods: {
handleSort(event) {
this.sortBy = event.sortBy
Expand Down
2 changes: 1 addition & 1 deletion packages/web-client/src/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const graph = (baseURI: string, axiosClient: AxiosInstance): Graph => {
filter,
new Set<any>([orderBy]),
new Set<any>([]),
new Set<any>(['memberOf', 'appRoleAssignments'])
new Set<any>(['appRoleAssignments'])
),
createUserAppRoleAssignment: (userId: string, appRoleAssignment: AppRoleAssignment) =>
userAppRoleAssignmentApiFactory.userCreateAppRoleAssignments(userId, appRoleAssignment),
Expand Down

0 comments on commit 5b93e5e

Please sign in to comment.