fix: 💄 add icon
All checks were successful
retro / xml (push) Successful in 11s
retro / php (push) Successful in 56s
retro / nodejs (push) Successful in 44s
retro / release (push) Has been skipped

This commit is contained in:
Michel Roux 2025-01-04 22:44:54 +01:00
parent d0e8f9efe0
commit 68614fc9bd
2 changed files with 11 additions and 11 deletions

View File

@ -1,4 +1,5 @@
import {
DefaultType,
FileAction,
FileType,
Node,
@ -7,27 +8,24 @@ import {
} from '@nextcloud/files'
import cores from './mime.json'
import { generateUrl } from '@nextcloud/router'
import icon from '../img/app.svg?raw'
import { t } from '@nextcloud/l10n'
const getCore = (file: Node) => {
if (
!file.fileid ||
file.type !== FileType.File ||
!(file.permissions & Permission.READ)
)
return false
if (file.type === FileType.File && file.permissions & Permission.READ) {
const extension = file.extension?.substring(1)
for (const core in cores) {
if (cores[core].types.includes(file.mime)) return core
if (cores[core].extensions.includes(extension)) return core
}
}
return false
}
const action = new FileAction({
id: 'retro',
displayName: () => t('repod', 'Play'),
iconSvgInline: () => '',
iconSvgInline: () => icon,
enabled: (files: Node[]) => {
if (files.length !== 1) return false
return !!getCore(files[0])
@ -39,6 +37,7 @@ const action = new FileAction({
})
return true
},
default: DefaultType.DEFAULT,
})
registerFileAction(action)

View File

@ -10,5 +10,6 @@
"rootDir": ".",
"strict": true,
"noEmit": true,
"types": ["vite/client"],
}
}