-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #890 from nextcloud/feat/365
Feat: File action to import from Files to Tables
- Loading branch information
Showing
11 changed files
with
584 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace OCA\Tables\Listener; | ||
|
||
use OCA\Tables\AppInfo\Application; | ||
use OCP\Collaboration\Resources\LoadAdditionalScriptsEvent; | ||
use OCP\EventDispatcher\Event; | ||
use OCP\EventDispatcher\IEventListener; | ||
use OCP\Util; | ||
|
||
/** @template-implements IEventListener<LoadAdditionalScriptsEvent> */ | ||
class LoadAdditionalListener implements IEventListener { | ||
public function handle(Event $event): void { | ||
if (!($event instanceof LoadAdditionalScriptsEvent)) { | ||
return; | ||
} | ||
|
||
Util::addInitScript(Application::APP_ID, 'tables-files'); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { FileAction, registerFileAction } from '@nextcloud/files' | ||
import { spawnDialog } from '@nextcloud/dialogs' | ||
// eslint-disable-next-line import/no-unresolved | ||
import tablesIcon from '@mdi/svg/svg/table-large.svg?raw' | ||
|
||
__webpack_nonce__ = btoa(OC.requestToken) // eslint-disable-line | ||
__webpack_public_path__ = OC.linkTo('tables', 'js/') // eslint-disable-line | ||
|
||
const validMimeTypes = [ | ||
'text/csv', | ||
'text/html', | ||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', | ||
'application/vnd.ms-excel', | ||
] | ||
|
||
const fileAction = new FileAction({ | ||
id: 'import-to-tables', | ||
displayName: () => t('tables', 'Import into Tables'), | ||
iconSvgInline: () => tablesIcon, | ||
|
||
enabled: (files) => { | ||
const file = files[0] | ||
|
||
return file.type === 'file' && validMimeTypes.includes(file.mime) | ||
}, | ||
|
||
exec: async (file) => { | ||
const { default: FileActionImport } = await import('./modules/modals/FileActionImport.vue') | ||
spawnDialog(FileActionImport, { file }) | ||
return null | ||
}, | ||
}) | ||
|
||
registerFileAction(fileAction) |
Oops, something went wrong.