Skip to content

Commit 8eeea92

Browse files
fix(teams): allow hiding the shared folder button via config.php
Organizations that want Team Folders instead of personal shares can hide the team-page action that creates a personal folder and shares it with the team. Fixes #5638 Assisted-by: Cursor Grok:cursor-grok-4.6 Signed-off-by: Lennart Joswig <mail@ljoswig.de> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 742458e commit 8eeea92

6 files changed

Lines changed: 63 additions & 2 deletions

File tree

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,27 @@ The app is distributed through the [app store](https://apps.nextcloud.com/apps/c
3333

3434
Release tarballs are hosted at https://github.com/nextcloud-releases/contacts/releases.
3535

36+
## Configuration
37+
38+
The following options can be set in Nextcloud's `config/config.php`:
39+
40+
```php
41+
/**
42+
* Hide the button on the team page that creates a personal folder and
43+
* shares it with the team. Useful when organizations want users to use
44+
* Team Folders instead of personal shares for collaborative work.
45+
*
46+
* Defaults to false (the button is shown).
47+
*/
48+
'contacts.hide_team_shared_folder_creation' => true,
49+
```
50+
51+
Or via occ:
52+
53+
```bash
54+
occ config:system:set contacts.hide_team_shared_folder_creation --type=boolean --value=true
55+
```
56+
3657
## :satellite: Support
3758

3859
If you need assistance or want to ask a question about Contacts, you are welcome to [ask for support](https://help.nextcloud.com) in our forums. If you have found a bug, feel free to open a new Issue on GitHub. Keep in mind, that this repository only manages the frontend. If you find bugs or have problems with the CardDAV-Backend, you should ask the team at [Nextcloud server](https://github.com/nextcloud/server) for help!

lib/AppInfo/Application.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
class Application extends App implements IBootstrap {
2323
public const APP_ID = 'contacts';
2424

25+
/**
26+
* System config key (config.php) to hide the "create a personal folder
27+
* and share it with the team" button on the team page.
28+
*/
29+
public const CONFIG_HIDE_TEAM_SHARED_FOLDER_CREATION = 'contacts.hide_team_shared_folder_creation';
30+
2531
public function __construct() {
2632
parent::__construct(self::APP_ID);
2733
}

lib/Controller/PageController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public function index(): TemplateResponse {
6666

6767
$isTalkVersionCompatible = $this->compareVersion->isCompatible($talkVersion ? $talkVersion : '0.0.0', 2);
6868

69+
$hideTeamSharedFolderCreation = $this->config->getSystemValueBool(Application::CONFIG_HIDE_TEAM_SHARED_FOLDER_CREATION, false);
70+
6971
$this->initialState->provideInitialState('isGroupSharingEnabled', $isGroupSharingEnabled);
7072
$this->initialState->provideInitialState('locales', $locales);
7173
$this->initialState->provideInitialState('defaultProfile', $defaultProfile);
@@ -75,6 +77,7 @@ public function index(): TemplateResponse {
7577
$this->initialState->provideInitialState('isContactsInteractionEnabled', $isContactsInteractionEnabled);
7678
$this->initialState->provideInitialState('isCirclesEnabled', $isCirclesEnabled && $isCircleVersionCompatible);
7779
$this->initialState->provideInitialState('isTalkEnabled', $isTalkEnabled && $isTalkVersionCompatible);
80+
$this->initialState->provideInitialState('hideTeamSharedFolderCreation', $hideTeamSharedFolderCreation);
7881

7982
Util::addStyle(Application::APP_ID, 'contacts-main');
8083
Util::addScript(Application::APP_ID, 'contacts-main');

src/components/CircleDetails.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
</div>
152152

153153
<!-- Team resource creation shortcuts -->
154-
<div v-if="circle.isMember" class="resource-shortcuts">
154+
<div v-if="circle.isMember && resourceTypes.length > 0" class="resource-shortcuts">
155155
<h3 class="resource-shortcuts__title">
156156
{{ t('contacts', 'Create') }}
157157
</h3>
@@ -327,6 +327,7 @@ import TeamResourceButton from './CircleDetails/TeamResourceButton.vue'
327327
import MemberList from './MemberList/MemberList.vue'
328328
import CircleActionsMixin from '../mixins/CircleActionsMixin.js'
329329
import { CircleEdit, editCircle } from '../services/circles.ts'
330+
import hideTeamSharedFolderCreation from '../services/hideTeamSharedFolderCreation.js'
330331
331332
import 'cropperjs/dist/cropper.css'
332333
@@ -540,7 +541,7 @@ export default {
540541
helperText: t('contacts', 'This will create a regular folder shared with the team. To create a Team Folder, please contact your {productName} administrator', { productName: OC.theme.name }),
541542
icon: 'FolderOutlineIcon',
542543
apiPath: 'files',
543-
enabled: enabledApps.files !== undefined,
544+
enabled: enabledApps.files !== undefined && !hideTeamSharedFolderCreation,
544545
},
545546
{
546547
id: 'talk',
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
import { loadState } from '@nextcloud/initial-state'
7+
8+
const hideTeamSharedFolderCreation = loadState('contacts', 'hideTeamSharedFolderCreation', false)
9+
export default hideTeamSharedFolderCreation

tests/unit/Controller/PageControllerTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,25 @@ public function testIndex() {
8888
$this->assertEquals('user', $result->getRenderAs());
8989
$this->assertTrue($result instanceof TemplateResponse);
9090
}
91+
92+
public function testIndexProvidesHideTeamSharedFolderCreation() {
93+
$user = $this->createMock(IUser::class);
94+
$user->method('getUid')->willReturn('mrstest');
95+
$this->userSession->method('getUser')->willReturn($user);
96+
97+
$this->config->expects($this->once())
98+
->method('getSystemValueBool')
99+
->with('contacts.hide_team_shared_folder_creation', false)
100+
->willReturn(true);
101+
102+
$states = [];
103+
$this->initialStateService->method('provideInitialState')
104+
->willReturnCallback(function (string $key, mixed $value) use (&$states): void {
105+
$states[$key] = $value;
106+
});
107+
108+
$this->controller->index();
109+
110+
$this->assertTrue($states['hideTeamSharedFolderCreation']);
111+
}
91112
}

0 commit comments

Comments
 (0)