Skip to content

Commit 5a2541d

Browse files
committed
fix: Fix styling of collission dialog and move it out of the editor
Signed-off-by: Julius Härtl <[email protected]>
1 parent 19e3e30 commit 5a2541d

File tree

3 files changed

+40
-33
lines changed

3 files changed

+40
-33
lines changed

src/components/CollisionResolveDialog.vue

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,34 @@
2222

2323
<template>
2424
<div id="resolve-conflicts" class="collision-resolve-dialog" :class="{'icon-loading': clicked }">
25-
<button :disabled="clicked" @click="resolveThisVersion" data-cy="resolveThisVersion">
25+
<NcButton :disabled="clicked" data-cy="resolveThisVersion" @click="resolveThisVersion">
2626
{{ t('text', 'Use current version') }}
27-
</button>
28-
<button :disabled="clicked" @click="resolveServerVersion" data-cy="resolveServerVersion">
27+
</NcButton>
28+
<NcButton :disabled="clicked" data-cy="resolveServerVersion" @click="resolveServerVersion">
2929
{{ t('text', 'Use the saved version') }}
30-
</button>
30+
</NcButton>
3131
</div>
3232
</template>
3333

3434
<script>
35+
import { useEditorMixin, useSyncServiceMixin } from './Editor.provider.js'
36+
import { NcButton } from '@nextcloud/vue'
37+
import markdownit from './../markdownit/index.js'
3538
export default {
3639
name: 'CollisionResolveDialog',
40+
components: {
41+
NcButton,
42+
},
43+
mixins: [
44+
useEditorMixin,
45+
useSyncServiceMixin,
46+
],
47+
props: {
48+
syncError: {
49+
type: Object,
50+
default: null,
51+
}
52+
},
3753
data() {
3854
return {
3955
clicked: false,
@@ -42,11 +58,17 @@ export default {
4258
methods: {
4359
resolveThisVersion() {
4460
this.clicked = true
45-
this.$emit('resolve-use-this-version')
61+
this.$syncService.forceSave()
62+
this.$editor.setOptions({ editable: !this.readOnly })
63+
this.$syncService.startSync()
4664
},
4765
resolveServerVersion() {
4866
this.clicked = true
49-
this.$emit('resolve-use-server-version')
67+
const markdownItHtml = markdownit.render(this.syncError.data.outsideChange)
68+
this.$editor.setOptions({ editable: !this.readOnly })
69+
this.$editor.commands.setContent(markdownItHtml)
70+
this.$syncService.forceSave()
71+
this.$syncService.startSync()
5072
},
5173
},
5274
}
@@ -55,17 +77,12 @@ export default {
5577
<style scoped lang="scss">
5678
#resolve-conflicts {
5779
display: flex;
58-
position: fixed;
59-
z-index: 10000;
60-
bottom: 0;
61-
max-width: 900px;
62-
width: 100vw;
80+
width: 100%;
6381
margin: auto;
6482
padding: 20px 0;
6583
6684
button {
6785
margin: auto;
68-
box-shadow: 0 0 10px var(--color-box-shadow);
6986
}
7087
}
7188
</style>

src/components/Editor.vue

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
:sync-error="syncError"
3232
:has-connection-issue="hasConnectionIssue"
3333
@reconnect="reconnect" />
34+
3435
<Wrapper v-if="displayed"
3536
:sync-error="syncError"
3637
:has-connection-issue="hasConnectionIssue"
@@ -71,10 +72,6 @@
7172
:content="syncError.data.outsideChange"
7273
:is-rich-editor="isRichEditor" />
7374
</Wrapper>
74-
75-
<CollisionResolveDialog v-if="hasSyncCollission && !readOnly"
76-
@resolve-use-this-version="resolveUseThisVersion"
77-
@resolve-use-server-version="resolveUseServerVersion" />
7875
</div>
7976
</template>
8077

@@ -132,7 +129,6 @@ export default {
132129
MenuBar,
133130
Reader: () => import(/* webpackChunkName: "editor" */'./Reader.vue'),
134131
Status,
135-
CollisionResolveDialog: () => import(/* webpackChunkName: "editor" */'./CollisionResolveDialog.vue'),
136132
},
137133
mixins: [
138134
isMobile,
@@ -423,20 +419,6 @@ export default {
423419
.off('save', this.onSave)
424420
},
425421
426-
resolveUseThisVersion() {
427-
this.$syncService.forceSave()
428-
this.$editor.setOptions({ editable: !this.readOnly })
429-
this.$syncService.startSync()
430-
},
431-
432-
resolveUseServerVersion() {
433-
const markdownItHtml = markdownit.render(this.syncError.data.outsideChange)
434-
this.$editor.setOptions({ editable: !this.readOnly })
435-
this.$editor.commands.setContent(markdownItHtml)
436-
this.$syncService.forceSave()
437-
this.$syncService.startSync()
438-
},
439-
440422
reconnect() {
441423
this.contentLoaded = false
442424
this.hasConnectionIssue = false
@@ -891,8 +873,9 @@ export default {
891873
.text-editor__wrapper.has-conflicts > .content-wrapper {
892874
width: 50%;
893875
#read-only-editor {
894-
margin: 0px;
876+
margin: 0px auto;
895877
padding-top: 50px;
878+
overflow: initial;
896879
}
897880
}
898881

src/components/Editor/DocumentStatus.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
<p v-if="lock" class="msg msg-locked">
4444
<Lock /> {{ t('text', 'This file is opened read-only as it is currently locked by {user}.', { user: lock.displayName }) }}
4545
</p>
46+
47+
<CollisionResolveDialog v-if="hasSyncCollission" :sync-error="syncError" />
4648
</div>
4749
</template>
4850

@@ -52,11 +54,13 @@ import { ERROR_TYPE, IDLE_TIMEOUT } from './../../services/SyncService.js'
5254
import AlertOctagonOutline from 'vue-material-design-icons/AlertOctagonOutline.vue'
5355
import Lock from 'vue-material-design-icons/Lock.vue'
5456
import { NcEmptyContent } from '@nextcloud/vue'
57+
import CollisionResolveDialog from '../CollisionResolveDialog.vue'
5558
5659
export default {
5760
name: 'DocumentStatus',
5861
5962
components: {
63+
CollisionResolveDialog,
6064
AlertOctagonOutline,
6165
Lock,
6266
NcEmptyContent,
@@ -107,7 +111,10 @@ export default {
107111

108112
<style scoped lang="scss">
109113
.document-status {
110-
position: relative;
114+
position: sticky;
115+
top: 0;
116+
z-index: 10000;
117+
height: 50px;
111118
background-color: var(--color-main-background);
112119
113120
.msg {

0 commit comments

Comments
 (0)