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

[38909] Shorten watcher entry and use op-principal

Oliver Günther1fd51c730182
diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/watchers-tab.html b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/watchers-tab.html
index 42badbee969..5805a5de4b3 100644
--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/watchers-tab.html
+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/watchers-tab.html
@@ -9,10 +9,10 @@
<div class="work-package--watchers form--selected-value--list"
[ngClass]="{'-read-only': !allowedToRemove}">
- <wp-watcher-entry
+ <op-wp-watcher-entry
*ngFor="let watcher of watching; trackBy:trackByHref"
[watcher]="watcher">
- </wp-watcher-entry>
+ </op-wp-watcher-entry>
</div>
<div class="work-package--watchers-lookup hide-when-print"
[hidden]="!allowedToAdd">
diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/wp-watcher-entry.component.html b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/wp-watcher-entry.component.html
new file mode 100644
index 00000000000..eab9fdce422
--- /dev/null
+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/wp-watcher-entry.component.html
@@ -0,0 +1,19 @@
+<div class="op-wp-watcher form--selected-value--container" opFocusWithin="button">
+ <span class="op-wp-watcher--form form--selected-value">
+ <op-principal
+ [principal]="watcher"
+ data-link="true"
+ data-principal-type="user"
+ data-size="avatar-mini"
+ data-qa-selector="op-wp-watcher-name"
+ ></op-principal>
+ </span>
+ <button
+ type="button"
+ class="op-link form--selected-value--remover"
+ [title]="text.remove"
+ (click)="remove()"
+ >
+ <op-icon icon-classes="icon-remove"></op-icon>
+ </button>
+</div>
diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/wp-watcher-entry.component.sass b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/wp-watcher-entry.component.sass
new file mode 100644
index 00000000000..5910ecb7f34
--- /dev/null
+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/wp-watcher-entry.component.sass
@@ -0,0 +1,6 @@
+@import "helpers"
+
+.op-wp-watcher
+ &--form
+ display: inline-block
+ @include text-shortener
diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/wp-watcher-entry.component.ts b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/wp-watcher-entry.component.ts
index d4184e9e664..d889bf09ecb 100644
--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/wp-watcher-entry.component.ts
+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/wp-watcher-entry.component.ts
@@ -26,19 +26,24 @@
// See COPYRIGHT and LICENSE files for more details.
//++
-import { Component, Input, OnInit } from '@angular/core';
+import {
+ ChangeDetectionStrategy,
+ Component,
+ Input,
+ OnInit,
+} from '@angular/core';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { UserResource } from 'core-app/features/hal/resources/user-resource';
import { WorkPackageWatchersTabComponent } from './watchers-tab.component';
@Component({
- templateUrl: './wp-watcher-entry.html',
- selector: 'wp-watcher-entry',
+ templateUrl: './wp-watcher-entry.component.html',
+ styleUrls: ['./wp-watcher-entry.component.sass'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ selector: 'op-wp-watcher-entry',
})
export class WorkPackageWatcherEntryComponent implements OnInit {
- @Input('watcher') public watcher:UserResource;
-
- public deleting = false;
+ @Input() public watcher:UserResource;
public text:{ remove:string };
@@ -46,14 +51,13 @@ export class WorkPackageWatcherEntryComponent implements OnInit {
readonly panelCtrl:WorkPackageWatchersTabComponent) {
}
- ngOnInit() {
+ ngOnInit():void {
this.text = {
remove: this.I18n.t('js.label_remove_watcher', { name: this.watcher.name }),
};
}
- public remove() {
- this.deleting = true;
+ public remove():void {
this.panelCtrl.removeWatcher(this.watcher);
}
}
diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/wp-watcher-entry.html b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/wp-watcher-entry.html
deleted file mode 100644
index 5113a197336..00000000000
--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/wp-watcher-entry.html
+++ /dev/null
@@ -1,27 +0,0 @@
-<div class="form--selected-value--container" opFocusWithin="button">
- <span class="form--selected-value">
- <span [ngClass]="{'deleting': deleting }">
- <a [attr.href]="watcher.showUser.href">
- <op-principal
- [attr.data-principal-id]="watcher.id"
- [attr.data-principal-name]="watcher.name"
- data-principal-type="user"
- data-hide-name="true"
- data-size="avatar-mini"
- ></op-principal>
- <span class="work-package--watcher-name" [textContent]="watcher.name"></span>
- </a>
- </span>
- </span>
- <button
- type="button"
- class="op-link form--selected-value--remover"
- [title]="text.remove"
- (click)="remove()"
- >
- <op-icon icon-classes="icon-remove"></op-icon>
- </button>
-</div>
-
-
-
diff --git a/spec/features/work_packages/tabs/watcher_tab_spec.rb b/spec/features/work_packages/tabs/watcher_tab_spec.rb
index 099210d05a9..df085d70c39 100644
--- a/spec/features/work_packages/tabs/watcher_tab_spec.rb
+++ b/spec/features/work_packages/tabs/watcher_tab_spec.rb
@@ -34,17 +34,17 @@ describe 'Watcher tab', js: true, selenium: true do
it 'watching the WP modifies the watcher list' do
# Expect WP watch button is in not-watched state
expect_button_is_not_watching
- expect(page).to have_no_selector('.work-package--watcher-name')
+ expect(page).to have_no_selector('[data-qa-selector="op-wp-watcher-name"]')
watch_button.click
# Expect WP watch button causes watcher list to add user
expect_button_is_watching
- expect(page).to have_selector('.work-package--watcher-name', count: 1, text: user.name)
+ expect(page).to have_selector('[data-qa-selector="op-wp-watcher-name"]', count: 1, text: user.name)
# Expect WP unwatch button causes watcher list to remove user
watch_button.click
expect_button_is_not_watching
- expect(page).to have_no_selector('.work-package--watcher-name')
+ expect(page).to have_no_selector('[data-qa-selector="op-wp-watcher-name"]')
end
end
@@ -64,21 +64,21 @@ describe 'Watcher tab', js: true, selenium: true do
select_text: user.name
# Expect the addition of the user to toggle WP watch button
- expect(page).to have_selector('.work-package--watcher-name', count: 1, text: user.name)
+ expect(page).to have_selector('[data-qa-selector="op-wp-watcher-name"]', count: 1, text: user.name)
expect_button_is_watching
# Expect watchers counter to increase
tabs.expect_counter(watchers_tab, 1)
# Remove watcher from list
- page.find('wp-watcher-entry', text: user.name).hover
+ page.find('[data-qa-selector="op-wp-watcher-name"]', text: user.name).hover
page.find('.form--selected-value--remover').click
# Watchers counter should not be displayed
tabs.expect_no_counter(watchers_tab)
# Expect the removal of the user to toggle WP watch button
- expect(page).to have_no_selector('.work-package--watcher-name')
+ expect(page).to have_no_selector('[data-qa-selector="op-wp-watcher-name"]')
expect_button_is_not_watching
end