-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat(f2v): migrate Files #39808
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
Merged
Merged
feat(f2v): migrate Files #39808
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
998b3a2
feat(f2v): migrate Files
skjnldsv 410f58e
chore(files): add Headers, remove legacy methods and cleanup
skjnldsv 3344f0f
fix(files): service worker
skjnldsv 0f68d08
feat: virtual scrolling update
skjnldsv 9df5212
perf(files): reuse vnode with unique key
skjnldsv 28725c4
feat: redirect to the mime icon if no preview available
skjnldsv 267cea8
fix: FileEntry boundariesElement and right click menu
skjnldsv 6214fe7
fix(files): active and open sidebar on mount
skjnldsv 52f2ddd
fix(files): router and fileid sidebar open
skjnldsv c08d5e6
fix(files): dir contents variables
skjnldsv af44cc7
fix(files): unnecessary navigation change detection
skjnldsv 96d5971
fix(files): navigation quota alignments
skjnldsv f6a6e0b
fix(files): sidebar favorite event sync
skjnldsv 5098a2d
fix(tests): actions adjust and jest fetch mock
skjnldsv 2cdb074
chore: compile assets
skjnldsv 9a5b266
fix(files): window.caches check
skjnldsv fdf07fc
fix(cypress): adjust selectors
skjnldsv 6da9813
chore: update openapi
skjnldsv 1b67542
fix(files): trashbin redirect and default fileid Sidebar open
skjnldsv 266fb31
fix(tests): preview phpunit
skjnldsv 74c2f61
chore: remove outdated acceptance tests
skjnldsv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: redirect to the mime icon if no preview available
Signed-off-by: John Molakvoæ <[email protected]>
- Loading branch information
commit 28725c46a84db6e733c42e38cbc5e1b7f0e3854b
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,98 @@ | ||
| <?php | ||
| /** | ||
| * @copyright Copyright (c) 2023 John Molakvoæ <[email protected]> | ||
| * | ||
| * @author John Molakvoæ <[email protected]> | ||
| * | ||
| * @license AGPL-3.0-or-later | ||
| * | ||
| * This code is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License, version 3, | ||
| * as published by the Free Software Foundation. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License, version 3, | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/> | ||
| * | ||
| */ | ||
| namespace OC\Preview; | ||
|
|
||
| use OCA\Theming\ThemingDefaults; | ||
| use OCP\App\IAppManager; | ||
| use OCP\Files\IMimeTypeDetector; | ||
| use OCP\IConfig; | ||
| use OCP\IURLGenerator; | ||
| use OCP\Preview\IMimeIconProvider; | ||
|
|
||
| class MimeIconProvider implements IMimeIconProvider { | ||
| public function __construct( | ||
| protected IMimeTypeDetector $mimetypeDetector, | ||
| protected IConfig $config, | ||
| protected IURLGenerator $urlGenerator, | ||
| protected IAppManager $appManager, | ||
| protected ThemingDefaults $themingDefaults, | ||
| ) { | ||
| } | ||
|
|
||
| public function getMimeIconUrl(string $mime): null|string { | ||
| if (!$mime) { | ||
| return null; | ||
| } | ||
|
|
||
| // Fetch all the aliases | ||
| $aliases = $this->mimetypeDetector->getAllAliases(); | ||
|
|
||
| // Remove comments | ||
| $aliases = array_filter($aliases, static function ($key) { | ||
| return !($key === '' || $key[0] === '_'); | ||
| }, ARRAY_FILTER_USE_KEY); | ||
|
|
||
| // Map all the aliases recursively | ||
| foreach ($aliases as $alias => $value) { | ||
| if ($alias === $mime) { | ||
| $mime = $value; | ||
| } | ||
| } | ||
|
|
||
| $fileName = str_replace('/', '-', $mime); | ||
| if ($url = $this->searchfileName($fileName)) { | ||
| return $url; | ||
| } | ||
|
|
||
| $mimeType = explode('/', $mime)[0]; | ||
| if ($url = $this->searchfileName($mimeType)) { | ||
| return $url; | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| private function searchfileName(string $fileName): null|string { | ||
| // If the file exists in the current enabled legacy | ||
| // custom theme, let's return it | ||
| $theme = $this->config->getSystemValue('theme', ''); | ||
| if (!empty($theme)) { | ||
| $path = "/themes/$theme/core/img/filetypes/$fileName.svg"; | ||
| if (file_exists(\OC::$SERVERROOT . $path)) { | ||
| return $this->urlGenerator->getAbsoluteURL($path); | ||
| } | ||
| } | ||
|
|
||
| // Previously, we used to pass thi through Theming | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thi ? |
||
| // But it was only used to colour icons containing | ||
| // 0082c9. Since with vue we moved to inline svg icons, | ||
| // we can just use the default core icons. | ||
|
|
||
| // Finally, if the file exists in core, let's return it | ||
| $path = "/core/img/filetypes/$fileName.svg"; | ||
| if (file_exists(\OC::$SERVERROOT . $path)) { | ||
| return $this->urlGenerator->getAbsoluteURL($path); | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.