Skip to content

Commit

Permalink
Merge pull request #7139 from owncloud/redesign-reposition-notifications
Browse files Browse the repository at this point in the history
[full-ci] Reposition OcNotifications in web-runtime
  • Loading branch information
Pascal Wengerter committed Jun 30, 2022
2 parents 50c709a + f5da6ee commit 9591bfd
Show file tree
Hide file tree
Showing 20 changed files with 114 additions and 86 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/enhancement-reposition-notifications
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Enhancement: Reposition notifications

We've repositioned the notifications to no longer block the searchbar - they are now in the bottom right corner, above the (possibly visible) upload information.
It has also been redesigned to better fit the overall design.

https://github.com/owncloud/web/pull/7139
https://github.com/owncloud/web/issues/7082
13 changes: 13 additions & 0 deletions changelog/unreleased/enhancement-update-ods
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Enhancement: Update ODS to v14.0.0-alpha.2

We updated the ownCloud Design System to version 14.0.0-alpha.2. Please refer to the full changelog in the ODS release (linked) for more details. Summary:

- Change - Remove OcAlert component: https://github.com/owncloud/owncloud-design-system/pull/2210
- Change - Remove transition animations: https://github.com/owncloud/owncloud-design-system/pull/2210
- Change - Revamp animations: https://github.com/owncloud/owncloud-design-system/pull/2210
- Enhancement - Progress bar indeterminate state: https://github.com/owncloud/owncloud-design-system/pull/2200
- Enhancement - Redesign notifications: https://github.com/owncloud/owncloud-design-system/pull/2210
- Bugfix - Remove click event on OcIcon: https://github.com/owncloud/owncloud-design-system/pull/2216

