Skip to content

Commit

Permalink
change icon from hardcoded svg string to icon import
Browse files Browse the repository at this point in the history
Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de>
  • Loading branch information
elzody committed Mar 4, 2024
1 parent 62aa604 commit ddb59ec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/file-actions.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { FileAction, registerFileAction } from '@nextcloud/files'
import { spawnDialog } from '@nextcloud/dialogs'
import FileActionImport from './modules/modals/FileActionImport.vue'

const icon = `<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="24" height="24" viewBox="0 0 24 24">
<path d="M4,3H20A2,2 0 0,1 22,5V20A2,2 0 0,1 20,22H4A2,2 0 0,1 2,20V5A2,2 0 0,1 4,3M4,7V10H8V7H4M10,7V10H14V7H10M20,10V7H16V10H20M4,12V15H8V12H4M4,20H8V17H4V20M10,12V15H14V12H10M10,20H14V17H10V20M20,20V17H16V20H20M20,12H16V15H20V12Z"/>
</svg>
`
import tablesIcon from '@mdi/svg/svg/table-large.svg?raw'

const validMimeTypes = [
'text/csv',
Expand All @@ -17,15 +13,15 @@ const validMimeTypes = [
const fileAction = new FileAction({
id: 'import-to-tables',
displayName: () => t('tables', 'Import into Tables'),
iconSvgInline: () => icon,
iconSvgInline: () => tablesIcon,

enabled: (files) => {
const file = files[0]

return file.type === 'file' && validMimeTypes.includes(file.mime)
},

exec: async (file) => {
exec: (file) => {
spawnDialog(FileActionImport, { file })
return null
},
Expand Down
10 changes: 10 additions & 0 deletions webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,14 @@ webpackConfig.entry = {
reference: path.join(__dirname, 'src', 'reference.js'),
}

webpackConfig.module = {
rules: [
...webpackConfig.module.rules,
{
resourceQuery: /raw/,
type: 'asset/source',
}
]
}

module.exports = webpackConfig

0 comments on commit ddb59ec

Please sign in to comment.