Skip to content

Commit da49e3f

Browse files
committed
Port share by mail settings to vue
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
1 parent 18dd460 commit da49e3f

File tree

104 files changed

+326
-212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+326
-212
lines changed

.github/workflows/command-compile.yml

+6
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ jobs:
8686
npm ci
8787
npm run build --if-present
8888
89+
- name: Build css
90+
run: npm run sass
91+
92+
- name: Build icons css
93+
run: npm run sass:icons
94+
8995
- name: Commit and push default
9096
if: ${{ needs.init.outputs.arg1 != 'fixup' && needs.init.outputs.arg1 != 'amend' }}
9197
run: |

apps/sharebymail/css/settings-admin.css

-3
This file was deleted.

apps/sharebymail/js/settings-admin.js

-46
This file was deleted.

apps/sharebymail/lib/Settings/Admin.php

+9-12
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,29 @@
2424
namespace OCA\ShareByMail\Settings;
2525

2626
use OCP\AppFramework\Http\TemplateResponse;
27+
use OCP\AppFramework\Services\IInitialState;
2728
use OCP\IL10N;
2829
use OCP\Settings\IDelegatedSettings;
2930

3031
class Admin implements IDelegatedSettings {
32+
private SettingsManager $settingsManager;
33+
private IL10N $l;
34+
private IInitialState $initialState;
3135

32-
/** @var SettingsManager */
33-
private $settingsManager;
34-
35-
/** @var IL10N */
36-
private $l;
37-
38-
public function __construct(SettingsManager $settingsManager, IL10N $l) {
36+
public function __construct(SettingsManager $settingsManager, IL10N $l, IInitialState $initialState) {
3937
$this->settingsManager = $settingsManager;
4038
$this->l = $l;
39+
$this->initialState = $initialState;
4140
}
4241

4342
/**
4443
* @return TemplateResponse
4544
*/
4645
public function getForm() {
47-
$parameters = [
48-
'sendPasswordMail' => $this->settingsManager->sendPasswordByMail(),
49-
'replyToInitiator' => $this->settingsManager->replyToInitiator()
50-
];
46+
$this->initialState->provideInitialState('sendPasswordMail', $this->settingsManager->sendPasswordByMail());
47+
$this->initialState->provideInitialState('replyToInitiator', $this->settingsManager->replyToInitiator());
5148

52-
return new TemplateResponse('sharebymail', 'settings-admin', $parameters, '');
49+
return new TemplateResponse('sharebymail', 'settings-admin', [], '');
5350
}
5451

5552
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<!--
2+
- @copyright 2022 Carl Schwan <carl@carlschwan.eu>
3+
-
4+
- @author Carl Schwan <carl@carlschwan.eu>
5+
-
6+
- @license GNU AGPL version 3 or any later version
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+
<SettingsSection :title="t('sharebymail', 'Share by mail')"
25+
:description="t('sharebymail', 'Allows users to share a personalized link to a file or folder by putting in an email address.')">
26+
<CheckboxRadioSwitch type="switch"
27+
:checked.sync="sendPasswordMail"
28+
@update:checked="update('sendpasswordmail', sendPasswordMail)">
29+
{{ t('sharebymail', 'Send password by mail') }}
30+
</CheckboxRadioSwitch>
31+
32+
<CheckboxRadioSwitch type="switch"
33+
:checked.sync="replyToInitiator"
34+
@update:checked="update('replyToInitiator', replyToInitiator)">
35+
{{ t('sharebymail', 'Reply to initiator') }}
36+
</CheckboxRadioSwitch>
37+
</SettingsSection>
38+
</template>
39+
40+
<script>
41+
import CheckboxRadioSwitch from '@nextcloud/vue/dist/Components/CheckboxRadioSwitch'
42+
import SettingsSection from '@nextcloud/vue/dist/Components/SettingsSection'
43+
import { loadState } from '@nextcloud/initial-state'
44+
import { showError } from '@nextcloud/dialogs'
45+
import axios from '@nextcloud/axios'
46+
import { generateOcsUrl } from '@nextcloud/router'
47+
import confirmPassword from '@nextcloud/password-confirmation'
48+
49+
export default {
50+
name: 'AdminSettings',
51+
components: {
52+
CheckboxRadioSwitch,
53+
SettingsSection,
54+
},
55+
data() {
56+
return {
57+
sendPasswordMail: loadState('sharebymail', 'sendPasswordMail'),
58+
replyToInitiator: loadState('sharebymail', 'replyToInitiator'),
59+
}
60+
},
61+
methods: {
62+
async update(key, value) {
63+
await confirmPassword()
64+
const url = generateOcsUrl('/apps/provisioning_api/api/v1/config/apps/{appId}/{key}', {
65+
appId: 'sharebymail',
66+
key,
67+
})
68+
const stringValue = value ? 'yes' : 'no'
69+
try {
70+
const { data } = await axios.post(url, {
71+
value: stringValue,
72+
})
73+
this.handleResponse({
74+
status: data.ocs?.meta?.status
75+
})
76+
} catch (e) {
77+
this.handleResponse({
78+
errorMessage: t('sharebymail', 'Unable to update share by mail config'),
79+
error: e,
80+
})
81+
}
82+
},
83+
async handleResponse({ status, errorMessage, error }) {
84+
if (status !== 'ok') {
85+
showError(errorMessage)
86+
console.error(errorMessage, error)
87+
}
88+
},
89+
}
90+
}
91+
</script>

apps/sharebymail/src/main-admin.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* @copyright 2022 Carl Schwan <carl@carlschwan.eu>
3+
*
4+
* @author Carl Schwan <carl@carlschwan.eu>
5+
*
6+
* @license GNU AGPL version 3 or any later version
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+
import Vue from 'vue'
24+
import { getRequestToken } from '@nextcloud/auth'
25+
import { translate as t } from '@nextcloud/l10n'
26+
import '@nextcloud/dialogs/styles/toast.scss'
27+
28+
import AdminSettings from './components/AdminSettings'
29+
30+
__webpack_nonce__ = btoa(getRequestToken())
31+
32+
Vue.mixin({
33+
methods: {
34+
t,
35+
},
36+
})
37+
38+
const AdminSettingsView = Vue.extend(AdminSettings)
39+
new AdminSettingsView().$mount('#vue-admin-sharebymail')
+23-21
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
<?php
2-
/** @var array $_ */
2+
/**
3+
* @copyright 2022 Carl Schwan <carl@carlschwan.eu>
4+
*
5+
* @author Carl Schwan <carl@carlschwan.eu>
6+
*
7+
* @license GNU AGPL version 3 or any later version
8+
*
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Affero General Public License as
11+
* published by the Free Software Foundation, either version 3 of the
12+
* License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Affero General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Affero General Public License
20+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
*
22+
*/
323

4-
/** @var \OCP\IL10N $l */
5-
script('sharebymail', 'settings-admin');
6-
style('sharebymail', 'settings-admin');
24+
\OCP\Util::addScript('sharebymail', 'vue-settings-admin-sharebymail');
725
?>
8-
<div id="ncShareByMailSettings" class="section">
9-
<h2><?php p($l->t('Share by mail')); ?></h2>
10-
<p class="settings-hint"><?php p($l->t('Allows users to share a personalized link to a file or folder by putting in an email address.')); ?></p>
11-
12-
<p>
13-
<input id="sendPasswordMail" type="checkbox" class="checkbox" <?php if ($_['sendPasswordMail']) {
14-
p('checked');
15-
} ?> />
16-
<label for="sendPasswordMail"><?php p($l->t('Send password by mail')); ?></label><br/>
17-
18-
<input id="replyToInitiator" type="checkbox" class="checkbox" <?php if ($_['replyToInitiator']) {
19-
p('checked');
20-
} ?> />
21-
<label for="replyToInitiator"><?php p($l->t('Reply to initiator')); ?></label>
22-
</p>
23-
24-
</div>
26+
<div id="vue-admin-sharebymail"></div>

dist/comments-comments-app.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/comments-comments-app.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-common.js

+2-2
Large diffs are not rendered by default.

dist/core-common.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)