Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable17] Better general setting #2342

Merged
merged 6 commits into from
Oct 22, 2019
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
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>