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

[stable30] fix: Use icons instead of avatar for locking indication #472

Merged
merged 2 commits into from
Dec 19, 2024
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
6 changes: 3 additions & 3 deletions src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,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
Loading