Skip to content

Commit 510898a

Browse files
committed
feat(federations): provide admin setting to enable federations in Talk on instance
Signed-off-by: Maksim Sukharev <[email protected]>
1 parent 237488c commit 510898a

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed

lib/Settings/Admin/AdminSettings.php

+5
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function getForm(): TemplateResponse {
6868
$this->initGeneralSettings();
6969
$this->initAllowedGroups();
7070
$this->initCommands();
71+
$this->initFederation();
7172
$this->initMatterbridge();
7273
$this->initStunServers();
7374
$this->initTurnServers();
@@ -109,6 +110,10 @@ protected function initCommands(): void {
109110
$this->initialState->provideInitialState('commands', $result);
110111
}
111112

113+
protected function initFederation(): void {
114+
$this->initialState->provideInitialState('federation_enabled', $this->serverConfig->getAppValue('spreed', 'federation_enabled', 'no'));
115+
}
116+
112117
protected function initMatterbridge(): void {
113118
$error = '';
114119
try {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<!--
2+
- @copyright Copyright (c) 2024 Maksim Sukharev <antreesy.web@gmail.com>
3+
-
4+
- @author Maksim Sukharev <[email protected]>
5+
-
6+
- @license AGPL-3.0-or-later
7+
-
8+
- This program is free software: you can redistribute it and/or modify
9+
- it under the terms of the GNU Affero General Public License as
10+
- published by the Free Software Foundation, either version 3 of the
11+
- License, or (at your option) any later version.
12+
-
13+
- This program is distributed in the hope that it will be useful,
14+
- but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
- GNU Affero General Public License for more details.
17+
-
18+
- You should have received a copy of the GNU Affero General Public License
19+
- along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
-
21+
-->
22+
23+
<template>
24+
<section id="general_settings" class="federation section">
25+
<h2>
26+
{{ t('spreed', 'Federation') }}
27+
<small>{{ t('spreed', 'Beta') }}</small>
28+
</h2>
29+
30+
<NcCheckboxRadioSwitch :checked="isFederationEnabled"
31+
:disabled="loading"
32+
type="switch"
33+
@update:checked="saveFederationEnabled">
34+
{{ t('spreed', 'Enable Federation in Talk app') }}
35+
</NcCheckboxRadioSwitch>
36+
</section>
37+
</template>
38+
39+
<script>
40+
import { loadState } from '@nextcloud/initial-state'
41+
42+
import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
43+
44+
export default {
45+
name: 'Federation',
46+
47+
components: {
48+
NcCheckboxRadioSwitch,
49+
},
50+
51+
data() {
52+
return {
53+
loading: false,
54+
isFederationEnabled: loadState('spreed', 'federation_enabled') === 'yes',
55+
}
56+
},
57+
58+
methods: {
59+
saveFederationEnabled(value) {
60+
this.loading = true
61+
62+
OCP.AppConfig.setValue('spreed', 'federation_enabled', value ? 'yes' : 'no', {
63+
success: function() {
64+
this.loading = false
65+
this.isFederationEnabled = value
66+
}.bind(this),
67+
})
68+
},
69+
},
70+
}
71+
</script>
72+
73+
<style scoped lang="scss">
74+
small {
75+
color: var(--color-warning);
76+
border: 1px solid var(--color-warning);
77+
border-radius: 16px;
78+
padding: 0 9px;
79+
}
80+
</style>

src/views/AdminSettings.vue

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
<GeneralSettings />
2626
<MatterbridgeIntegration />
2727
<AllowedGroups />
28+
<!-- TODO remove OC.debug when Federation feature is ready -->
29+
<Federation v-if="OC.debug" />
2830
<BotsSettings />
2931
<Commands />
3032
<WebServerSetupChecks />
@@ -41,6 +43,7 @@
4143
import AllowedGroups from '../components/AdminSettings/AllowedGroups.vue'
4244
import BotsSettings from '../components/AdminSettings/BotsSettings.vue'
4345
import Commands from '../components/AdminSettings/Commands.vue'
46+
import Federation from '../components/AdminSettings/Federation.vue'
4447
import GeneralSettings from '../components/AdminSettings/GeneralSettings.vue'
4548
import HostedSignalingServer from '../components/AdminSettings/HostedSignalingServer.vue'
4649
import MatterbridgeIntegration from '../components/AdminSettings/MatterbridgeIntegration.vue'
@@ -58,6 +61,7 @@ export default {
5861
AllowedGroups,
5962
BotsSettings,
6063
Commands,
64+
Federation,
6165
GeneralSettings,
6266
HostedSignalingServer,
6367
MatterbridgeIntegration,

0 commit comments

Comments
 (0)