Skip to content

Commit

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

This reverts commit 2d4c740.
  • Loading branch information
nhthinh-axonivy committed Dec 6, 2024
1 parent a107ca6 commit 667cdfb
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 345 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ 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.addDefaultDashboardsIfMissing(collectedDashboards);
DashboardUtils.addDefaultTaskCaseListDashboardsIfMissing(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.addDefaultDashboardsIfMissing(this.dashboards);
DashboardUtils.addDefaultTaskCaseListDashboardsIfMissing(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,16 +134,12 @@ public static List<Dashboard> getVisiblePublicDashboards() {
public static List<Dashboard> getPublicDashboards() {
String dashboardJson = Ivy.var().get(PortalVariable.DASHBOARD.key);
List<Dashboard> visibleDashboards = jsonToDashboards(dashboardJson);
addDefaultDashboardsIfMissing(visibleDashboards);
addDefaultTaskCaseListDashboardsIfMissing(visibleDashboards);
setDashboardAsPublic(visibleDashboards);
return visibleDashboards;
}

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());
}
public static void addDefaultTaskCaseListDashboardsIfMissing(List<Dashboard> dashboards) {
if (!hasDashboardWithId(dashboards, DEFAULT_CASE_LIST_DASHBOARD)) {
dashboards.add(0, DefaultDashboardUtils.getDefaultCaseListDashboard());
}
Expand Down Expand Up @@ -202,7 +198,7 @@ public static List<Dashboard> collectDashboards() {
}
}
collectedDashboards.addAll(idToDashboard.values());
addDefaultDashboardsIfMissing(collectedDashboards);
addDefaultTaskCaseListDashboardsIfMissing(collectedDashboards);
return collectedDashboards;
}

Expand Down
Loading

0 comments on commit 667cdfb

Please sign in to comment.