Skip to content

Commit

Permalink
Merge pull request #3997 from nextcloud/fix/force_save
Browse files Browse the repository at this point in the history
Make saving indicator a button for force-save
  • Loading branch information
mejo- authored Mar 27, 2023
2 parents 99c9c29 + bf64e0e commit 43ad16c
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 28 deletions.
4 changes: 2 additions & 2 deletions js/editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/editor.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/files-modal.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/files-modal.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions js/text-editors.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-editors.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-files.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-files.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-public.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-text.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-text.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-viewer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-viewer.js.map

Large diffs are not rendered by default.

31 changes: 25 additions & 6 deletions src/components/Editor/Status.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@
<template>
<div class="text-editor__session-list">
<div v-tooltip="lastSavedStatusTooltip" class="save-status" :class="saveStatusClass">
<SavingIndicator :saving="saveStatusClass === 'saving'"
:error="saveStatusClass === 'error'" />
<NcButton type="tertiary"
@click="onClickSave">
<template #icon>
<SavingIndicator :saving="saveStatusClass === 'saving'"
:error="saveStatusClass === 'error'" />
</template>
</NcButton>
</div>
<SessionList :sessions="sessions">
<p slot="lastSaved" class="last-saved">
Expand All @@ -38,19 +43,21 @@
<script>

import SavingIndicator from '../SavingIndicator.vue'
import { ERROR_TYPE } from './../../services/SyncService.js'
import { ERROR_TYPE } from '../../services/SyncService.js'
import moment from '@nextcloud/moment'
import { Tooltip } from '@nextcloud/vue'
import { NcButton, Tooltip } from '@nextcloud/vue'
import {
useIsMobileMixin,
useIsPublicMixin,
useSyncServiceMixin,
} from '../Editor.provider.js'
import refreshMoment from '../../mixins/refreshMoment.js'

export default {
name: 'Status',

components: {
NcButton,
SavingIndicator,
SessionList: () => import(/* webpackChunkName: "editor-collab" */'./SessionList.vue'),
GuestNameDialog: () => import(/* webpackChunkName: "editor-guest" */'./GuestNameDialog.vue'),
Expand All @@ -60,7 +67,12 @@ export default {
Tooltip,
},

mixins: [useIsMobileMixin, useIsPublicMixin, refreshMoment],
mixins: [
useIsMobileMixin,
useIsPublicMixin,
useSyncServiceMixin,
refreshMoment,
],

props: {
hasConnectionIssue: {
Expand Down Expand Up @@ -124,13 +136,20 @@ export default {
return Object.values(this.sessions).find((session) => session.isCurrent)
},
lastSavedString() {
// Make this a dependent of refreshMoment so it will be recomputed
// Make this a dependent of refreshMoment, so it will be recomputed
/* eslint-disable-next-line no-unused-expressions */
this.refreshMoment
return moment(this.document.lastSavedVersionTime * 1000).fromNow()
},
},

methods: {
onClickSave() {
if (this.dirtyStateIndicator) {
this.$syncService.forceSave()
}
},
},
}
</script>

Expand Down
17 changes: 16 additions & 1 deletion src/components/SavingIndicator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<template>
<span class="material-design-icon">
<CheckIcon />
<CheckIcon class="saving-indicator-check" />
<span class="saving-indicator-container" :class="{error, saving}">
<CircleMedium class="saving-indicator" />
</span>
Expand Down Expand Up @@ -53,6 +53,14 @@ export default defineComponent({
</script>

<style lang="scss" scoped>
.saving-indicator-check {
cursor: pointer;

:deep(svg) {
fill: var(--color-text-lighter);
}
}

.saving-indicator-container {
display: none;
position: absolute;
Expand All @@ -63,14 +71,21 @@ export default defineComponent({
position: relative;
top: 6px;
left: 6px;
cursor: pointer;
}
}

&.saving > span {
color: var(--color-primary);
:deep(svg) {
fill: var(--color-primary);
}
}
&.error > span {
color: var(--color-error);
:deep(svg) {
fill: var(--color-primary);
}
}
}
</style>

0 comments on commit 43ad16c

Please sign in to comment.