diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index ac43828a3c..3ffea8610b 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -22,10 +22,6 @@ class Application extends App implements IBootstrap { public const APP_ID = 'contacts'; - public const AVAIL_SETTINGS = [ - 'allowSocialSync' => 'yes', - ]; - public function __construct() { parent::__construct(self::APP_ID); } diff --git a/lib/Settings/AdminSettings.php b/lib/Settings/AdminSettings.php index 0162b25c44..46af297800 100644 --- a/lib/Settings/AdminSettings.php +++ b/lib/Settings/AdminSettings.php @@ -8,25 +8,17 @@ namespace OCA\Contacts\Settings; use OCA\Contacts\AppInfo\Application; +use OCA\Contacts\Service\SocialApiService; use OCP\AppFramework\Http\TemplateResponse; use OCP\IConfig; use OCP\IInitialStateService; use OCP\Settings\ISettings; class AdminSettings implements ISettings { - protected $appName; - - /** - * Admin constructor. - * - * @param IConfig $config - * @param IL10N $l - */ public function __construct( private IConfig $config, private IInitialStateService $initialStateService, ) { - $this->appName = Application::APP_ID; } /** diff --git a/src/components/AdminSettings.vue b/src/components/AdminSettings.vue index 0d79be5c7f..255dbefe4d 100644 --- a/src/components/AdminSettings.vue +++ b/src/components/AdminSettings.vue @@ -26,7 +26,7 @@ export default { name: 'AdminSettings', data() { return { - allowSocialSync: loadState('contacts', 'allowSocialSync') === 'yes', + allowSocialSync: loadState('contacts', 'allowSocialSync', true), } }, diff --git a/src/components/AppNavigation/ContactsSettings.vue b/src/components/AppNavigation/ContactsSettings.vue index 5e2099613f..0dfb806375 100644 --- a/src/components/AppNavigation/ContactsSettings.vue +++ b/src/components/AppNavigation/ContactsSettings.vue @@ -12,7 +12,7 @@ - + initialState = $this->createMock(IInitialState::class); + $this->socialApiService = $this->createMock(SocialApiService::class); + $this->settings = new AdminSettings($this->initialState, $this->socialApiService); + } + + public static function allowSocialSyncProvider(): array { + return [[true], [false]]; + } + + #[DataProvider('allowSocialSyncProvider')] + public function testGetFormProvidesBooleanInitialState(bool $allowed): void { + $this->socialApiService + ->method('syncAllowedByAdmin') + ->willReturn($allowed); + $this->initialState + ->expects($this->once()) + ->method('provideInitialState') + ->with('allowSocialSync', $allowed); + + $form = $this->settings->getForm(); + $this->assertInstanceOf(TemplateResponse::class, $form); + } +}