https://github.com/owncloud/web/pull/7139
https://github.com/owncloud/owncloud-design-system/releases/tag/14.0.0-alpha.2
1 change: 1 addition & 0 deletions dev/docker/oc10.web.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"search"
],
"options": {
"topCenterNotifications": true,
"disablePreviews": true,
"displayResourcesLazy": false,
"sidebar": {
Expand Down
1 change: 1 addition & 0 deletions dev/docker/ocis.web.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"scope": "openid profile email"
},
"options": {
"topCenterNotifications": true,
"disablePreviews": true,
"displayResourcesLazy": false,
"sidebar": {
Expand Down
36 changes: 11 additions & 25 deletions packages/web-app-draw-io/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<template>
<main>
<oc-notifications>
<oc-notification-message
v-if="notificationMessage"
:message="notificationMessage"
:status="notificationStatus"
@close="clearNotificationMessage"
/>
</oc-notifications>
<div v-if="loading" class="oc-position-center">
<oc-spinner size="xlarge" />
<p v-translate class="oc-invisible">Loading media</p>
Expand Down Expand Up @@ -43,9 +35,7 @@ export default {
filePath: '',
fileExtension: '',
isReadOnly: null,
currentETag: null,
notificationMessage: null,
notificationStatus: null
currentETag: null
}),
computed: {
...mapGetters(['getToken']),
Expand Down Expand Up @@ -97,23 +87,19 @@ export default {
},
methods: {
...mapActions(['showMessage']),
error(error) {
errorPopup(error) {
this.showMessage({
title: this.$gettext('The diagram could not be loaded…'),
title: this.$gettext('An error occurred'),
desc: error,
status: 'danger'
})
},
errorPopup(error) {
this.notificationStatus = 'danger'
this.notificationMessage = error
},
successPopup(msg) {
this.notificationStatus = 'success'
this.notificationMessage = msg
},
clearNotificationMessage() {
this.notificationMessage = null
this.showMessage({
title: this.$gettext('The diagram was successfully saved'),
desc: msg,
status: 'success'
})
},
errorNotification(error) {
this.$refs.drawIoEditor.contentWindow.postMessage(
Expand All @@ -133,7 +119,7 @@ export default {
this.loading = false
})
.catch((error) => {
this.error(error)
this.errorPopup(error)
})
},
load() {
Expand All @@ -150,7 +136,7 @@ export default {
)
})
.catch((error) => {
this.error(error)
this.errorPopup(error)
})
},
importVisio() {
Expand Down Expand Up @@ -191,7 +177,7 @@ export default {
reader.readAsDataURL(blob)
})
.catch((error) => {
this.error(error)
this.errorPopup(error)
})
},
save(payload, auto = false) {
Expand Down
42 changes: 19 additions & 23 deletions packages/web-app-text-editor/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@
@closeApp="closeApp"
@save="save"
/>
<oc-notifications>
<oc-notification-message
v-if="lastError"
:message="lastError"
status="danger"
@close="clearLastError"
/>
</oc-notifications>
<div class="oc-flex editor-wrapper-height">
<div :class="showPreview ? 'oc-width-1-2' : 'oc-width-1-1'" class="oc-height-1-1">
<oc-textarea
Expand All @@ -37,14 +29,14 @@
</main>
</template>
<script>
import AppBar from './AppBar.vue'
import { useAppDefaults } from 'web-pkg/src/composables'
import { marked } from 'marked'
import sanitizeHtml from 'sanitize-html'
import { useTask } from 'vue-concurrency'
import { computed, onMounted, onBeforeUnmount, ref, unref } from '@vue/composition-api'
import { mapActions } from 'vuex'
import { DavPermission, DavProperty } from 'web-pkg/src/constants'
import { useAppDefaults } from 'web-pkg/src/composables'
import AppBar from './AppBar.vue'
export default {
name: 'TextEditor',
Expand Down Expand Up @@ -121,27 +113,25 @@ export default {
(error) => {
switch (error.statusCode) {
case 412:
lastError.value =
'This file was updated outside this window. Please refresh the page (all changes will be lost).'
this.errorPopup(
this.$gettext(
'This file was updated outside this window. Please refresh the page (all changes will be lost).'
)
)
break
case 500:
lastError.value = 'Error when contacting the server'
this.errorPopup(this.$gettext('Error when contacting the server'))
break
case 401:
lastError.value = "You're not authorized to save this file"
this.errorPopup(this.$gettext("You're not authorized to save this file"))
break
default:
lastError.value = error.message || error
this.errorPopup(error.message || error)
}
}
)
}).restartable()
const lastError = ref()
const clearLastError = () => {
lastError.value = null
}
const renderedMarkdown = computed(() => {
return unref(currentContent) && showPreview
? sanitizeHtml(marked(unref(currentContent)))
Expand Down Expand Up @@ -214,19 +204,25 @@ export default {
isDirty,
isReadOnly,
currentContent,
lastError,
renderedMarkdown,
config,
// methods
clearLastError,
save,
handleSKey,
handleUnload
}
},
methods: {
...mapActions(['createModal', 'hideModal'])
...mapActions(['createModal', 'hideModal', 'showMessage']),
errorPopup(error) {
this.showMessage({
title: this.$gettext('An error occurred'),
desc: error,
status: 'danger'
})
}
}
}
</script>
Expand Down
4 changes: 2 additions & 2 deletions packages/web-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
"axios": "^0.26.1",
"cross-fetch": "^3.0.6",
"easygettext": "https://github.com/owncloud/easygettext/archive/refs/tags/v2.18.1-oc.tar.gz",
"filesize": "^8.0.7",
"filesize": "^9.0.11",
"focus-trap": "^6.4.0",
"focus-trap-vue": "^1.1.1",
"fuse.js": "^6.5.3",
"lodash-es": "^4.17.21",
"luxon": "^2.4.0",
"marked": "^4.0.12",
"oidc-client": "1.11.5",
"owncloud-design-system": "^13.2.0-rc.1",
"owncloud-design-system": "^14.0.0-alpha.2",
"owncloud-sdk": "~3.0.0-alpha.14",
"p-queue": "^6.6.2",
"popper-max-size-modifier": "^0.2.0",
Expand Down
12 changes: 10 additions & 2 deletions packages/web-runtime/src/components/MessageBar.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<template>
<oc-notifications>
<oc-notifications :position="notificationPosition">
<oc-notification-message
v-for="item in $_ocMessages_limited"
:key="item.id"
:title="item.title"
:message="item.desc"
:status="item.status"
class="oc-width-large"
@close="deleteMessage(item)"
/>
</oc-notifications>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
props: {
activeMessages: {
Expand All @@ -22,6 +23,13 @@ export default {
}
},
computed: {
...mapGetters(['configuration']),
notificationPosition() {
if (this.configuration.options.topCenterNotifications) {
return 'top-center'
}
return 'default'
},
$_ocMessages_limited() {
return this.activeMessages ? this.activeMessages.slice(0, 5) : []
}
Expand Down
5 changes: 0 additions & 5 deletions packages/web-runtime/src/components/UploadInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -548,16 +548,11 @@ export default {
<style lang="scss">
#upload-info {
position: absolute;
right: 20px;
background-color: var(--oc-color-background-secondary);
bottom: 20px;
width: 400px;
z-index: 4;
@media (max-width: 640px) {
left: 0;
right: 0;
margin: 0 auto;
width: 100%;
max-width: 500px;
Expand Down
20 changes: 18 additions & 2 deletions packages/web-runtime/src/layouts/Application.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<top-bar :applications-list="applicationsList" :active-notifications="activeNotifications" />
</div>
<div id="web-content-main" class="oc-px-s oc-pb-s">
<message-bar :active-messages="activeMessages" @deleteMessage="deleteMessage" />
<div class="app-container oc-flex">
<sidebar-nav v-if="isSidebarVisible" class="app-navigation" :nav-items="sidebarNavItems" />
<router-view
Expand All @@ -18,7 +17,10 @@
/>
</div>
</div>
<upload-info />
<div class="snackbars">
<message-bar :active-messages="activeMessages" @deleteMessage="deleteMessage" />
<upload-info />
</div>
</div>
</template>

Expand Down Expand Up @@ -194,5 +196,19 @@ export default defineComponent({
}
}
}
.snackbars {
position: absolute;
right: 20px;
bottom: 20px;
@media (max-width: 640px) {
left: 0;
right: 0;
margin: 0 auto;
width: 100%;
max-width: 500px;
}
}
}
</style>
3 changes: 0 additions & 3 deletions packages/web-runtime/src/store/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ const state = {
}

const actions = {
toggleSidebar(context, visible) {
context.commit('TOGGLE_SIDEBAR', visible)
},
showMessage({ commit }, message) {
commit('ENQUEUE_MESSAGE', message)
},
Expand Down
3 changes: 3 additions & 0 deletions packages/web-runtime/src/store/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ const state = {
options: {
contextHelpers: true,
defaultExtension: 'files',
// ugly hack to still have notifications but don't have
// them blocking UI elements in acceptance/E2E tests
topCenterNotifications: false,
disablePreviews: false,
displayResourcesLazy: true,
homeFolder: '',
Expand Down
11 changes: 11 additions & 0 deletions packages/web-runtime/tests/unit/components/MessageBar.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { shallowMount, createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import DesignSystem from 'owncloud-design-system'
import GetText from 'vue-gettext'

import MessageBar from 'web-runtime/src/components/MessageBar.vue'

const localVue = createLocalVue()
localVue.use(Vuex)
localVue.use(DesignSystem)
localVue.use(GetText, {
translations: 'does-not-matter.json',
Expand Down Expand Up @@ -99,6 +101,15 @@ function getShallowWrapper(activeMessages = []) {
propsData: {
activeMessages
},
store: new Vuex.Store({
getters: {
configuration: () => ({
options: {
topCenterNotifications: false
}
})
}
}),
stubs: {
'oc-icon': true,
'oc-notifications': true,
Expand Down
Loading

0 comments on commit 9591bfd

Please sign in to comment.