mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 08:16:43 -04:00
fix(files_versions): Migrate version name dialog from NcModal to NcDialog
* Resolves https://github.com/nextcloud/viewer/issues/2390 Make the version name dialog a real dialog instead of a modal. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
This commit is contained in:
parent
11a0878337
commit
ffefa2137e
6 changed files with 139 additions and 112 deletions
123
apps/files_versions/src/components/VersionLabelDialog.vue
Normal file
123
apps/files_versions/src/components/VersionLabelDialog.vue
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
<!--
|
||||
- SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
|
||||
- SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
-->
|
||||
<template>
|
||||
<NcDialog :buttons="dialogButtons"
|
||||
content-classes="version-label-modal"
|
||||
is-form
|
||||
:open="open"
|
||||
size="normal"
|
||||
:name="t('files_versions', 'Name this version')"
|
||||
@update:open="$emit('update:open', $event)"
|
||||
@submit="setVersionLabel(editedVersionLabel)">
|
||||
<NcTextField ref="labelInput"
|
||||
class="version-label-modal__input"
|
||||
:label="t('files_versions', 'Version name')"
|
||||
:placeholder="t('files_versions', 'Version name')"
|
||||
:value.sync="editedVersionLabel" />
|
||||
|
||||
<p class="version-label-modal__info">
|
||||
{{ t('files_versions', 'Named versions are persisted, and excluded from automatic cleanups when your storage quota is full.') }}
|
||||
</p>
|
||||
</NcDialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { t } from '@nextcloud/l10n'
|
||||
import { defineComponent } from 'vue'
|
||||
import svgCheck from '@mdi/svg/svg/check.svg?raw'
|
||||
|
||||
import NcDialog from '@nextcloud/vue/dist/Components/NcDialog.js'
|
||||
import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js'
|
||||
|
||||
type Focusable = Vue & { focus: () => void }
|
||||
|
||||
export default defineComponent({
|
||||
name: 'VersionLabelDialog',
|
||||
components: {
|
||||
NcDialog,
|
||||
NcTextField,
|
||||
},
|
||||
props: {
|
||||
open: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
versionLabel: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
editedVersionLabel: '',
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
dialogButtons() {
|
||||
const buttons: unknown[] = []
|
||||
if (this.versionLabel.trim() === '') {
|
||||
// If there is no label just offer a cancel action that just closes the dialog
|
||||
buttons.push({
|
||||
label: t('files_versions', 'Cancel'),
|
||||
})
|
||||
} else {
|
||||
// If there is already a label set, offer to remove the version label
|
||||
buttons.push({
|
||||
label: t('files_versions', 'Remove version name'),
|
||||
type: 'error',
|
||||
nativeType: 'reset',
|
||||
callback: () => { this.setVersionLabel('') },
|
||||
})
|
||||
}
|
||||
return [
|
||||
...buttons,
|
||||
{
|
||||
label: t('files_versions', 'Save version name'),
|
||||
type: 'primary',
|
||||
nativeType: 'submit',
|
||||
icon: svgCheck,
|
||||
},
|
||||
]
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
versionLabel: {
|
||||
immediate: true,
|
||||
handler(label) {
|
||||
this.editedVersionLabel = label ?? ''
|
||||
},
|
||||
},
|
||||
open: {
|
||||
immediate: true,
|
||||
handler(open) {
|
||||
if (open) {
|
||||
this.$nextTick(() => (this.$refs.labelInput as Focusable).focus())
|
||||
}
|
||||
this.editedVersionLabel = this.versionLabel
|
||||
},
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
setVersionLabel(label: string) {
|
||||
this.$emit('label-update', label)
|
||||
},
|
||||
|
||||
t,
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.version-label-modal {
|
||||
&__info {
|
||||
color: var(--color-text-maxcontrast);
|
||||
margin-block: calc(3 * var(--default-grid-baseline));
|
||||
}
|
||||
|
||||
&__input {
|
||||
margin-block-start: calc(2 * var(--default-grid-baseline));
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
<!--
|
||||
- SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
|
||||
- SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
-->
|
||||
<template>
|
||||
<form class="version-label-modal"
|
||||
@submit.prevent="setVersionLabel(innerVersionLabel)">
|
||||
<label>
|
||||
<div class="version-label-modal__title">{{ t('files_versions', 'Version name') }}</div>
|
||||
<NcTextField ref="labelInput"
|
||||
:value.sync="innerVersionLabel"
|
||||
:placeholder="t('files_versions', 'Version name')"
|
||||
:label-outside="true" />
|
||||
</label>
|
||||
|
||||
<div class="version-label-modal__info">
|
||||
{{ t('files_versions', 'Named versions are persisted, and excluded from automatic cleanups when your storage quota is full.') }}
|
||||
</div>
|
||||
|
||||
<div class="version-label-modal__actions">
|
||||
<NcButton :disabled="innerVersionLabel.trim().length === 0" @click="setVersionLabel('')">
|
||||
{{ t('files_versions', 'Remove version name') }}
|
||||
</NcButton>
|
||||
<NcButton type="primary" native-type="submit">
|
||||
<template #icon>
|
||||
<Check />
|
||||
</template>
|
||||
{{ t('files_versions', 'Save version name') }}
|
||||
</NcButton>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Check from 'vue-material-design-icons/Check.vue'
|
||||
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
|
||||
import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js'
|
||||
import { translate } from '@nextcloud/l10n'
|
||||
|
||||
import { defineComponent } from 'vue'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'VersionLabelForm',
|
||||
components: {
|
||||
NcButton,
|
||||
NcTextField,
|
||||
Check,
|
||||
},
|
||||
props: {
|
||||
versionLabel: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
innerVersionLabel: this.versionLabel,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$nextTick(() => {
|
||||
(this.$refs.labelInput as Vue).$el.getElementsByTagName('input')[0].focus()
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
setVersionLabel(label: string) {
|
||||
this.$emit('label-update', label)
|
||||
},
|
||||
|
||||
t: translate,
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.version-label-modal {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
flex-direction: column;
|
||||
height: 250px;
|
||||
padding: 16px;
|
||||
|
||||
&__title {
|
||||
margin-bottom: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
&__info {
|
||||
margin-top: 12px;
|
||||
color: var(--color-text-maxcontrast);
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-top: 64px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -28,11 +28,10 @@
|
|||
</template>
|
||||
<NcLoadingIcon v-if="loading" slot="loader" class="files-list-viewer__loader" />
|
||||
</VirtualScrolling>
|
||||
<NcModal v-if="showVersionLabelForm"
|
||||
:title="t('files_versions', 'Name this version')"
|
||||
@close="showVersionLabelForm = false">
|
||||
<VersionLabelForm :version-label="editedVersion.label" @label-update="handleLabelUpdate" />
|
||||
</NcModal>
|
||||
<VersionLabelDialog v-if="editedVersion"
|
||||
:open.sync="showVersionLabelForm"
|
||||
:version-label="editedVersion.label"
|
||||
@label-update="handleLabelUpdate" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
@ -40,25 +39,23 @@
|
|||
import path from 'path'
|
||||
|
||||
import { showError, showSuccess } from '@nextcloud/dialogs'
|
||||
import isMobile from '@nextcloud/vue/dist/Mixins/isMobile.js'
|
||||
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'
|
||||
import { getCurrentUser } from '@nextcloud/auth'
|
||||
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
|
||||
import NcModal from '@nextcloud/vue/dist/Components/NcModal.js'
|
||||
import isMobile from '@nextcloud/vue/dist/Mixins/isMobile.js'
|
||||
|
||||
import { fetchVersions, deleteVersion, restoreVersion, setVersionLabel } from '../utils/versions.ts'
|
||||
import Version from '../components/Version.vue'
|
||||
import VirtualScrolling from '../components/VirtualScrolling.vue'
|
||||
import VersionLabelForm from '../components/VersionLabelForm.vue'
|
||||
import VersionLabelDialog from '../components/VersionLabelDialog.vue'
|
||||
|
||||
export default {
|
||||
name: 'VersionTab',
|
||||
components: {
|
||||
Version,
|
||||
VirtualScrolling,
|
||||
VersionLabelForm,
|
||||
VersionLabelDialog,
|
||||
NcLoadingIcon,
|
||||
NcModal,
|
||||
},
|
||||
mixins: [
|
||||
isMobile,
|
||||
|
|
@ -71,6 +68,7 @@ export default {
|
|||
versions: [],
|
||||
loading: false,
|
||||
showVersionLabelForm: false,
|
||||
editedVersion: null,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
|
|
|||
4
dist/files_versions-files_versions.js
vendored
4
dist/files_versions-files_versions.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -2,6 +2,7 @@ SPDX-License-Identifier: MIT
|
|||
SPDX-License-Identifier: ISC
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-License-Identifier: BSD-3-Clause
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
SPDX-License-Identifier: (MPL-2.0 OR Apache-2.0)
|
||||
SPDX-FileCopyrightText: string_decoder developers
|
||||
|
|
@ -58,6 +59,7 @@ SPDX-FileCopyrightText: David Clark
|
|||
SPDX-FileCopyrightText: Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
SPDX-FileCopyrightText: Christoph Wurst
|
||||
SPDX-FileCopyrightText: Ben Drucker
|
||||
SPDX-FileCopyrightText: Austin Andrews
|
||||
SPDX-FileCopyrightText: Arnout Kazemier
|
||||
SPDX-FileCopyrightText: Anthony Fu <https://github.com/antfu>
|
||||
SPDX-FileCopyrightText: Andris Reinman
|
||||
|
|
@ -71,6 +73,9 @@ This file is generated from multiple sources. Included packages:
|
|||
- @babel/runtime
|
||||
- version: 7.25.0
|
||||
- license: MIT
|
||||
- @mdi/svg
|
||||
- version: 7.4.47
|
||||
- license: Apache-2.0
|
||||
- @nextcloud/auth
|
||||
- version: 2.4.0
|
||||
- license: GPL-3.0-or-later
|
||||
|
|
|
|||
2
dist/files_versions-files_versions.js.map
vendored
2
dist/files_versions-files_versions.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue