Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix avatar icons in user list when using dark theme #34022

Merged
merged 1 commit into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion apps/settings/src/components/UserList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@
:settings="settings"
:show-config="showConfig"
:sub-admins-groups="subAdminsGroups"
:user="user" />
:user="user"
:is-dark-theme="isDarkTheme" />
<InfiniteLoading ref="infiniteLoading" @infinite="infiniteHandler">
<div slot="spinner">
<div class="users-icon-loading icon-loading" />
Expand Down Expand Up @@ -378,6 +379,10 @@ export default {
},
]
},
isDarkTheme() {
return window.getComputedStyle(this.$el)
.getPropertyValue('--background-invert-if-dark') === 'invert(100%)'
CarlSchwan marked this conversation as resolved.
Show resolved Hide resolved
},
},
watch: {
// watch url change and group select
Expand Down
9 changes: 7 additions & 2 deletions apps/settings/src/components/UserList/UserRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<div :class="{'icon-loading-small': loading.delete || loading.disable || loading.wipe}"
class="avatar">
<img v-if="!loading.delete && !loading.disable && !loading.wipe"
:src="generateAvatar(user.id)"
:src="generateAvatar(user.id, isDarkTheme)"
alt=""
height="32"
width="32">
Expand All @@ -54,6 +54,7 @@
:sub-admins-groups="subAdminsGroups"
:user-actions="userActions"
:user="user"
:is-dark-theme="isDarkTheme"
:class="{'row--menu-opened': openedMenu}" />
<div v-else
:class="{
Expand All @@ -65,7 +66,7 @@
<div :class="{'icon-loading-small': loading.delete || loading.disable || loading.wipe}"
class="avatar">
<img v-if="!loading.delete && !loading.disable && !loading.wipe"
:src="generateAvatar(user.id)"
:src="generateAvatar(user.id, isDarkTheme)"
alt=""
height="32"
width="32">
Expand Down Expand Up @@ -295,6 +296,10 @@ export default {
type: Array,
default: () => [],
},
isDarkTheme: {
type: Boolean,
required: true,
},
},
data() {
return {
Expand Down
6 changes: 5 additions & 1 deletion apps/settings/src/components/UserList/UserRowSimple.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
alt=""
width="32"
height="32"
:src="generateAvatar(user.id)" />
:src="generateAvatar(user.id, isDarkTheme)" />
</div>
<!-- dirty hack to ellipsis on two lines -->
<div class="name">
Expand Down Expand Up @@ -130,6 +130,10 @@ export default {
type: Object,
required: true,
},
isDarkTheme: {
type: Boolean,
required: true,
},
},
computed: {
userGroupsLabels() {
Expand Down
27 changes: 19 additions & 8 deletions apps/settings/src/mixins/UserRowMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,27 @@ export default {
* Generate avatar url
*
* @param {string} user The user name
* @param {bool} isDarkTheme Whether the avatar should be the dark version
* @return {string}
*/
generateAvatar(user) {
return generateUrl(
'/avatar/{user}/64?v={version}',
{
user,
version: oc_userconfig.avatar.version,
}
)
generateAvatar(user, isDarkTheme) {
if (isDarkTheme) {
return generateUrl(
'/avatar/{user}/64/dark?v={version}',
{
user,
version: oc_userconfig.avatar.version,
}
)
} else {
return generateUrl(
'/avatar/{user}/64?v={version}',
{
user,
version: oc_userconfig.avatar.version,
}
)
}
},
},
}
4 changes: 2 additions & 2 deletions dist/settings-users-8351.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-users-8351.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/settings-vue-settings-apps-users-management.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-vue-settings-apps-users-management.js.map

Large diffs are not rendered by default.