Skip to content

Commit

Permalink
bug/IVYPORTAL-18051-Portal-Dashboard-shows-no-permission-screen-when-…
Browse files Browse the repository at this point in the history
…dashboards-is-empty

_ adapt logic
_ import default dashboard
  • Loading branch information
nhthinh-axonivy committed Nov 28, 2024
1 parent fc1f4ca commit 2d4c740
Show file tree
Hide file tree
Showing 5 changed files with 345 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ public void buildPortalLeftMenu(ITask workingTask, boolean isWorkingOnATask) {
mainMenuModel = new DefaultMenuModel();
mainMenuModel.getElements().add(buildDashboardItem()); // menuIndex = 0



List<SubMenuItem> subMenuItems = PortalMenuNavigator.callSubMenuItemsProcess();
int menuIndex = 1;
for (SubMenuItem subMenu : subMenuItems) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ protected List<Dashboard> collectDashboards() {
} catch (PortalException e) {
Ivy.log().error(e);
}
DashboardUtils.addDefaultTaskCaseListDashboardsIfMissing(collectedDashboards);
DashboardUtils.addDefaultDashboardsIfMissing(collectedDashboards);
return collectedDashboards.stream()
.filter(dashboard -> dashboard.getId().equals(selectedDashboardId)).collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected void collectDashboardsForManagement() {
String dashboardInUserProperty = readDashboardBySessionUser();
if (isPublicDashboard) {
this.dashboards = DashboardUtils.getPublicDashboards();
DashboardUtils.addDefaultTaskCaseListDashboardsIfMissing(this.dashboards);
DashboardUtils.addDefaultDashboardsIfMissing(this.dashboards);
} else if (StringUtils.isNoneEmpty(dashboardInUserProperty)) {
List<Dashboard> myDashboards = getVisibleDashboards(dashboardInUserProperty);
this.dashboards.addAll(myDashboards);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,16 @@ public static List<Dashboard> getVisiblePublicDashboards() {
public static List<Dashboard> getPublicDashboards() {
String dashboardJson = Ivy.var().get(PortalVariable.DASHBOARD.key);
List<Dashboard> visibleDashboards = jsonToDashboards(dashboardJson);
addDefaultTaskCaseListDashboardsIfMissing(visibleDashboards);
addDefaultDashboardsIfMissing(visibleDashboards);
setDashboardAsPublic(visibleDashboards);
return visibleDashboards;
}

public static void addDefaultTaskCaseListDashboardsIfMissing(List<Dashboard> dashboards) {
public static void addDefaultDashboardsIfMissing(List<Dashboard> dashboards) {
List<Dashboard> dashboardsWithoutItem = dashboards.stream().filter(dashboard -> !dashboard.getIsTopMenu()).toList();
if (dashboardsWithoutItem.size() == 0) {
dashboards.add(0,DefaultDashboardUtils.getDefaultDashboard());
}
if (!hasDashboardWithId(dashboards, DEFAULT_CASE_LIST_DASHBOARD)) {
dashboards.add(0, DefaultDashboardUtils.getDefaultCaseListDashboard());
}
Expand Down Expand Up @@ -198,7 +202,7 @@ public static List<Dashboard> collectDashboards() {
}
}
collectedDashboards.addAll(idToDashboard.values());
addDefaultTaskCaseListDashboardsIfMissing(collectedDashboards);
addDefaultDashboardsIfMissing(collectedDashboards);
return collectedDashboards;
}

Expand Down
Loading

0 comments on commit 2d4c740

Please sign in to comment.