Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug/IVYPORTAL-18051-Portal-Dashboard-shows-no-permission-screen-when-… #1280

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 Expand Up @@ -152,13 +150,17 @@ private MenuElement buildDashboardItem() {
String mainMenuDisplayName = mainMenuEntryService.getNameInCurrentLocale();
String mainMenuIcon = mainMenuEntryService.getMenuIcon();

var subItemDashboards = getSubItemDashboards();
List<Dashboard> subItemDashboards = getSubItemDashboards();
if (subItemDashboards.size() > 1) {
return buildDashboardGroupMenu(subItemDashboards, dashboardTitle, mainMenuDisplayName, mainMenuIcon,
currentLanguage, dashboardLink);
} else if (subItemDashboards.size() == 1) {
Dashboard dashboard = subItemDashboards.getFirst();
String localizedTitle = getLocalizedTitle(dashboard, currentLanguage, dashboardTitle);
return buildSingleDashboardMenu(localizedTitle, dashboardId, dashboardLink, dashboard.getIcon());
}

return buildSingleDashboardMenu(dashboardTitle, dashboardId, dashboardLink);
return buildSingleDashboardMenu(dashboardTitle, "", dashboardLink, "");
}

private String determineDashboardLink() {
Expand Down Expand Up @@ -240,9 +242,11 @@ private void setMenuExpansion(DefaultSubMenu dashboardGroupMenu) {
}
}

private MenuElement buildSingleDashboardMenu(String dashboardTitle, String dashboardId, String dashboardLink) {
private MenuElement buildSingleDashboardMenu(String dashboardTitle, String dashboardId, String dashboardLink,
String dashboardIcon) {
var dashboardMenu = new PortalMenuBuilder(dashboardTitle, MenuKind.DASHBOARD, this.isWorkingOnATask)
.icon(PortalMenuItem.DEFAULT_DASHBOARD_ICON).url(dashboardLink).workingTaskId(this.workingTaskId).build();
.icon(StringUtils.isNoneEmpty(dashboardIcon) ? dashboardIcon : PortalMenuItem.DEFAULT_DASHBOARD_ICON)
.url(dashboardLink).workingTaskId(this.workingTaskId).build();

if (StringUtils.isBlank(dashboardId)) {
dashboardId = dashboardMenu.getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,33 +91,17 @@ public void init() {
currentDashboardIndex = 0;
dashboards = collectDashboards();


if (isReadOnlyMode) {
MenuView menuView = (MenuView) ManagedBeans.get("menuView");
menuView.updateDashboardCache(dashboards);
}

if (CollectionUtils.isNotEmpty(DashboardUtils.getDashboardsWithoutMenuItem())) {
if (CollectionUtils.isNotEmpty(DashboardUtils.getDashboardsWithoutMenuItem())
|| isRequestPathForMainOrDetailModification()) {
updateSelectedDashboardIdFromSessionAttribute();
currentDashboardIndex = findIndexOfDashboardById(selectedDashboardId);
selectedDashboard = dashboards.get(currentDashboardIndex);

String selectedDashboardName = selectedDashboard.getTitles().stream()
.filter(displayName -> displayName.getLocale().equals(Ivy.session().getContentLocale()))
.findFirst()
.orElseGet(() -> selectedDashboard.getTitles().get(0)).getValue();
setSelectedDashboardName(selectedDashboardName);
initShareDashboardLink(selectedDashboard);
// can not find dashboard by dashboard id session in view mode
if (StringUtils.isBlank(selectedDashboardId)
|| (!selectedDashboardId.equalsIgnoreCase(selectedDashboard.getId())
&& DashboardUtils.getDashboardsWithoutMenuItem().size() > 1)) {
DashboardUtils.storeDashboardInSession(selectedDashboard.getId());
}
if (isReadOnlyMode) {
DashboardUtils.highlightDashboardMenuItem(selectedDashboard.getId());
}
}
updateSelectedDashboard();
storeAndHighlightDashboardIfRequired();
}
buildWidgetModels(selectedDashboard);
isRunningTaskWhenClickingOnTaskInList = GlobalSettingService.getInstance()
.findGlobalSettingValue(GlobalVariable.DEFAULT_BEHAVIOUR_WHEN_CLICKING_ON_LINE_IN_TASK_LIST)
Expand All @@ -131,6 +115,33 @@ private void buildClientStatisticApiUri() {
.getExternalContext().getRequestContextPath() + "/api/statistics/data";
}

private boolean isRequestPathForMainOrDetailModification() {
String requestPath = Ivy.request().getRequestPath();
return requestPath.endsWith("/PortalMainDashboard.xhtml")
|| requestPath.endsWith("/PortalDashboardDetailModification.xhtml");
}

private void updateSelectedDashboard() {
currentDashboardIndex = findIndexOfDashboardById(selectedDashboardId);
selectedDashboard = dashboards.get(currentDashboardIndex);

String selectedDashboardName = selectedDashboard.getTitles().stream()
.filter(displayName -> displayName.getLocale().equals(Ivy.session().getContentLocale())).findFirst()
.orElseGet(() -> selectedDashboard.getTitles().get(0)).getValue();
setSelectedDashboardName(selectedDashboardName);
initShareDashboardLink(selectedDashboard);
}

private void storeAndHighlightDashboardIfRequired() {
if (StringUtils.isBlank(selectedDashboardId) || (!selectedDashboardId.equalsIgnoreCase(selectedDashboard.getId())
&& DashboardUtils.getDashboardsWithoutMenuItem().size() > 1)) {
DashboardUtils.storeDashboardInSession(selectedDashboard.getId());
}
if (isReadOnlyMode) {
DashboardUtils.highlightDashboardMenuItem(selectedDashboard.getId());
}
}

protected List<Dashboard> collectDashboards() {
return DashboardUtils.collectDashboards();
}
Expand Down
Loading