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

[33073] Add notification message to board when there are no options to add (#8325)

Henriette Darge7b87beb8ae40
diff --git a/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.component.ts b/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.component.ts
index 37f41e4857b..a45aa77903c 100644
--- a/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.component.ts
+++ b/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.component.ts
@@ -73,6 +73,10 @@ export class AddListModalComponent extends OpModalComponent implements OnInit {
/* Do not close on outside click (because the select option are appended to the body */
public closeOnOutsideClick = false;
+ public valuesAvailable:boolean = true;
+
+ public warningText:string|undefined;
+
public text:any = {
title: this.I18n.t('js.boards.add_list'),
button_add: this.I18n.t('js.button_add'),
@@ -117,6 +121,14 @@ export class AddListModalComponent extends OpModalComponent implements OnInit {
.getAvailableValues(this.board, this.queries)
.then(available => {
this.availableValues = available;
+ if (this.availableValues.length === 0) {
+ this.actionService
+ .warningTextWhenNoOptionsAvailable()
+ .then((text) => {
+ this.warningText = text;
+ this.valuesAvailable = false;
+ });
+ }
});
}
diff --git a/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.html b/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.html
index ecccf80d178..2c38fd37862 100644
--- a/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.html
+++ b/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.html
@@ -29,6 +29,14 @@
</div>
</div>
</div>
+
+ <div *ngIf="!valuesAvailable && warningText"
+ class="notification-box -warning">
+ <div class="notification-box--content">
+ <p [innerHTML]="warningText"></p>
+ </div>
+ </div>
+
</div>
<div class="op-modal--modal-footer">
<button class="button -highlight"
diff --git a/frontend/src/app/modules/boards/board/board-actions/assignee/assignee-action.service.ts b/frontend/src/app/modules/boards/board/board-actions/assignee/assignee-action.service.ts
index 3648276bc01..d47c63c2f8b 100644
--- a/frontend/src/app/modules/boards/board/board-actions/assignee/assignee-action.service.ts
+++ b/frontend/src/app/modules/boards/board/board-actions/assignee/assignee-action.service.ts
@@ -1,4 +1,4 @@
-import {Injectable} from "@angular/core";
+import {Injectable, Injector} from "@angular/core";
import {BoardListsService} from "core-app/modules/boards/board/board-list/board-lists.service";
import {Board} from "core-app/modules/boards/board/board";
import {QueryResource} from "core-app/modules/hal/resources/query-resource";
@@ -16,18 +16,23 @@ import {AssigneeBoardHeaderComponent} from "core-app/modules/boards/board/board-
import {input} from "reactivestates";
import {take} from "rxjs/operators";
import {PathHelperService} from "core-app/modules/common/path-helper/path-helper.service";
+import {InjectField} from "core-app/helpers/angular/inject-field.decorator";
+import {ProjectDmService} from "core-app/modules/hal/dm-services/project-dm.service";
+import {ProjectResource} from "core-app/modules/hal/resources/project-resource";
@Injectable()
export class BoardAssigneeActionService implements BoardActionService {
private assignees = input<HalResource[]>();
+ @InjectField() public projectDmService:ProjectDmService;
+
constructor(protected boardListsService:BoardListsService,
protected I18n:I18nService,
protected halResourceService:HalResourceService,
protected pathHelper:PathHelperService,
- protected currentProject:CurrentProjectService
- ) {
+ protected currentProject:CurrentProjectService,
+ readonly injector:Injector) {
}
public get localizedName() {
@@ -127,6 +132,24 @@ export class BoardAssigneeActionService implements BoardActionService {
return undefined;
}
+ public warningTextWhenNoOptionsAvailable() {
+ let text = this.I18n.t('js.boards.add_list_modal.warning.assignee');
+
+ return this.projectDmService
+ .one(parseInt(this.currentProject.id!))
+ .then((project:ProjectResource) => {
+ if (project.memberships) {
+ text = text.concat(
+ this.I18n.t('js.boards.add_list_modal.warning.add_members', {
+ link: this.pathHelper.projectMembershipsPath(this.currentProject.identifier!)
+ })
+ );
+ }
+
+ return text;
+ });
+ }
+
private getAssignees():Promise<HalResource[]> {
const projectIdentifier = this.currentProject.identifier!;
this.assignees.putFromPromiseIfPristine(() =>
diff --git a/frontend/src/app/modules/boards/board/board-actions/board-action.service.ts b/frontend/src/app/modules/boards/board/board-actions/board-action.service.ts
index 29a2146e1ce..d20b4b442cc 100644
--- a/frontend/src/app/modules/boards/board/board-actions/board-action.service.ts
+++ b/frontend/src/app/modules/boards/board/board-actions/board-action.service.ts
@@ -81,4 +81,10 @@ export interface BoardActionService {
* @returns {the icon class or nothing}
*/
disabledAddButtonPlaceholder(resource?:HalResource):DisabledButtonPlaceholder|undefined;
+
+ /**
+ * Determines the specific warning to be shown, when there are no options to add as a list
+ * @returns {the text or nothing}
+ */
+ warningTextWhenNoOptionsAvailable():Promise<string|undefined>;
}
diff --git a/frontend/src/app/modules/boards/board/board-actions/status/status-action.service.ts b/frontend/src/app/modules/boards/board/board-actions/status/status-action.service.ts
index 7ee05bce236..7274c5f34f7 100644
--- a/frontend/src/app/modules/boards/board/board-actions/status/status-action.service.ts
+++ b/frontend/src/app/modules/boards/board/board-actions/status/status-action.service.ts
@@ -128,6 +128,10 @@ export class BoardStatusActionService implements BoardActionService {
return undefined;
}
+ public warningTextWhenNoOptionsAvailable() {
+ return Promise.resolve(this.I18n.t('js.boards.add_list_modal.warning.status'));
+ }
+
private getStatuses():Promise<StatusResource[]> {
return this.statusDm
.list()
diff --git a/frontend/src/app/modules/boards/board/board-actions/version/version-action.service.ts b/frontend/src/app/modules/boards/board/board-actions/version/version-action.service.ts
index 8fabacd0927..97051cdc3a4 100644
--- a/frontend/src/app/modules/boards/board/board-actions/version/version-action.service.ts
+++ b/frontend/src/app/modules/boards/board/board-actions/version/version-action.service.ts
@@ -170,6 +170,10 @@ export class BoardVersionActionService implements BoardActionService {
return value instanceof VersionResource && value.isOpen();
}
+ public warningTextWhenNoOptionsAvailable() {
+ return Promise.resolve(undefined);
+ }
+
private getVersions():Promise<VersionResource[]> {
if (this.currentProject.id === null) {
return Promise.resolve([]);
diff --git a/modules/boards/config/locales/js-en.yml b/modules/boards/config/locales/js-en.yml
index eebf34eb4f1..4f283a217e1 100644
--- a/modules/boards/config/locales/js-en.yml
+++ b/modules/boards/config/locales/js-en.yml
@@ -49,6 +49,13 @@ en:
version: version
select_attribute: "Action attribute"
+ add_list_modal:
+ warning:
+ status: |
+ There is currently no status available. <br>
+ Either there are none or they have all already been added to the board.
+ assignee: This project currently does not have any members that can be added. <br>
+ add_members: <a href="%{link}">Add a new member to this project</a> to select users again.
configuration_modal:
title: 'Configure this board'
display_settings:
diff --git a/modules/boards/spec/features/action_boards/assignee_board_spec.rb b/modules/boards/spec/features/action_boards/assignee_board_spec.rb
index 40a476f1fbf..0b3dee25396 100644
--- a/modules/boards/spec/features/action_boards/assignee_board_spec.rb
+++ b/modules/boards/spec/features/action_boards/assignee_board_spec.rb
@@ -40,11 +40,14 @@ describe 'Assignee action board',
member_in_project: project,
member_through_role: role)
end
+ let(:admin) { FactoryBot.create(:admin) }
let(:type) { FactoryBot.create(:type_standard) }
let(:project) { FactoryBot.create(:project, types: [type], enabled_module_names: %i[work_package_tracking board_view]) }
+ let(:project_without_members) { FactoryBot.create(:project, enabled_module_names: %i[work_package_tracking board_view]) }
let(:role) { FactoryBot.create(:role, permissions: permissions) }
let(:board_index) { Pages::BoardIndex.new(project) }
+ let(:other_board_index) { Pages::BoardIndex.new(project_without_members) }
let(:permissions) {
%i[show_board_views manage_board_views add_work_packages
@@ -78,84 +81,112 @@ describe 'Assignee action board',
assigned_to: bobself_user,
subject: 'Some Task' }
- before do
- with_enterprise_token :board_view
- login_as(bobself_user)
- end
+ context 'in a project with members' do
+ before do
+ with_enterprise_token :board_view
+ login_as(bobself_user)
+ end
- it 'allows to move a task between two assignees' do
- # Move to the board index page
- board_index.visit!
+ it 'allows to move a task between two assignees' do
+ # Move to the board index page
+ board_index.visit!
- # Create new board
- board_page = board_index.create_board action: :Assignee, expect_empty: true
+ # Create new board
+ board_page = board_index.create_board action: :Assignee, expect_empty: true
- # Expect no assignees to be present
- board_page.expect_empty
+ # Expect no assignees to be present
+ board_page.expect_empty
- # Add myself to the board list
- board_page.add_list option: 'Bob Self'
- board_page.expect_list 'Bob Self'
+ # Add myself to the board list
+ board_page.add_list option: 'Bob Self'
+ board_page.expect_list 'Bob Self'
- # Add the other user to the board list
- board_page.add_list option: 'Foo Bar'
- board_page.expect_list 'Foo Bar'
+ # Add the other user to the board list
+ board_page.add_list option: 'Foo Bar'
+ board_page.expect_list 'Foo Bar'
- # Add grouped list
- board_page.add_list option: 'Grouped'
- board_page.expect_list 'Grouped'
+ # Add grouped list
+ board_page.add_list option: 'Grouped'
+ board_page.expect_list 'Grouped'
- board_page.board(reload: true) do |board|
- expect(board.name).to eq 'Action board (assignee)'
- queries = board.contained_queries
- expect(queries.count).to eq(3)
+ # There can't be any other users added
+ board_page.open_add_list_modal
+ board_page.add_list_modal_shows_warning true, with_link: false
+ click_on 'Cancel'
- bob = queries.first
- foo = queries.second
- grouped = queries.last
+ board_page.board(reload: true) do |board|
+ expect(board.name).to eq 'Action board (assignee)'
+ queries = board.contained_queries
+ expect(queries.count).to eq(3)
- expect(bob.name).to eq 'Bob Self'
- expect(foo.name).to eq 'Foo Bar'
- expect(grouped.name).to eq 'Grouped'
+ bob = queries.first
+ foo = queries.second
+ grouped = queries.last
- expect(bob.filters.first.name).to eq :assigned_to_id
- expect(bob.filters.first.values).to eq [bobself_user.id.to_s]
+ expect(bob.name).to eq 'Bob Self'
+ expect(foo.name).to eq 'Foo Bar'
+ expect(grouped.name).to eq 'Grouped'
- expect(foo.filters.first.name).to eq :assigned_to_id
- expect(foo.filters.first.values).to eq [foobar_user.id.to_s]
+ expect(bob.filters.first.name).to eq :assigned_to_id
+ expect(bob.filters.first.values).to eq [bobself_user.id.to_s]
- expect(grouped.filters.first.name).to eq :assigned_to_id
- expect(grouped.filters.first.values).to eq [group.id.to_s]
- end
+ expect(foo.filters.first.name).to eq :assigned_to_id
+ expect(foo.filters.first.values).to eq [foobar_user.id.to_s]
+
+ expect(grouped.filters.first.name).to eq :assigned_to_id
+ expect(grouped.filters.first.values).to eq [group.id.to_s]
+ end
- # First, expect work package to be assigned to "Bob self"
- # For this, test the Bob self column to contain the work package
- board_page.expect_card 'Bob Self', 'Some Task'
+ # First, expect work package to be assigned to "Bob self"
+ # For this, test the Bob self column to contain the work package
+ board_page.expect_card 'Bob Self', 'Some Task'
- # Then, move the work package from one column to the next one
- board_page.move_card(0, from: 'Bob Self', to: 'Foo Bar')
+ # Then, move the work package from one column to the next one
+ board_page.move_card(0, from: 'Bob Self', to: 'Foo Bar')
- # Then, the work package should be in the other column
- # and assigned to "Foo Bar" user
- board_page.expect_card 'Foo Bar', 'Some Task'
- board_page.expect_card 'Bob Self', 'Some Task', present: false
+ # Then, the work package should be in the other column
+ # and assigned to "Foo Bar" user
+ board_page.expect_card 'Foo Bar', 'Some Task'
+ board_page.expect_card 'Bob Self', 'Some Task', present: false
- # Expect to have changed the avatar
- expect(page).to have_selector('.wp-card--assignee .avatar-default', text: 'FB', wait: 10)
+ # Expect to have changed the avatar
+ expect(page).to have_selector('.wp-card--assignee .avatar-default', text: 'FB', wait: 10)
- work_package.reload
- expect(work_package.assigned_to).to eq(foobar_user)
+ work_package.reload
+ expect(work_package.assigned_to).to eq(foobar_user)
- # Move to group column
- board_page.move_card(0, from: 'Foo Bar', to: 'Grouped')
- board_page.expect_card 'Grouped', 'Some Task'
- board_page.expect_card 'Foo Bar', 'Some Task', present: false
- board_page.expect_card 'Bob Self', 'Some Task', present: false
+ # Move to group column
+ board_page.move_card(0, from: 'Foo Bar', to: 'Grouped')
+ board_page.expect_card 'Grouped', 'Some Task'
+ board_page.expect_card 'Foo Bar', 'Some Task', present: false
+ board_page.expect_card 'Bob Self', 'Some Task', present: false
- # Expect to have changed the avatar
- expect(page).to have_selector('.wp-card--assignee .avatar-default', text: 'GG', wait: 10)
+ # Expect to have changed the avatar
+ expect(page).to have_selector('.wp-card--assignee .avatar-default', text: 'GG', wait: 10)
+
+ work_package.reload
+ expect(work_package.assigned_to).to eq(group)
+ end
+ end
- work_package.reload
- expect(work_package.assigned_to).to eq(group)
+ context 'in a project without members' do
+ before do
+ with_enterprise_token :board_view
+ login_as(admin)
+ end
+
+ it 'shows a warning when there are no members to add as a list with a link to add a new member' do
+ # Move to the board index page
+ other_board_index.visit!
+
+ # Create new board
+ board_page = other_board_index.create_board action: :Assignee, expect_empty: true
+
+ # Expect no assignees to be present
+ board_page.expect_empty
+
+ board_page.open_add_list_modal
+ board_page.add_list_modal_shows_warning true, with_link: true
+ end
end
end
diff --git a/modules/boards/spec/features/support/board_page.rb b/modules/boards/spec/features/support/board_page.rb
index 2db5e13d358..2dd1f3d3fea 100644
--- a/modules/boards/spec/features/support/board_page.rb
+++ b/modules/boards/spec/features/support/board_page.rb
@@ -345,10 +345,24 @@ module Pages
end
def open_and_fill_add_list_modal(name)
- page.find('.boards-list--add-item').click
- expect(page).to have_selector('.new-list--action-select input')
+ open_add_list_modal
sleep(0.1)
page.find('.op-modal--modal-container .new-list--action-select input').set(name)
end
+
+ def open_add_list_modal
+ page.find('.boards-list--add-item').click
+ expect(page).to have_selector('.new-list--action-select input')
+ end
+
+ def add_list_modal_shows_warning(value, with_link: false)
+ within page.find('.op-modal--modal-container') do
+ warning = '.notification-box.-warning'
+ link = '.notification-box--content a'
+
+ expect(page).to (value ? have_selector(warning) : have_no_selector(warning))
+ expect(page).to (with_link ? have_selector(link) : have_no_selector(link))
+ end
+ end
end
end