Skip to content

Commit

Permalink
[4079] Fix a warning in the console when closing the project's contex…
Browse files Browse the repository at this point in the history
…t menu

Bug: #4079
Signed-off-by: Pierre-Charles David <[email protected]>
  • Loading branch information
pcdavid authored and sbegaudeau committed Oct 9, 2024
1 parent b456b93 commit 7e8bc3b
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ The ids used to create a subscription is also changed, refer to [ADR-159] for mo
- https://github.com/eclipse-sirius/sirius-web/issues/3920[#3920] [form] Fix DateTime widget default style not set
- https://github.com/eclipse-sirius/sirius-web/issues/3934[#3934] [diagram] Remove helper lines when moving pinned elements
- https://github.com/eclipse-sirius/sirius-web/issues/3907[#3907] [diagram] Fix bad state update in handleNodesChange
- https://github.com/eclipse-sirius/sirius-web/issues/4079[#4079] [sirius-web] Fix a warning in the console when closing the project's context menu

=== New Features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
*******************************************************************************/
package org.eclipse.sirius.web.domain.boundedcontexts.project.repositories;

import java.util.List;
import java.util.UUID;

import org.eclipse.sirius.web.domain.boundedcontexts.project.Project;
import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.data.repository.ListCrudRepository;
import org.springframework.data.repository.ListPagingAndSortingRepository;
import org.springframework.stereotype.Repository;
Expand All @@ -26,4 +28,19 @@
*/
@Repository
public interface IProjectRepository extends ListPagingAndSortingRepository<Project, UUID>, ListCrudRepository<Project, UUID>, ProjectSearchRepository<Project, UUID> {

@Query("""
SELECT * FROM project
WHERE project.id IN (:projectIds)
ORDER BY project.name ASC
OFFSET :offset
LIMIT :limit
""")
List<Project> findAllById(List<UUID> projectIds, long offset, int limit);

@Query("""
SELECT count(*) FROM project
WHERE project.id IN (:projectIds)
""")
long countAllById(List<UUID> projectIds);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.eclipse.sirius.web.domain.boundedcontexts.project.repositories.IProjectRepository;
import org.eclipse.sirius.web.domain.boundedcontexts.project.services.api.IProjectSearchService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

Expand Down Expand Up @@ -54,7 +55,9 @@ public Page<Project> findAll(Pageable pageable) {
}

@Override
public List<Project> findAllByIds(List<UUID> projectIds) {
return this.projectRepository.findAllById(projectIds);
public Page<Project> findAllById(List<UUID> projectIds, Pageable pageable) {
var projects = this.projectRepository.findAllById(projectIds, pageable.getPageNumber() * pageable.getPageSize(), pageable.getPageSize());
var count = this.projectRepository.countAllById(projectIds);
return new PageImpl<>(projects, pageable, count);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ public interface IProjectSearchService {

Page<Project> findAll(Pageable pageable);

List<Project> findAllByIds(List<UUID> projectIds);
Page<Project> findAllById(List<UUID> projectIds, Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.PageRequest;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.SqlConfig;
import org.springframework.transaction.annotation.Transactional;
Expand Down Expand Up @@ -63,8 +64,8 @@ public void givenProjectWhenNatureIsAddedThenTheNewNatureIsVisible() {
var projectId = optionalProject.map(Project::getId).orElseThrow(IllegalStateException::new);
this.projectUpdateService.addNature(null, projectId, "new nature");

var projects = this.projectSearchService.findAllByIds(List.of(TestIdentifiers.SYSML_SAMPLE_PROJECT));
assertThat(projects)
var projects = this.projectSearchService.findAllById(List.of(TestIdentifiers.SYSML_SAMPLE_PROJECT), PageRequest.of(0, 20));
assertThat(projects.stream().toList())
.isNotEmpty()
.anySatisfy(project -> assertThat(project.getNatures()).hasSize(2));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023 Obeo.
* Copyright (c) 2023, 2024 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -142,7 +142,7 @@ export const editProjectNavbarMachine = Machine<
on: {
HANDLE_CLOSE_CONTEXT_MENU_EVENT: {
target: 'empty',
actions: 'closeContextMenu',
actions: 'hideContextMenu',
},
HANDLE_SHOW_MODAL_EVENT: {
target: 'modalDisplayedState',
Expand Down

0 comments on commit 7e8bc3b

Please sign in to comment.