From 662d5a3105f45f073a30bc8aa2e7cb95c669f30b Mon Sep 17 00:00:00 2001 From: Jan Date: Mon, 17 Jul 2023 15:58:45 +0200 Subject: [PATCH 1/7] Add dismiss button to oc-notification-message (#9421) * Add dismiss button to oc-notification-message * Add changelog item --- ...button-to-oc-notification-message-component | 8 ++++++++ .../OcNotificationMessage.vue | 18 ++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 packages/design-system/changelog/unreleased/enhancement-add-dismiss-button-to-oc-notification-message-component diff --git a/packages/design-system/changelog/unreleased/enhancement-add-dismiss-button-to-oc-notification-message-component b/packages/design-system/changelog/unreleased/enhancement-add-dismiss-button-to-oc-notification-message-component new file mode 100644 index 00000000000..fdac647d414 --- /dev/null +++ b/packages/design-system/changelog/unreleased/enhancement-add-dismiss-button-to-oc-notification-message-component @@ -0,0 +1,8 @@ +Enhancement: Add dismiss button to OcNotificationsMessage component + +We've added added dismiss button to the OcNotificationsMessage component, +which closes the open notification immediately. + +https://github.com/owncloud/web/pull/9421 +https://github.com/owncloud/web/issues/9420 + diff --git a/packages/design-system/src/components/OcNotificationMessage/OcNotificationMessage.vue b/packages/design-system/src/components/OcNotificationMessage/OcNotificationMessage.vue index 8e375299ee4..b2f00588c48 100644 --- a/packages/design-system/src/components/OcNotificationMessage/OcNotificationMessage.vue +++ b/packages/design-system/src/components/OcNotificationMessage/OcNotificationMessage.vue @@ -4,11 +4,16 @@ :class="classes" >
-
- -
- {{ title }} +
+
+ +
+ {{ title }} +
+
import { defineComponent } from 'vue' import OcIcon from '../OcIcon/OcIcon.vue' +import OcButton from '../OcButton/OcButton.vue' /** * Notifications are used to inform users about errors, warnings and as confirmations for their actions. @@ -31,7 +37,8 @@ export default defineComponent({ status: 'ready', release: '1.0.0', components: { - OcIcon + OcIcon, + OcButton }, props: { /** @@ -114,7 +121,6 @@ export default defineComponent({ + + +Component to display error log. +```js + + + +``` + diff --git a/packages/design-system/src/components/OcNotificationMessage/OcNotificationMessage.spec.ts b/packages/design-system/src/components/OcNotificationMessage/OcNotificationMessage.spec.ts index 55a33eed664..44f9c16703a 100644 --- a/packages/design-system/src/components/OcNotificationMessage/OcNotificationMessage.spec.ts +++ b/packages/design-system/src/components/OcNotificationMessage/OcNotificationMessage.spec.ts @@ -1,5 +1,5 @@ import OcNotificationMessage from './OcNotificationMessage.vue' -import { shallowMount } from 'web-test-helpers' +import { defaultPlugins, mount } from 'web-test-helpers' jest.useFakeTimers() describe('OcNotificationMessage', () => { @@ -68,6 +68,26 @@ describe('OcNotificationMessage', () => { }) }) + describe('errorLogContent prop', () => { + it('should render OcErrorLogComponent, if errorLogContent is provided', async () => { + const wrapper = getWrapper({ errorLogContent: 'X-REQUEST-ID: 1234' }) + const errorLogToggleButtonEl = wrapper.find(selectors.errorLogToggleButton) + + expect(errorLogToggleButtonEl.exists()).toBeTruthy() + await errorLogToggleButtonEl.trigger('click') + + const errorLogEl = wrapper.find(selectors.errorLog) + expect(errorLogEl.exists()).toBeTruthy() + }) + + it('should not render OcErrorLogComponent, if errorLogContent is not provided', () => { + const wrapper = getWrapper() + const errorLogToggleButtonEl = wrapper.find(selectors.errorLogToggleButton) + + expect(errorLogToggleButtonEl.exists()).toBeFalsy() + }) + }) + it('should emit close after set timout', () => { const wrapper = getWrapper({ timeout: 1 }) @@ -79,14 +99,22 @@ describe('OcNotificationMessage', () => { const selectors = { messageTitle: '.oc-notification-message-title', messageContent: '.oc-notification-message-content', - messageWrapper: '.oc-notification-message div' + messageWrapper: '.oc-notification-message div', + errorLog: '.oc-error-log', + errorLogToggleButton: '.oc-notification-message-error-log-toggle-button' } function getWrapper(props = {}) { - return shallowMount(OcNotificationMessage, { + return mount(OcNotificationMessage, { props: { ...props, title: 'Test passed' + }, + global: { + stubs: { + 'oc-icon': true + }, + plugins: defaultPlugins() } }) } diff --git a/packages/design-system/src/components/OcNotificationMessage/OcNotificationMessage.vue b/packages/design-system/src/components/OcNotificationMessage/OcNotificationMessage.vue index b2f00588c48..f6d84eb7acc 100644 --- a/packages/design-system/src/components/OcNotificationMessage/OcNotificationMessage.vue +++ b/packages/design-system/src/components/OcNotificationMessage/OcNotificationMessage.vue @@ -5,29 +5,42 @@ >
-
+
{{ title }}
- +
-
- {{ message }} +
+
+ + + + + +
+