Skip to content

Commit

Permalink
fix(systemtags): fix capabilities and sidebar + tag visibility
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Sep 18, 2023
1 parent fb30aa0 commit ef1abd9
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 290 deletions.
2 changes: 1 addition & 1 deletion apps/files/src/actions/downloadAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const action = new FileAction({
// some folders, we need to use the /apps/files/ajax/download.php
// endpoint, which only supports user root folder.
if (nodes.some(node => node.type === FileType.Folder)
&& !nodes.every(node => node.root?.startsWith('/files'))) {
&& nodes.some(node => !node.root?.startsWith('/files'))) {
return false
}

Expand Down
3 changes: 1 addition & 2 deletions apps/files/src/views/FilesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,7 @@ export default Vue.extend({
this.pathsStore.addPath({ service: currentView.id, fileid: node.fileid, path: join(dir, node.basename) })
})
} catch (error) {
throw error
// logger.error('Error while fetching content', { error })
logger.error('Error while fetching content', { error })
} finally {
this.loading = false
}
Expand Down
3 changes: 2 additions & 1 deletion apps/files/src/views/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
import { emit } from '@nextcloud/event-bus'
import { encodePath } from '@nextcloud/paths'
import { File, Folder } from '@nextcloud/files'
import { getCapabilities } from '@nextcloud/capabilities'
import { getCurrentUser } from '@nextcloud/auth'
import { Type as ShareTypes } from '@nextcloud/sharing'
import $ from 'jquery'
Expand Down Expand Up @@ -299,7 +300,7 @@ export default {
},
isSystemTagsEnabled() {
return OCA && 'SystemTags' in OCA
return getCapabilities()?.systemtags?.enabled === true
},
},
created() {
Expand Down
1 change: 1 addition & 0 deletions apps/systemtags/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'OCA\\SystemTags\\Activity\\Provider' => $baseDir . '/../lib/Activity/Provider.php',
'OCA\\SystemTags\\Activity\\Setting' => $baseDir . '/../lib/Activity/Setting.php',
'OCA\\SystemTags\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
'OCA\\SystemTags\\Capabilities' => $baseDir . '/../lib/Capabilities.php',
'OCA\\SystemTags\\Controller\\LastUsedController' => $baseDir . '/../lib/Controller/LastUsedController.php',
'OCA\\SystemTags\\Search\\TagSearchProvider' => $baseDir . '/../lib/Search/TagSearchProvider.php',
'OCA\\SystemTags\\Settings\\Admin' => $baseDir . '/../lib/Settings/Admin.php',
Expand Down
1 change: 1 addition & 0 deletions apps/systemtags/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ComposerStaticInitSystemTags
'OCA\\SystemTags\\Activity\\Provider' => __DIR__ . '/..' . '/../lib/Activity/Provider.php',
'OCA\\SystemTags\\Activity\\Setting' => __DIR__ . '/..' . '/../lib/Activity/Setting.php',
'OCA\\SystemTags\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
'OCA\\SystemTags\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php',
'OCA\\SystemTags\\Controller\\LastUsedController' => __DIR__ . '/..' . '/../lib/Controller/LastUsedController.php',
'OCA\\SystemTags\\Search\\TagSearchProvider' => __DIR__ . '/..' . '/../lib/Search/TagSearchProvider.php',
'OCA\\SystemTags\\Settings\\Admin' => __DIR__ . '/..' . '/../lib/Settings/Admin.php',
Expand Down
13 changes: 2 additions & 11 deletions apps/systemtags/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\SystemTags\Search\TagSearchProvider;
use OCA\SystemTags\Activity\Listener;
use OCA\SystemTags\Capabilities;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
Expand All @@ -45,6 +46,7 @@ public function __construct() {

public function register(IRegistrationContext $context): void {
$context->registerSearchProvider(TagSearchProvider::class);
$context->registerCapability(Capabilities::class);
}

public function boot(IBootContext $context): void {
Expand Down Expand Up @@ -77,16 +79,5 @@ function () {
$dispatcher->addListener(MapperEvent::EVENT_ASSIGN, $mapperListener);
$dispatcher->addListener(MapperEvent::EVENT_UNASSIGN, $mapperListener);
});

\OCA\Files\App::getNavigationManager()->add(function () {
$l = \OC::$server->getL10N(self::APP_ID);
return [
'id' => 'systemtagsfilter',
'appname' => self::APP_ID,
'script' => 'list.php',
'order' => 25,
'name' => $l->t('Tags'),
];
});
}
}
40 changes: 40 additions & 0 deletions apps/systemtags/lib/Capabilities.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);

/**
* @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
*
* @license AGPL-3.0
*
* 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 OCA\SystemTags;

use OCP\Capabilities\ICapability;

class Capabilities implements ICapability {
/**
* @return array{systemtags: array{enabled: true}}
*/
public function getCapabilities() {
$capabilities = [
'systemtags' => [
'enabled' => true,
]
];
return $capabilities;
}
}
22 changes: 0 additions & 22 deletions apps/systemtags/src/css/systemtagsfilelist.scss

This file was deleted.

5 changes: 2 additions & 3 deletions apps/systemtags/src/services/systemtags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import { fetchTags } from './api'
import { getClient } from '../../../files/src/services/WebdavClient'
import { resultToNode } from '../../../files/src/services/Files'

let tagsCache = [] as TagWithId[]

const formatReportPayload = (tagId: number) => `<?xml version="1.0"?>
<oc:filter-files ${getDavNameSpaces()}>
<d:prop>
Expand All @@ -58,7 +56,7 @@ const tagToNode = function(tag: TagWithId): Folder {

export const getContents = async (path = '/'): Promise<ContentsWithRoot> => {
// List tags in the root
tagsCache = await fetchTags()
const tagsCache = (await fetchTags()).filter(tag => tag.userVisible) as TagWithId[]

if (path === '/') {
return {
Expand All @@ -67,6 +65,7 @@ export const getContents = async (path = '/'): Promise<ContentsWithRoot> => {
source: generateRemoteUrl('dav/systemtags'),
owner: getCurrentUser()?.uid as string,
root: '/systemtags',
permissions: Permission.NONE,
}),
contents: tagsCache.map(tagToNode),
}
Expand Down

0 comments on commit ef1abd9

Please sign in to comment.