Skip to content

Commit

Permalink
Merge pull request #2342 from nextcloud/backport/2281/stable17
Browse files Browse the repository at this point in the history
[stable17] Better general setting
  • Loading branch information
danxuliu authored Oct 22, 2019
2 parents 35ac1e3 + 96d019e commit 142f91e
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 23 deletions.
2 changes: 1 addition & 1 deletion css/settings-admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
border-color: $color-error;
}

label {
div.signaling-server label {
margin: 0 20px;
display: inline-block;
}
Expand Down
16 changes: 8 additions & 8 deletions js/admin/general-settings.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/admin/general-settings.js.map

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions lib/Controller/FilesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use OCP\AppFramework\OCSController;
use OCP\Files\FileInfo;
use OCP\Files\NotFoundException;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IRequest;
use OCP\Share\IShare;
Expand All @@ -44,6 +45,8 @@ class FilesController extends OCSController {
private $manager;
/** @var Util */
private $util;
/** @var IConfig */
private $config;
/** @var IL10N */
private $l;

Expand All @@ -53,12 +56,14 @@ public function __construct(
string $userId,
Manager $manager,
Util $util,
IConfig $config,
IL10N $l10n
) {
parent::__construct($appName, $request);
$this->currentUser = $userId;
$this->manager = $manager;
$this->util = $util;
$this->config = $config;
$this->l = $l10n;
}

Expand Down Expand Up @@ -93,6 +98,10 @@ public function __construct(
* @throws OCSNotFoundException
*/
public function getRoom(string $fileId): DataResponse {
if ($this->config->getAppValue('spreed', 'conversations_files', '1') !== '1') {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}

$share = $this->util->getAnyPublicShareOfFileOwnedByUserOrAnyDirectShareOfFileAccessibleByUser($fileId, $this->currentUser);
$groupFolder = null;
if (!$share) {
Expand Down
7 changes: 6 additions & 1 deletion lib/Files/TemplateLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
class TemplateLoader {

public static function register(EventDispatcherInterface $dispatcher): void {
$dispatcher->addListener('OCA\Files::loadAdditionalScripts', function() {
$dispatcher->addListener('OCA\Files::loadAdditionalScripts', static function() {
self::loadTalkSidebarForFilesApp();
});
}
Expand All @@ -44,6 +44,11 @@ public static function register(EventDispatcherInterface $dispatcher): void {
* Files app.
*/
public static function loadTalkSidebarForFilesApp(): void {
$config = \OC::$server->getConfig();
if ($config->getAppValue('spreed', 'conversations_files', '1') !== '1') {
return;
}

Util::addStyle('spreed', 'merged-files');
Util::addScript('spreed', 'merged-files');
}
Expand Down
13 changes: 9 additions & 4 deletions lib/PublicShare/TemplateLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@
class TemplateLoader {

public static function register(EventDispatcherInterface $dispatcher): void {
$listener = function() {
$dispatcher->addListener('OCA\Files_Sharing::loadAdditionalScripts', static function() {
self::loadTalkSidebarUi();
};
$dispatcher->addListener('OCA\Files_Sharing::loadAdditionalScripts', $listener);
});
}

/**
Expand All @@ -49,7 +48,13 @@ public static function register(EventDispatcherInterface $dispatcher): void {
* This method should be called when loading additional scripts for the
* public share page of the server.
*/
public static function loadTalkSidebarUi() {
public static function loadTalkSidebarUi(): void {
$config = \OC::$server->getConfig();
if ($config->getAppValue('spreed', 'conversations_files', '1') !== '1' ||
$config->getAppValue('spreed', 'conversations_files_public_shares', '1') !== '1') {
return;
}

Util::addStyle('spreed', 'merged-public-share');
Util::addScript('spreed', 'merged-public-share');
}
Expand Down
2 changes: 2 additions & 0 deletions lib/Settings/Admin/GeneralSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public function __construct(IConfig $config,
*/
public function getForm(): TemplateResponse {
$this->initialStateService->provideInitialState('talk', 'start_calls', (int) $this->config->getAppValue('spreed', 'start_calls', '0'));
$this->initialStateService->provideInitialState('talk', 'conversations_files', (int) $this->config->getAppValue('spreed', 'conversations_files', '1'));
$this->initialStateService->provideInitialState('talk', 'conversations_files_public_shares', (int) $this->config->getAppValue('spreed', 'conversations_files_public_shares', '1'));
return new TemplateResponse('spreed', 'settings/admin/general-settings', [], '');
}

Expand Down
92 changes: 84 additions & 8 deletions vue/src/views/GeneralSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,38 @@
<Multiselect id="start_calls"
v-model="startCalls"
:options="startCallOptions"
:placeholder="t('spreed', 'Who can start a call?')"
label="label"
track-by="value" />
track-by="value"
:disabled="loading || loadingStartCalls"
@input="saveStartCalls" />
</p>
<p>
<em>{{ t('spreed', 'When a call has started, everyone with access to the conversation can join the call.') }}</em>
</p>

<h3>{{ t('spreed', 'Integration into other apps') }}</h3>

<p>
<input id="conversations_files"
v-model="conversationsFiles"
type="checkbox"
name="conversations_files"
class="checkbox"
:disabled="loading || loadingConversationsFiles"
@change="saveConversationsFiles">
<label for="conversations_files">{{ t('spreed', 'Allow conversations on files') }}</label>
</p>

<p>
<input id="conversations_files_public_shares"
v-model="conversationsFilesPublicShares"
type="checkbox"
name="conversations_files_public_shares"
class="checkbox"
:disabled="loading || loadingConversationsFiles || !conversationsFiles"
@change="saveConversationsFilesPublicShares">
<label for="conversations_files_public_shares">{{ t('spreed', 'Allow conversations on public shares for files') }}</label>
</p>
</div>
</template>
Expand All @@ -52,34 +82,80 @@ export default {

data() {
return {
loading: false,
loading: true,
loadingStartCalls: false,
loadingConversationsFiles: false,

startCallOptions,
startCalls: startCallOptions[0]
startCalls: startCallOptions[0],

conversationsFiles: true,
conversationsFilesPublicShares: true
}
},

mounted() {
this.loading = true
this.startCalls = startCallOptions[parseInt(OCP.InitialState.loadState('talk', 'start_calls'))]
this.conversationsFiles = parseInt(OCP.InitialState.loadState('talk', 'conversations_files')) === 1
this.conversationsFilesPublicShares = parseInt(OCP.InitialState.loadState('talk', 'conversations_files_public_shares')) === 1
this.loading = false
},

methods: {
saveChanges() {
this.loading = true
saveStartCalls() {
this.loadingStartCalls = true

OCP.AppConfig.setValue('spreed', 'start_calls', this.startCalls, {
OCP.AppConfig.setValue('spreed', 'start_calls', this.startCalls.value, {
success: function() {
this.loading = false
this.loadingStartCalls = false
}.bind(this)
})
},
saveConversationsFiles() {
this.loadingConversationsFiles = true

OCP.AppConfig.setValue('spreed', 'conversations_files', this.conversationsFiles ? '1' : '0', {
success: function() {
if (!this.conversationsFiles) {
// When the file integration is disabled, the share integration is also disabled
OCP.AppConfig.setValue('spreed', 'conversations_files_public_shares', '0', {
success: function() {
this.conversationsFilesPublicShares = false
this.loadingConversationsFiles = false
}.bind(this)
})
} else {
this.loadingConversationsFiles = false
}
}.bind(this)
})
},
saveConversationsFilesPublicShares() {
this.loadingConversationsFiles = true

OCP.AppConfig.setValue('spreed', 'conversations_files_public_shares', this.conversationsFilesPublicShares ? '1' : '0', {
success: function() {
this.loadingConversationsFiles = false
}.bind(this)
})
}
}
}
</script>
<style scoped>
<style scoped lang="scss">
p {
display: flex;
align-items: center;

label {
display: block;
margin-right: 10px;
}
}

.multiselect {
flex-grow: 1;
max-width: 300px;
}
</style>

0 comments on commit 142f91e

Please sign in to comment.