Skip to content

Commit

Permalink
Merge pull request #474 from nextcloud/backport/471/stable28
Browse files Browse the repository at this point in the history
[stable28] fix: Use icons instead of avatar for locking indication
  • Loading branch information
juliusknorr authored Dec 19, 2024
2 parents 4cdec9f + e872884 commit d32efa0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ export const getInfoLabel = (node: Node): string => {

if (state.lockOwnerType === LockType.User) {
return state.isLocked
? t('files_lock', 'Locked by {user}', { user: state.lockOwnerDisplayName })
? t('files_lock', 'Manually locked by {user}', { user: state.lockOwnerDisplayName })
: ''

} else if (state.lockOwnerType === LockType.App) {
return state.isLocked
? t('files_lock', 'Locked by {app}', { app: state.lockOwnerDisplayName })
? t('files_lock', 'Locked by editing online in {app}', { app: state.lockOwnerDisplayName })
: ''
} else {
return state.isLocked
? t('files_lock', 'Locked by {user}', { user: state.lockOwnerDisplayName })
? t('files_lock', 'Automatically locked by {user}', { user: state.lockOwnerDisplayName })
: ''
}

Expand Down
11 changes: 8 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { lockFile, unlockFile } from './api'
import { LockType } from './types'
import {
canLock, canUnlock,
generateAvatarSvg,
getInfoLabel,
getLockStateFromAttributes,
} from './helper'
Expand All @@ -29,6 +28,8 @@ import '@nextcloud/dialogs/style.css'
import LockSvg from '@mdi/svg/svg/lock.svg?raw'
import LockOpenSvg from '@mdi/svg/svg/lock-open-variant.svg?raw'
import LockEditSvg from '@mdi/svg/svg/pencil-lock.svg?raw'
import LockMonitorSvg from '@mdi/svg/svg/monitor-lock.svg?raw'
import LockAccountSvg from '@mdi/svg/svg/account-lock.svg?raw'

const switchLock = async (node: Node) => {
try {
Expand Down Expand Up @@ -73,14 +74,18 @@ const inlineAction = new FileAction({
return ''
}

if (state.isLocked && state.lockOwnerType !== LockType.App && state.lockOwner !== getCurrentUser()?.uid) {
return generateAvatarSvg(state.lockOwner)
if (state.lockOwnerType === LockType.Token) {
return LockMonitorSvg
}

if (state.lockOwnerType === LockType.App) {
return LockEditSvg
}

if (state.lockOwner !== getCurrentUser()?.uid) {
return LockAccountSvg
}

return LockSvg
},

Expand Down

0 comments on commit d32efa0

Please sign in to comment.