-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Expand file tree
/
Copy pathMountOptions.vue
More file actions
120 lines (106 loc) · 3.77 KB
/
Copy pathMountOptions.vue
File metadata and controls
120 lines (106 loc) · 3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<!--
- SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<script setup lang="ts">
import type { IMountOptions } from '../../types.ts'
import { mdiChevronDown, mdiChevronRight } from '@mdi/js'
import { loadState } from '@nextcloud/initial-state'
import { t } from '@nextcloud/l10n'
import { computed, ref, useId, watchEffect } from 'vue'
import NcButton from '@nextcloud/vue/components/NcButton'
import NcCheckboxRadioSwitch from '@nextcloud/vue/components/NcCheckboxRadioSwitch'
import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper'
import NcSelect from '@nextcloud/vue/components/NcSelect'
import { parseMountOptions } from '../../store/storages.ts'
import { MountOptionsCheckFilesystem } from '../../types.ts'
const mountOptions = defineModel<Partial<IMountOptions>>({ required: true })
watchEffect(() => {
if (Object.keys(mountOptions.value).length === 0) {
// parse and initialize with defaults if needed
mountOptions.value = parseMountOptions(mountOptions.value)
}
})
const { hasEncryption } = loadState<{ hasEncryption: boolean }>('files_external', 'settings')
const idButton = useId()
const idFieldset = useId()
const isExpanded = ref(false)
const checkFilesystemOptions = [
{
label: t('files_external', 'Never'),
value: MountOptionsCheckFilesystem.Never,
},
{
label: t('files_external', 'Once every direct access'),
value: MountOptionsCheckFilesystem.OncePerRequest,
},
{
label: t('files_external', 'Always'),
value: MountOptionsCheckFilesystem.Always,
},
]
const checkFilesystem = computed({
get() {
return checkFilesystemOptions.find((option) => option.value === mountOptions.value.filesystem_check_changes)
},
set(value) {
mountOptions.value.filesystem_check_changes = value?.value ?? MountOptionsCheckFilesystem.OncePerRequest
},
})
</script>
<template>
<div :class="$style.mountOptions">
<NcButton
:id="idButton"
:aria-controls="idFieldset"
:aria-expanded="isExpanded"
variant="tertiary-no-background"
@click="isExpanded = !isExpanded">
<template #icon>
<NcIconSvgWrapper directional :path="isExpanded ? mdiChevronDown : mdiChevronRight" />
</template>
{{ t('files_external', 'Mount options') }}
</NcButton>
<fieldset
v-show="isExpanded"
:id="idFieldset"
:class="$style.mountOptions__fieldset"
:aria-labelledby="idButton">
<NcSelect
v-model="checkFilesystem"
:inputLabel="t('files_external', 'Check filesystem changes')"
:options="checkFilesystemOptions" />
<NcCheckboxRadioSwitch v-model="modelValue.readonly" type="switch">
{{ t('files_external', 'Read only') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch v-model="modelValue.previews" type="switch">
{{ t('files_external', 'Enable previews') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch v-model="modelValue.enable_sharing" type="switch">
{{ t('files_external', 'Enable sharing') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch v-if="hasEncryption" v-model="modelValue.encrypt" type="switch">
{{ t('files_external', 'Enable encryption') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch v-model="modelValue.encoding_compatibility" type="switch">
{{ t('files_external', 'Compatibility with Mac NFD encoding (slow)') }}
</NcCheckboxRadioSwitch>
</fieldset>
</div>
</template>
<style module>
.mountOptions {
background-color: hsl(from var(--color-primary-element-light) h s calc(l * 1.045));
border-radius: var(--border-radius-element);
display: flex;
flex-direction: column;
gap: var(--default-grid-baseline);
width: 100%;
}
.mountOptions__fieldset {
display: flex;
flex-direction: column;
gap: var(--default-grid-baseline);
padding-inline: calc(2 * var(--default-grid-baseline)) var(--default-grid-baseline);
}
</style>