Skip to content

Commit 1639a16

Browse files
committed
Add OCA.Files.Settings for Files Settings
Signed-off-by: Gary Kim <gary@garykim.dev>
1 parent 4503cff commit 1639a16

13 files changed

Lines changed: 321 additions & 29 deletions

apps/files/css/files.scss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
* See the COPYING-README file.
77
*/
88

9-
/* SETTINGS */
10-
#files-setting-showhidden {
11-
padding-bottom: 8px;
12-
}
13-
149
/* FILE MENU */
1510
.actions {
1611
padding: 5px;

apps/files/js/dist/files-app-settings.js

Lines changed: 75 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/files/js/dist/files-app-settings.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/files/js/dist/personal-settings.js

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/files/js/dist/personal-settings.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/files/js/dist/sidebar.js

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/files/js/dist/sidebar.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<!--
2+
- @copyright Copyright (c) 2019 Gary Kim <gary@garykim.dev>
3+
-
4+
- @author Gary Kim <gary@garykim.dev>
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+
<template>
23+
<div id="files-app-extra-settings">
24+
<template v-for="setting in settings">
25+
<div :ref="setting.name" :key="setting.name" />
26+
</template>
27+
</div>
28+
</template>
29+
30+
<script>
31+
export default {
32+
name: 'Settings',
33+
data() {
34+
return {
35+
settings: OCA.Files.Settings.settings,
36+
}
37+
},
38+
updated() {
39+
this.$nextTick(() => {
40+
this.settings.forEach(e => {
41+
this.$refs[e.name][0].appendChild(e.el())
42+
e.open()
43+
})
44+
})
45+
},
46+
beforeDestroy() {
47+
this.settings.forEach(e => {
48+
e.close()
49+
})
50+
},
51+
}
52+
</script>
53+
54+
<style lang="scss" scoped>
55+
#files-app-extra-settings {
56+
padding-bottom: 8px;
57+
}
58+
</style>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* @copyright Copyright (c) 2019 Gary Kim <gary@garykim.dev>
3+
* @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
4+
*
5+
* @author Gary Kim <gary@garykim.dev>
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+
*/
23+
24+
import Vue from 'vue'
25+
import Settings from './services/Settings'
26+
import SettingsView from './components/Settings'
27+
import Setting from './models/Setting'
28+
29+
Vue.prototype.t = t
30+
31+
// Init Files App Settings Service
32+
if (!window.OCA.Files) {
33+
window.OCA.Files = {}
34+
}
35+
Object.assign(window.OCA.Files, { Settings: new Settings() })
36+
Object.assign(window.OCA.Files.Settings, { Setting })
37+
38+
window.addEventListener('DOMContentLoaded', () => {
39+
// Init Vue app
40+
// eslint-disable-next-line
41+
new Vue({
42+
el: '#files-app-settings',
43+
render: h => h(SettingsView),
44+
})
45+
})

apps/files/src/models/Setting.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/**
2+
* @copyright Copyright (c) 2019 Gary Kim <gary@garykim.dev>
3+
* @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
4+
*
5+
* @author Gary Kim <gary@garykim.dev>
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+
*/
23+
24+
export default class Setting {
25+
26+
#close
27+
#el
28+
#name
29+
#open
30+
31+
/**
32+
* Create a new files app setting
33+
*
34+
* @param {string} name the name of this setting
35+
* @param {Function} component.el function that returns an unmounted dom element to be added
36+
* @param {Function} [component.open] callback for when setting is added
37+
* @param {Function} [component.close] callback for when setting is closed
38+
*/
39+
constructor(name, { el, open, close }) {
40+
this.#name = name
41+
this.#el = el
42+
this.#open = open
43+
this.#close = close
44+
if (typeof this.#open !== 'function') {
45+
this.#open = () => {}
46+
}
47+
if (typeof this.#close !== 'function') {
48+
this.#close = () => {}
49+
}
50+
}
51+
52+
get name() {
53+
return this.#name
54+
}
55+
56+
get el() {
57+
return this.#el
58+
}
59+
60+
get open() {
61+
return this.#open
62+
}
63+
64+
get close() {
65+
return this.#close
66+
}
67+
68+
}

0 commit comments

Comments
 (0)