-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added file action to Files to import file into Tables
Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de> basic implementation of import to tables button Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de> work on api request to import table Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de> addition of import modal and import logic Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de> update variable names for clarity and consistency Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de> added error handling and feedback to import modal Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de> updated valid importable file formats Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de> added error handling for unimportable file type Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de> removed unused import Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de> modal organization/code cleanup Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de> added error messages and modal visibility Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de> reworked error handling Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de> added import results dialog, renamed files Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de> only render button when valid file type Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de> fixed enabled for valid file types Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de> fix lint errors Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de> added info to aid static analysis Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de> made ImportResults into reusable component Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de> refactored to use ImportResults component Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de> change icon from hardcoded svg string to icon import Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de> added cypress tests for file action import Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de> fix: dynamic import for FileActionImport component Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de> test: refactored tests for file importing Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de>
- Loading branch information
Showing
8 changed files
with
511 additions
and
63 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
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::addScript(Application::APP_ID, 'tables-files', 'files'); | ||
} | ||
} |
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,33 @@ | ||
import { FileAction, registerFileAction } from '@nextcloud/files' | ||
import { spawnDialog } from '@nextcloud/dialogs' | ||
import tablesIcon from '@mdi/svg/svg/table-large.svg?raw' | ||
Check failure on line 3 in src/file-actions.js GitHub Actions / NPM lint
|
||
|
||
__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.