Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/ConfigLexicon.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ConfigLexicon implements ILexicon {
public const FEDERATIONS_CACHE = 'federations_cache';
public const FEDERATIONS_CACHE_EXPIRES = 'expires';
public const FEDERATIONS_CACHE_DELTA_EXPIRES = 'delta_expires';
public const HIDE_TEAM_SHARED_FOLDER_CREATION = 'hide_team_shared_folder_creation';

#[\Override]
public function getStrictness(): Strictness {
Expand Down Expand Up @@ -107,6 +108,13 @@ public function getAppConfigs(): array {
definition: 'Federations cache update (delta) expiration time.',
lazy: true,
),
new Entry(
self::HIDE_TEAM_SHARED_FOLDER_CREATION,
ValueType::BOOL,
defaultRaw: false,
definition: 'Hide the team-page button that creates a personal folder and shares it with the team.',
lazy: true,
),
];
}

Expand Down
8 changes: 8 additions & 0 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@

use OC\App\CompareVersion;
use OCA\Contacts\AppInfo\Application;
use OCA\Contacts\ConfigLexicon;
use OCA\Contacts\Service\FederatedInvitesService;
use OCA\Contacts\Service\GroupSharingService;
use OCA\Contacts\Service\SocialApiService;
use OCP\App\IAppManager;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
use OCP\IAppConfig;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IUserSession;
Expand All @@ -29,6 +31,7 @@ public function __construct(
IRequest $request,
private FederatedInvitesService $federatedInvitesService,
private IConfig $config,
private IAppConfig $appConfig,
private IInitialState $initialState,
private IFactory $languageFactory,
private IUserSession $userSession,
Expand Down Expand Up @@ -83,6 +86,10 @@ public function index(string $token = '', string $providerDomain = ''): Template
$isTalkVersionCompatible = $this->compareVersion->isCompatible($talkVersion ? $talkVersion : '0.0.0', 2);
$isOcmInvitesEnabled = $this->federatedInvitesService->isOcmInvitesEnabled();
$ocmInvitesConfig = $this->federatedInvitesService->getOcmInvitesConfig();
$hideTeamSharedFolderCreation = $this->appConfig->getValueBool(
Application::APP_ID,
ConfigLexicon::HIDE_TEAM_SHARED_FOLDER_CREATION,
);

$this->initialState->provideInitialState('isGroupSharingEnabled', $isGroupSharingEnabled);
$this->initialState->provideInitialState('locales', $locales);
Expand All @@ -95,6 +102,7 @@ public function index(string $token = '', string $providerDomain = ''): Template
$this->initialState->provideInitialState('isTalkEnabled', $isTalkEnabled && $isTalkVersionCompatible);
$this->initialState->provideInitialState('isOcmInvitesEnabled', $isOcmInvitesEnabled);
$this->initialState->provideInitialState('ocmInvitesConfig', $ocmInvitesConfig);
$this->initialState->provideInitialState('hideTeamSharedFolderCreation', $hideTeamSharedFolderCreation);

Util::addStyle(Application::APP_ID, 'contacts-main');
Util::addScript(Application::APP_ID, 'contacts-main');
Expand Down
5 changes: 3 additions & 2 deletions src/components/CircleDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
</div>

<!-- Team resource creation shortcuts -->
<div v-if="circle.isMember" class="resource-shortcuts">
<div v-if="circle.isMember && resourceTypes.length > 0" class="resource-shortcuts">
<h3 class="resource-shortcuts__title">
{{ t('contacts', 'Create') }}
</h3>
Expand Down Expand Up @@ -327,6 +327,7 @@ import TeamResourceButton from './CircleDetails/TeamResourceButton.vue'
import MemberList from './MemberList/MemberList.vue'
import CircleActionsMixin from '../mixins/CircleActionsMixin.js'
import { CircleEdit, editCircle } from '../services/circles.ts'
import hideTeamSharedFolderCreation from '../services/hideTeamSharedFolderCreation.js'
import logger from '../services/logger.js'

import 'cropperjs/dist/cropper.css'
Expand Down Expand Up @@ -541,7 +542,7 @@ export default {
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 }),
icon: 'FolderOutlineIcon',
apiPath: 'files',
enabled: enabledApps.files !== undefined,
enabled: enabledApps.files !== undefined && !hideTeamSharedFolderCreation,
},
{
id: 'talk',
Expand Down
9 changes: 9 additions & 0 deletions src/services/hideTeamSharedFolderCreation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { loadState } from '@nextcloud/initial-state'

const hideTeamSharedFolderCreation = loadState('contacts', 'hideTeamSharedFolderCreation', false)
export default hideTeamSharedFolderCreation
48 changes: 48 additions & 0 deletions tests/unit/Controller/PageControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
use ChristophWurst\Nextcloud\Testing\TestCase;
use OC\App\CompareVersion;
use OCA\Contacts\AppInfo\Application;
use OCA\Contacts\ConfigLexicon;
use OCA\Contacts\Service\FederatedInvitesService;
use OCA\Contacts\Service\GroupSharingService;
use OCA\Contacts\Service\SocialApiService;
use OCP\App\IAppManager;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
use OCP\IAppConfig;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IUser;
Expand All @@ -33,6 +35,9 @@ class PageControllerTest extends TestCase {
/** @var IConfig|MockObject */
private $config;

/** @var IAppConfig|MockObject */
private $appConfig;

/** @var IInitialState|MockObject */
private $initialStateService;

Expand All @@ -59,6 +64,7 @@ protected function setUp(): void {

$this->request = $this->createMock(IRequest::class);
$this->config = $this->createMock(IConfig::class);
$this->appConfig = $this->createMock(IAppConfig::class);
$this->initialStateService = $this->createMock(IInitialState::class);
$this->languageFactory = $this->createMock(IFactory::class);
$this->userSession = $this->createMock(IUserSession::class);
Expand All @@ -76,6 +82,7 @@ private function buildController(ServerVersion $serverVersion): PageController {
$this->request,
$this->federatedInvitesService,
$this->config,
$this->appConfig,
$this->initialStateService,
$this->languageFactory,
$this->userSession,
Expand All @@ -99,6 +106,47 @@ public function testIndex() {
$this->assertTrue($result instanceof TemplateResponse);
}

public function testIndexProvidesHideTeamSharedFolderCreation() {
$user = $this->createMock(IUser::class);
$user->method('getUid')->willReturn('mrstest');
$this->userSession->method('getUser')->willReturn($user);

$this->appConfig->method('getValueBool')
->willReturnCallback(function (string $app, string $key, bool $default = false) {
$this->assertSame(Application::APP_ID, $app);
if ($key === ConfigLexicon::HIDE_TEAM_SHARED_FOLDER_CREATION) {
return true;
}
return $default;
});

$states = [];
$this->initialStateService->method('provideInitialState')
->willReturnCallback(function (string $key, mixed $value) use (&$states): void {
$states[$key] = $value;
});

$this->controller->index();

$this->assertTrue($states['hideTeamSharedFolderCreation']);
}

public function testIndexHideTeamSharedFolderCreationDefaultsToFalse() {
$user = $this->createMock(IUser::class);
$user->method('getUid')->willReturn('mrstest');
$this->userSession->method('getUser')->willReturn($user);

$states = [];
$this->initialStateService->method('provideInitialState')
->willReturnCallback(function (string $key, mixed $value) use (&$states): void {
$states[$key] = $value;
});

$this->controller->index();

$this->assertFalse($states['hideTeamSharedFolderCreation']);
}

public static function teamManagementDataProvider(): array {
return [
// [server major version, circles enabled, circles version compatible, expected]
Expand Down
Loading