Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Create empty state component

bsatarnejad349975d5f5d5
diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml
index 3ad6121e297..61ebb4332fd 100644
--- a/config/locales/js-en.yml
+++ b/config/locales/js-en.yml
@@ -576,6 +576,9 @@ en:
mark_as_read: 'Mark as read'
text_update_date: "%{date} by"
total_count_warning: "Showing the %{newest_count} most recent notifications. %{more_count} more are not displayed."
+ empty_state:
+ no_notification: "Looks like you're all caught up."
+ no_selection: "Click on a notification to view all activity details."
menu:
accountable: 'Accountable'
assigned: 'Assigned'
diff --git a/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.html b/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.html
new file mode 100644
index 00000000000..124c84e0039
--- /dev/null
+++ b/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.html
@@ -0,0 +1,19 @@
+<div
+ class="work-packages--details op-empty-state hidden-for-mobile"
+ data-qa-selector="op-empty-state"
+>
+ <div class="work-packages-tab-view--overflow op-empty-state--content">
+ <ng-container *ngIf="(hasNotifications$ | async); else noNotification">
+ <img [src]="image.no_selection" class="op-empty-state--content--image"/>
+ <p class="op-empty-state--content--text">
+ <span>{{ text.no_selection }}</span>
+ </p>
+ </ng-container>
+ <ng-template #noNotification>
+ <img [src]="image.no_notification" class="op-empty-state--content--image"/>
+ <p class="op-empty-state--content--text">
+ <span> {{ text.no_notification }}</span>
+ </p>
+ </ng-template>
+ </div>
+</div>
diff --git a/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.sass b/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.sass
new file mode 100644
index 00000000000..70e112fc4b8
--- /dev/null
+++ b/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.sass
@@ -0,0 +1,20 @@
+.op-empty-state
+ overflow: auto
+ position: relative
+ border-left: 2px solid #eee
+ border-top: 2px solid #eee
+ padding: 0
+
+ &--content
+ text-align: center
+ width: 100%
+ top: 35%
+ position: absolute
+
+ &--text
+ white-space: nowrap
+ color: var(--gray-dark)
+ font-size: larger
+
+ &--image
+ margin-bottom: 15px
\ No newline at end of file
diff --git a/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.ts b/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.ts
new file mode 100644
index 00000000000..93275b16f2d
--- /dev/null
+++ b/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.ts
@@ -0,0 +1,61 @@
+// -- copyright
+// OpenProject is an open source project management software.
+// Copyright (C) 2012-2021 the OpenProject GmbH
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License version 3.
+//
+// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+// Copyright (C) 2006-2013 Jean-Philippe Lang
+// Copyright (C) 2010-2013 the ChiliProject Team
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See COPYRIGHT and LICENSE files for more details.
+//++
+
+import {
+ ChangeDetectionStrategy,
+ Component,
+} from '@angular/core';
+import { I18nService } from 'core-app/core/i18n/i18n.service';
+import { imagePath } from 'core-app/shared/helpers/images/path-helper';
+import { IanCenterService } from '../state/ian-center.service';
+
+@Component({
+ templateUrl: './empty-state.component.html',
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ styleUrls: ['./empty-state.component.sass'],
+ selector: 'op-empty-state',
+})
+export class EmptyStateComponent {
+ image = {
+ no_notification: imagePath('notification-center/empty-state-no-notification.svg'),
+ no_selection: imagePath('notification-center/empty-state-no-selection.svg'),
+ };
+
+ text = {
+ no_notification: this.I18n.t('js.notifications.center.empty_state.no_notification'),
+ no_selection: this.I18n.t('js.notifications.center.empty_state.no_selection'),
+ };
+
+ hasNotifications$ = this.storeService.query.hasNotifications$;
+
+ constructor(
+ readonly I18n:I18nService,
+ readonly storeService:IanCenterService,
+ ) {
+ }
+}
diff --git a/frontend/src/app/features/in-app-notifications/in-app-notifications.module.ts b/frontend/src/app/features/in-app-notifications/in-app-notifications.module.ts
index cd03051ab31..d2be657c270 100644
--- a/frontend/src/app/features/in-app-notifications/in-app-notifications.module.ts
+++ b/frontend/src/app/features/in-app-notifications/in-app-notifications.module.ts
@@ -18,6 +18,7 @@ import { NotificationSettingsButtonComponent } from './center/toolbar/settings/n
import { ActivateFacetButtonComponent } from './center/toolbar/facet/activate-facet-button.component';
import { MarkAllAsReadButtonComponent } from './center/toolbar/mark-all-as-read/mark-all-as-read-button.component';
import { OpenprojectContentLoaderModule } from 'core-app/shared/components/op-content-loader/openproject-content-loader.module';
+import { EmptyStateComponent } from './center/empty-state/empty-state.component';
@NgModule({
declarations: [
@@ -30,6 +31,7 @@ import { OpenprojectContentLoaderModule } from 'core-app/shared/components/op-co
ActivateFacetButtonComponent,
MarkAllAsReadButtonComponent,
IanMenuComponent,
+ EmptyStateComponent,
],
imports: [
OPSharedModule,
diff --git a/frontend/src/app/features/in-app-notifications/in-app-notifications.routes.ts b/frontend/src/app/features/in-app-notifications/in-app-notifications.routes.ts
index dde72356faa..47e49fb5f32 100644
--- a/frontend/src/app/features/in-app-notifications/in-app-notifications.routes.ts
+++ b/frontend/src/app/features/in-app-notifications/in-app-notifications.routes.ts
@@ -32,6 +32,7 @@ import { WorkPackageSplitViewComponent } from 'core-app/features/work-packages/r
import { InAppNotificationCenterComponent } from 'core-app/features/in-app-notifications/center/in-app-notification-center.component';
import { InAppNotificationCenterPageComponent } from 'core-app/features/in-app-notifications/center/in-app-notification-center-page.component';
import { WorkPackagesBaseComponent } from 'core-app/features/work-packages/routing/wp-base/wp--base.component';
+import { EmptyStateComponent } from './center/empty-state/empty-state.component';
export interface INotificationPageQueryParameters {
filter?:string;
@@ -60,6 +61,7 @@ export const IAN_ROUTES:Ng2StateDeclaration[] = [
},
views: {
'content-left': { component: InAppNotificationCenterComponent },
+ 'content-right': { component: EmptyStateComponent },
},
},
...makeSplitViewRoutes(
diff --git a/frontend/src/assets/images/notification-center/empty-state-no-notification.svg b/frontend/src/assets/images/notification-center/empty-state-no-notification.svg
new file mode 100644
index 00000000000..c5da58b30e6
--- /dev/null
+++ b/frontend/src/assets/images/notification-center/empty-state-no-notification.svg
@@ -0,0 +1,10 @@
+<svg width="132" height="124" viewBox="0 0 132 124" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M114.826 107.919H17.0488C17.0488 107.919 17.0488 94.9595 24.6955 94.9595C24.6955 64.6791 17.0488 14.5857 65.9376 14.5857C117.334 14.5857 105.425 77.6386 105.425 94.9595C111.843 94.9595 114.367 103.599 114.826 107.919Z" stroke="#878787" stroke-width="3"/>
+<path d="M66.0615 2C57.6376 2 56.6181 10.7227 57.1613 15.0841C58.4566 14.7934 62.0502 14.2118 66.0615 14.2118C70.0729 14.2118 73.165 14.7934 74.2096 15.0841C75.0036 10.7227 74.4855 2 66.0615 2Z" fill="#878787" stroke="#878787" stroke-width="3"/>
+<path d="M24.6338 95L54.1538 94.6826" stroke="#878787" stroke-width="3"/>
+<path d="M65.9323 122C54.6001 122 53.9399 112.696 55.0263 108.044H77.2143C78.1754 112.696 76.4622 122 65.9323 122Z" fill="#BFEEB6" stroke="#878787" stroke-width="3"/>
+<path d="M115.328 77.8879L119.402 81.9377L123.476 85.9875M120.092 67.5452H132M115.328 57.7009L123.476 49.6013" stroke="#878787" stroke-width="3"/>
+<path d="M16.6719 77.8879L12.5978 81.9377L8.52374 85.9875M11.9083 67.5452H-0.000469521M16.6719 57.7009L8.52374 49.6013" stroke="#878787" stroke-width="3"/>
+<path d="M118.591 32.0312C118.591 42.3432 110.179 50.7181 99.7833 50.7181C89.3876 50.7181 80.9756 42.3432 80.9756 32.0312C80.9756 21.7191 89.3876 13.3442 99.7833 13.3442C110.179 13.3442 118.591 21.7191 118.591 32.0312Z" fill="#D1E5F5" stroke="#878787" stroke-width="3"/>
+<path d="M93.7292 40H94.5303V29.0526H93.7292C93.3042 29.0526 92.8967 29.2301 92.5962 29.5459C92.2958 29.8618 92.127 30.2902 92.127 30.7368V38.3158C92.127 38.7625 92.2958 39.1909 92.5962 39.5067C92.8967 39.8226 93.3042 40 93.7292 40ZM106.547 29.0526H100.939L101.838 26.2164C101.918 25.9633 101.94 25.6938 101.902 25.43C101.863 25.1663 101.766 24.9159 101.618 24.6994C101.469 24.483 101.274 24.3067 101.048 24.1851C100.822 24.0635 100.572 24.0001 100.318 24H100.138L96.1325 28.5794V40H104.945L108.079 32.7613L108.149 32.4211V30.7368C108.149 30.2902 107.98 29.8618 107.68 29.5459C107.379 29.2301 106.972 29.0526 106.547 29.0526V29.0526Z" fill="#878787"/>
+</svg>
diff --git a/frontend/src/assets/images/notification-center/empty-state-no-selection.svg b/frontend/src/assets/images/notification-center/empty-state-no-selection.svg
new file mode 100644
index 00000000000..8549900406d
--- /dev/null
+++ b/frontend/src/assets/images/notification-center/empty-state-no-selection.svg
@@ -0,0 +1,10 @@
+<svg width="132" height="124" viewBox="0 0 132 124" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M114.826 107.919H17.0488C17.0488 107.919 17.0488 94.9595 24.6955 94.9595C24.6955 64.6791 17.0488 14.5857 65.9376 14.5857C117.334 14.5857 105.425 77.6386 105.425 94.9595C111.843 94.9595 114.367 103.599 114.826 107.919Z" stroke="#878787" stroke-width="3"/>
+<path d="M66.0615 2C57.6376 2 56.6181 10.7227 57.1613 15.0841C58.4566 14.7934 62.0502 14.2118 66.0615 14.2118C70.0729 14.2118 73.165 14.7934 74.2096 15.0841C75.0036 10.7227 74.4855 2 66.0615 2Z" fill="#878787" stroke="#878787" stroke-width="3"/>
+<path d="M24.6338 95L54.1538 94.6826" stroke="#878787" stroke-width="3"/>
+<path d="M65.9323 122C54.6001 122 53.9399 112.696 55.0263 108.044H77.2143C78.1754 112.696 76.4622 122 65.9323 122Z" fill="#BFEEB6" stroke="#878787" stroke-width="3"/>
+<path d="M115.328 77.8879L119.402 81.9377L123.476 85.9875M120.092 67.5452H132M115.328 57.7009L123.476 49.6013" stroke="#878787" stroke-width="3"/>
+<path d="M16.6719 77.8879L12.5978 81.9377L8.52374 85.9875M11.9083 67.5452H-0.000469521M16.6719 57.7009L8.52374 49.6013" stroke="#878787" stroke-width="3"/>
+<path d="M118.591 32.0312C118.591 42.3432 110.179 50.7181 99.7833 50.7181C89.3876 50.7181 80.9756 42.3432 80.9756 32.0312C80.9756 21.7191 89.3876 13.3442 99.7833 13.3442C110.179 13.3442 118.591 21.7191 118.591 32.0312Z" fill="#D1E5F5" stroke="#878787" stroke-width="3"/>
+<path d="M101.549 21.3146V29.8093C101.549 30.7103 101.505 31.5964 101.416 32.4676C101.327 33.329 101.213 34.2448 101.074 35.215H98.5803C98.4418 34.2448 98.328 33.329 98.2389 32.4676C98.1498 31.5964 98.1053 30.7103 98.1053 29.8093V21.3146H101.549ZM97.5264 40.7693C97.5264 40.4623 97.5808 40.1703 97.6897 39.8931C97.8084 39.6158 97.9668 39.3782 98.1647 39.1802C98.3725 38.9822 98.615 38.8238 98.8921 38.705C99.1692 38.5862 99.4661 38.5268 99.7828 38.5268C100.09 38.5268 100.382 38.5862 100.659 38.705C100.936 38.8238 101.173 38.9822 101.371 39.1802C101.579 39.3782 101.742 39.6158 101.861 39.8931C101.98 40.1703 102.039 40.4623 102.039 40.7693C102.039 41.0861 101.98 41.3831 101.861 41.6603C101.742 41.9276 101.579 42.1603 101.371 42.3583C101.173 42.5563 100.936 42.7098 100.659 42.8187C100.382 42.9375 100.09 42.9969 99.7828 42.9969C99.4661 42.9969 99.1692 42.9375 98.8921 42.8187C98.615 42.7098 98.3725 42.5563 98.1647 42.3583C97.9668 42.1603 97.8084 41.9276 97.6897 41.6603C97.5808 41.3831 97.5264 41.0861 97.5264 40.7693Z" fill="#878787"/>
+</svg>
diff --git a/spec/features/notifications/notification_center/split_screen_spec.rb b/spec/features/notifications/notification_center/split_screen_spec.rb
index 9418b8ead60..3d7c3c04c59 100644
--- a/spec/features/notifications/notification_center/split_screen_spec.rb
+++ b/spec/features/notifications/notification_center/split_screen_spec.rb
@@ -26,7 +26,7 @@ describe "Split screen in the notification center", type: :feature, js: true do
end
let(:center) { ::Pages::Notifications::Center.new }
- let(:split_screen) { ::Pages::SplitWorkPackage.new work_package }
+ let(:split_screen) { ::Pages::Notifications::SplitScreen.new work_package }
describe 'basic use case' do
current_user { recipient }
@@ -54,6 +54,8 @@ describe "Split screen in the notification center", type: :feature, js: true do
it 'can navigate between the tabs' do
center.expect_bell_count 2
+ split_screen.expect_empty_state
+
center.click_item notification
split_screen.expect_open
@@ -77,7 +79,22 @@ describe "Split screen in the notification center", type: :feature, js: true do
# The split screen can be closed
split_screen.close
- split_screen.expect_closed
+ split_screen.expect_empty_state
+ end
+ end
+
+ context 'with no unread notification' do
+ current_user { recipient }
+
+ before do
+ Notification.where(recipient: recipient).update_all(read_ian: true)
+ visit home_path
+ center.open
+ end
+
+ it 'can switch between multiple notifications and the split screen remains open and updates accordingly' do
+ center.expect_bell_count 0
+ split_screen.expect_caught_up
end
end
end
diff --git a/spec/support/pages/notifications/split_screen.rb b/spec/support/pages/notifications/split_screen.rb
new file mode 100644
index 00000000000..dfa53fcc690
--- /dev/null
+++ b/spec/support/pages/notifications/split_screen.rb
@@ -0,0 +1,52 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2021 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+require 'support/pages/page'
+require 'support/pages/work_packages/split_work_package'
+
+module Pages
+ module Notifications
+ class SplitScreen < ::Pages::SplitWorkPackage
+ include ::Components::NgSelectAutocompleteHelpers
+
+ def initialize(work_package, project = nil)
+ super work_package, project
+ @selector = '.work-packages--details'
+ end
+
+ def expect_empty_state
+ expect(page).to have_selector('[data-qa-selector="op-empty-state"]')
+ end
+
+ def expect_caught_up
+ text = I18n.t('js.notifications.center.empty_state.no_notification')
+ expect(page).to have_selector('[data-qa-selector="op-empty-state"]', text: text)
+ end
+ end
+ end
+end