Skip to content

Commit ce0b75c

Browse files
Merge pull request #47436 from nextcloud/backport/47407/stable30
[stable30] fix(files_versions): Migrate version name dialog from NcModal to NcDialog
2 parents 11a0878 + ffefa21 commit ce0b75c

6 files changed

+139
-112
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<!--
2+
- SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
3+
- SPDX-License-Identifier: AGPL-3.0-or-later
4+
-->
5+
<template>
6+
<NcDialog :buttons="dialogButtons"
7+
content-classes="version-label-modal"
8+
is-form
9+
:open="open"
10+
size="normal"
11+
:name="t('files_versions', 'Name this version')"
12+
@update:open="$emit('update:open', $event)"
13+
@submit="setVersionLabel(editedVersionLabel)">
14+
<NcTextField ref="labelInput"
15+
class="version-label-modal__input"
16+
:label="t('files_versions', 'Version name')"
17+
:placeholder="t('files_versions', 'Version name')"
18+
:value.sync="editedVersionLabel" />
19+
20+
<p class="version-label-modal__info">
21+
{{ t('files_versions', 'Named versions are persisted, and excluded from automatic cleanups when your storage quota is full.') }}
22+
</p>
23+
</NcDialog>
24+
</template>
25+
26+
<script lang="ts">
27+
import { t } from '@nextcloud/l10n'
28+
import { defineComponent } from 'vue'
29+
import svgCheck from '@mdi/svg/svg/check.svg?raw'
30+
31+
import NcDialog from '@nextcloud/vue/dist/Components/NcDialog.js'
32+
import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js'
33+
34+
type Focusable = Vue & { focus: () => void }
35+
36+
export default defineComponent({
37+
name: 'VersionLabelDialog',
38+
components: {
39+
NcDialog,
40+
NcTextField,
41+
},
42+
props: {
43+
open: {
44+
type: Boolean,
45+
default: false,
46+
},
47+
versionLabel: {
48+
type: String,
49+
default: '',
50+
},
51+
},
52+
data() {
53+
return {
54+
editedVersionLabel: '',
55+
}
56+
},
57+
computed: {
58+
dialogButtons() {
59+
const buttons: unknown[] = []
60+
if (this.versionLabel.trim() === '') {
61+
// If there is no label just offer a cancel action that just closes the dialog
62+
buttons.push({
63+
label: t('files_versions', 'Cancel'),
64+
})
65+
} else {
66+
// If there is already a label set, offer to remove the version label
67+
buttons.push({
68+
label: t('files_versions', 'Remove version name'),
69+
type: 'error',
70+
nativeType: 'reset',
71+
callback: () => { this.setVersionLabel('') },
72+
})
73+
}
74+
return [
75+
...buttons,
76+
{
77+
label: t('files_versions', 'Save version name'),
78+
type: 'primary',
79+
nativeType: 'submit',
80+
icon: svgCheck,
81+
},
82+
]
83+
},
84+
},
85+
watch: {
86+
versionLabel: {
87+
immediate: true,
88+
handler(label) {
89+
this.editedVersionLabel = label ?? ''
90+
},
91+
},
92+
open: {
93+
immediate: true,
94+
handler(open) {
95+
if (open) {
96+
this.$nextTick(() => (this.$refs.labelInput as Focusable).focus())
97+
}
98+
this.editedVersionLabel = this.versionLabel
99+
},
100+
},
101+
},
102+
methods: {
103+
setVersionLabel(label: string) {
104+
this.$emit('label-update', label)
105+
},
106+
107+
t,
108+
},
109+
})
110+
</script>
111+
112+
<style scoped lang="scss">
113+
.version-label-modal {
114+
&__info {
115+
color: var(--color-text-maxcontrast);
116+
margin-block: calc(3 * var(--default-grid-baseline));
117+
}
118+
119+
&__input {
120+
margin-block-start: calc(2 * var(--default-grid-baseline));
121+
}
122+
}
123+
</style>

