From 1fde704c79f34297e50db8be5115dd8e23f52bba Mon Sep 17 00:00:00 2001 From: Pawel Boguslawski Date: Thu, 2 Jul 2026 15:07:36 +0200 Subject: [PATCH 1/3] Hide "Shared by link" when sharing by link is disabled Related: https://github.com/nextcloud/server/issues/50323 Author-Change-Id: IB#1156670 Signed-off-by: Pawel Boguslawski --- apps/files/lib/Controller/ViewController.php | 4 +++ apps/files_sharing/src/files_views/shares.ts | 27 +++++++++++--------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 054bb106e150f..285de5c8acf1d 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -175,6 +175,10 @@ public function index($dir = '', $view = '', $fileid = null) { } $this->initialState->provideInitialState('storageStats', $storageInfo); + $this->initialState->provideInitialState('isLinkSharingEnabled', + ($this->config->getAppValue('core', 'shareapi_enabled', 'yes') === 'yes') + && ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') + ); $this->initialState->provideInitialState('config', $this->userConfig->getConfigs()); $this->initialState->provideInitialState('viewConfigs', $this->viewConfig->getConfigs()); $this->initialState->provideInitialState('recent_limit', $this->appConfig->getAppValueInt(ConfigLexicon::RECENT_LIMIT, 100)); diff --git a/apps/files_sharing/src/files_views/shares.ts b/apps/files_sharing/src/files_views/shares.ts index 112bc2909988b..dd104f45307cd 100644 --- a/apps/files_sharing/src/files_views/shares.ts +++ b/apps/files_sharing/src/files_views/shares.ts @@ -80,22 +80,25 @@ export default () => { })) } - Navigation.register(new View({ - id: sharingByLinksViewId, - name: t('files_sharing', 'Shared by link'), - caption: t('files_sharing', 'List of files that are shared by link.'), + // Don't show this view if sharing by link is disabled. + if (loadState('files', 'isLinkSharingEnabled', true)) { + Navigation.register(new View({ + id: sharingByLinksViewId, + name: t('files_sharing', 'Shared by link'), + caption: t('files_sharing', 'List of files that are shared by link.'), - emptyTitle: t('files_sharing', 'No shared links'), - emptyCaption: t('files_sharing', 'Files and folders you shared by link will show up here'), + emptyTitle: t('files_sharing', 'No shared links'), + emptyCaption: t('files_sharing', 'Files and folders you shared by link will show up here'), - icon: LinkSvg, - order: 3, - parent: sharesViewId, + icon: LinkSvg, + order: 3, + parent: sharesViewId, - columns: [], + columns: [], - getContents: () => getContents(false, true, false, false, [ShareType.Link]), - })) + getContents: () => getContents(false, true, false, false, [ShareType.Link]), + })) + } Navigation.register(new View({ id: fileRequestViewId, From 1bd2b6d7300c8bd314c03646bcff3d2f1270495a Mon Sep 17 00:00:00 2001 From: Pawel Boguslawski Date: Fri, 10 Jul 2026 11:45:27 +0200 Subject: [PATCH 2/3] Use existing capability Related: https://github.com/nextcloud/server/pull/61724 Author-Change-Id: IB#1156670 Signed-off-by: Pawel Boguslawski --- apps/files/lib/Controller/ViewController.php | 3 --- apps/files_sharing/src/files_views/shares.ts | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 285de5c8acf1d..ec9af34eb0a89 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -175,9 +175,6 @@ public function index($dir = '', $view = '', $fileid = null) { } $this->initialState->provideInitialState('storageStats', $storageInfo); - $this->initialState->provideInitialState('isLinkSharingEnabled', - ($this->config->getAppValue('core', 'shareapi_enabled', 'yes') === 'yes') - && ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') ); $this->initialState->provideInitialState('config', $this->userConfig->getConfigs()); $this->initialState->provideInitialState('viewConfigs', $this->viewConfig->getConfigs()); diff --git a/apps/files_sharing/src/files_views/shares.ts b/apps/files_sharing/src/files_views/shares.ts index dd104f45307cd..629936161b868 100644 --- a/apps/files_sharing/src/files_views/shares.ts +++ b/apps/files_sharing/src/files_views/shares.ts @@ -15,6 +15,7 @@ import { loadState } from '@nextcloud/initial-state' import { t } from '@nextcloud/l10n' import { ShareType } from '@nextcloud/sharing' import { getContents, isFileRequest } from '../services/SharingService.ts' +import { getCapabilities } from '@nextcloud/capabilities' export const sharesViewId = 'shareoverview' export const sharedWithYouViewId = 'sharingin' @@ -81,7 +82,7 @@ export default () => { } // Don't show this view if sharing by link is disabled. - if (loadState('files', 'isLinkSharingEnabled', true)) { + if (getCapabilities().files_sharing.public.enabled) { Navigation.register(new View({ id: sharingByLinksViewId, name: t('files_sharing', 'Shared by link'), From b47ab9e3a6ed706af7a65bb85fe62f37fa1107d2 Mon Sep 17 00:00:00 2001 From: Pawel Boguslawski Date: Fri, 10 Jul 2026 11:57:09 +0200 Subject: [PATCH 3/3] Code cleanup Author-Change-Id: IB#1156670 Signed-off-by: Pawel Boguslawski --- apps/files/lib/Controller/ViewController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index ec9af34eb0a89..054bb106e150f 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -175,7 +175,6 @@ public function index($dir = '', $view = '', $fileid = null) { } $this->initialState->provideInitialState('storageStats', $storageInfo); - ); $this->initialState->provideInitialState('config', $this->userConfig->getConfigs()); $this->initialState->provideInitialState('viewConfigs', $this->viewConfig->getConfigs()); $this->initialState->provideInitialState('recent_limit', $this->appConfig->getAppValueInt(ConfigLexicon::RECENT_LIMIT, 100));