apps/files_versions/src/components/VersionLabelForm.vue

-99
This file was deleted.

apps/files_versions/src/views/VersionTab.vue

+8-10
Original file line numberDiff line numberDiff line change
@@ -28,37 +28,34 @@
2828
</template>
2929
<NcLoadingIcon v-if="loading" slot="loader" class="files-list-viewer__loader" />
3030
</VirtualScrolling>
31-
<NcModal v-if="showVersionLabelForm"
32-
:title="t('files_versions', 'Name this version')"
33-
@close="showVersionLabelForm = false">
34-
<VersionLabelForm :version-label="editedVersion.label" @label-update="handleLabelUpdate" />
35-
</NcModal>
31+
<VersionLabelDialog v-if="editedVersion"
32+
:open.sync="showVersionLabelForm"
33+
:version-label="editedVersion.label"
34+
@label-update="handleLabelUpdate" />
3635
</div>
3736
</template>
3837

3938
<script>
4039
import path from 'path'
4140

4241
import { showError, showSuccess } from '@nextcloud/dialogs'
43-
import isMobile from '@nextcloud/vue/dist/Mixins/isMobile.js'
4442
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'
4543
import { getCurrentUser } from '@nextcloud/auth'
4644
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
47-
import NcModal from '@nextcloud/vue/dist/Components/NcModal.js'
45+
import isMobile from '@nextcloud/vue/dist/Mixins/isMobile.js'
4846

4947
import { fetchVersions, deleteVersion, restoreVersion, setVersionLabel } from '../utils/versions.ts'
5048
import Version from '../components/Version.vue'
5149
import VirtualScrolling from '../components/VirtualScrolling.vue'
52-
import VersionLabelForm from '../components/VersionLabelForm.vue'
50+
import VersionLabelDialog from '../components/VersionLabelDialog.vue'
5351

5452
export default {
5553
name: 'VersionTab',
5654
components: {
5755
Version,
5856
VirtualScrolling,
59-
VersionLabelForm,
57+
VersionLabelDialog,
6058
NcLoadingIcon,
61-
NcModal,
6259
},
6360
mixins: [
6461
isMobile,
@@ -71,6 +68,7 @@ export default {
7168
versions: [],
7269
loading: false,
7370
showVersionLabelForm: false,
71+
editedVersion: null,
7472
}
7573
},
7674
computed: {

dist/files_versions-files_versions.js

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

dist/files_versions-files_versions.js.license

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ SPDX-License-Identifier: MIT
22
SPDX-License-Identifier: ISC
33
SPDX-License-Identifier: GPL-3.0-or-later
44
SPDX-License-Identifier: BSD-3-Clause
5+
SPDX-License-Identifier: Apache-2.0
56
SPDX-License-Identifier: AGPL-3.0-or-later
67
SPDX-License-Identifier: (MPL-2.0 OR Apache-2.0)
78
SPDX-FileCopyrightText: string_decoder developers
@@ -58,6 +59,7 @@ SPDX-FileCopyrightText: David Clark
5859
SPDX-FileCopyrightText: Christoph Wurst <christoph@winzerhof-wurst.at>
5960
SPDX-FileCopyrightText: Christoph Wurst
6061
SPDX-FileCopyrightText: Ben Drucker
62+
SPDX-FileCopyrightText: Austin Andrews
6163
SPDX-FileCopyrightText: Arnout Kazemier
6264
SPDX-FileCopyrightText: Anthony Fu <https://github.com/antfu>
6365
SPDX-FileCopyrightText: Andris Reinman
@@ -71,6 +73,9 @@ This file is generated from multiple sources. Included packages:
7173
- @babel/runtime
7274
- version: 7.25.0
7375
- license: MIT
76+
- @mdi/svg
77+
- version: 7.4.47
78+
- license: Apache-2.0
7479
- @nextcloud/auth
7580
- version: 2.4.0
7681
- license: GPL-3.0-or-later

dist/files_versions-files_versions.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)