Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/axonivy-market/portal int…
Browse files Browse the repository at this point in the history
…o feature/IVYPORTAL-16459-OpenSource
  • Loading branch information
chnam-axonivy committed Mar 4, 2024
2 parents 6871aed + 3c7a7b9 commit 531843b
Show file tree
Hide file tree
Showing 49 changed files with 885 additions and 215 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
name: Lint
name: Lint Code Base

on: # yamllint disable-line rule:truthy
push: null
pull_request: null
on:
pull_request:
branches: [ master ]
push:
branches: [ feature/IVYPORTAL-16459-OpenSource ]

jobs:
build:
Expand All @@ -25,9 +26,7 @@ jobs:
fetch-depth: 0

- name: Super-linter
uses: super-linter/super-linter@v6.0.0 # x-release-please-version
uses: super-linter/super-linter@v6.3.0 # x-release-please-version
env:
DEFAULT_BRANCH: main
# To report GitHub Actions status checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
...

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
package com.axonivy.portal.components.service.impl;

import static com.axonivy.portal.components.constant.CustomFields.IS_DASHBOARD_PROCESS;
import static org.apache.commons.collections4.CollectionUtils.isNotEmpty;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;

import com.axonivy.portal.components.enums.SessionAttribute;
import com.axonivy.portal.components.util.UserUtils;

import ch.ivyteam.ivy.environment.Ivy;
import ch.ivyteam.ivy.security.exec.Sudo;
import ch.ivyteam.ivy.server.restricted.EngineMode;
import ch.ivyteam.ivy.workflow.IWorkflowSession;
import ch.ivyteam.ivy.workflow.start.IWebStartable;

Expand All @@ -26,37 +21,22 @@ public class ProcessService {
private static final String PORTAL_IN_TEAMS_REQUEST_PATH = "InTeams.ivp";
private static final String PORTAL_START_REQUEST_PATH = "/DefaultApplicationHomePage.ivp";
private static ProcessService instance;
private static List<IWebStartable> processes;
private static List<IWebStartable> customDashboardProcesses;
private static String sessionUserId;
private static String userLanguage;

public ProcessService() { }

public static ProcessService getInstance() {
if (instance == null) {
instance = new ProcessService();
processes = new ArrayList<IWebStartable>();
customDashboardProcesses = new ArrayList<>();
}
return instance;
}

public List<IWebStartable> findProcesses() {
if (isInSession() && isNotEmpty(processes)) {
return processes;
}
updateUserSessionAtributes();
processes = new ArrayList<>();
return Sudo.get(() -> {
return findStartablesWithoutPortalHomeAndMSTeamsProcess(Ivy.session());
});
}

private void updateUserSessionAtributes() {
sessionUserId = Ivy.session().getAttribute(SessionAttribute.SESSION_IDENTIFIER.toString()).toString();
userLanguage = UserUtils.getUserLanguage();
}

private List<IWebStartable> findStartablesWithoutPortalHomeAndMSTeamsProcess(IWorkflowSession session) {
return session.getStartables().stream().filter(process -> isNotPortalHomeAndMSTeamsProcess(process))
.collect(Collectors.toList());
Expand All @@ -67,28 +47,12 @@ private boolean isNotPortalHomeAndMSTeamsProcess(IWebStartable process) {
return !StringUtils.endsWithAny(relativeEncoded, PORTAL_START_REQUEST_PATH, PORTAL_IN_TEAMS_REQUEST_PATH);
}

private boolean isInSession() {
String currentUserLanguage = UserUtils.getUserLanguage();
String sessionIdAttribute = SessionAttribute.SESSION_IDENTIFIER.toString();
if (Ivy.session().getAttribute(sessionIdAttribute) == null) {
Ivy.session().setAttribute(sessionIdAttribute, UUID.randomUUID().toString());
}
return EngineMode.isNot(EngineMode.DESIGNER_EMBEDDED) && currentUserLanguage.equals(userLanguage)
&& Ivy.session().getAttribute(sessionIdAttribute).toString().equals(sessionUserId);
}

public List<IWebStartable> findCustomDashboardProcesses() {
if (isInSession() && isNotEmpty(customDashboardProcesses)) {
return customDashboardProcesses;
}
updateUserSessionAtributes();
customDashboardProcesses = new ArrayList<>(
return new ArrayList<>(
Ivy.session().getAllStartables().filter(filterByCustomDashboardProcess()).collect(Collectors.toList()));
return customDashboardProcesses;
}

private Predicate<? super IWebStartable> filterByCustomDashboardProcess() {
return start -> BooleanUtils.toBoolean(start.customFields().value(IS_DASHBOARD_PROCESS));
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.axonivy.portal.components.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Predicate;

import org.apache.commons.collections4.CollectionUtils;
Expand Down Expand Up @@ -127,7 +129,7 @@ private static List<IWebStartable> getWebStartables() {
if (CollectionUtils.isEmpty(webStartables)) {
webStartables = ProcessService.getInstance().findProcesses();
}
return webStartables;
return Optional.ofNullable(webStartables).orElse(new ArrayList<>());
}

public static boolean isExpressCase(ICase iCase) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,29 @@ function highlightAddExternalDialogItem() {
var linkName = $("label[for$='add-external-link-form:external-link-name']");
appendStepAnnotation(linkName, "3", -5, linkName.width());

var translateName = $("button[id$='process-widget:add-external-link-form:add-name-language-button']");
appendStepAnnotation(translateName, "4", -5, translateName.width());

var startLink = $("label[for$='add-external-link-form:external-link']");
appendStepAnnotation(startLink, "4", -5, startLink.width());
appendStepAnnotation(startLink, "5", -5, startLink.width());

var linkDescription = $("label[for$='process-widget:add-external-link-form:external-description']");
appendStepAnnotation(linkDescription, "6", -5, linkDescription.width());

var translateDescription = $("button[id$='process-widget:add-external-link-form:add-description-language-button']");
appendStepAnnotation(translateDescription, "7", -5, translateDescription.width());

var visibility = $("label[for$='add-external-link-form:external-link-type-radio']");
appendStepAnnotation(visibility, "5", -5, visibility.width());
appendStepAnnotation(visibility, "8", -5, visibility.width());

var icon = $("[id$='add-external-link-form:external-link-icon:awesome-icon-selection']");
appendStepAnnotation(icon, "6", -10, icon.width());
appendStepAnnotation(icon, "9", -10, icon.width());

var uploadButton = $("[id$='add-external-link-form:external-link-image-upload']");
appendStepAnnotation(uploadButton, "7", 0, 80);
appendStepAnnotation(uploadButton, "10", 0, 80);

var addButton = $("[id$='process-widget:adding-new-external-link-command']");
appendStepAnnotation(addButton, "8", -25, -5);
appendStepAnnotation(addButton, "11", -25, -5);
}

function highlightProcessItems() {
Expand Down Expand Up @@ -465,6 +474,10 @@ function highlightTaskDetailComponent() {
appendStepAnnotation(histories, 3, 0, histories.width()/2);
}

function highlightTaskStatusBanner() {
createRedMediumOutline($("[id$=':task-status-banner']"));
}

function highlightUserExampleCard(cardIndex) {
var userCardId = '#panel-' + cardIndex;
createRedThickOutline($(userCardId).parent());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public void screenshotBasicTaskDetails() throws IOException {
NewDashboardPage homePage = new NewDashboardPage();
homePage.waitForCaseWidgetLoaded();
TaskWidgetPage taskWidget = mainMenuPage.openTaskList();
taskWidget.startTask(0);
mainMenuPage.openTaskList();
WaitHelper.waitForNavigation(() -> taskWidget.openTaskDetail(0));
TaskDetailsPage detailsPage = new TaskDetailsPage();
detailsPage.waitUtilsTaskDetailsDisplayed();
Expand Down Expand Up @@ -122,9 +124,16 @@ public void screenshotTaskDetails() throws IOException {
NewDashboardPage newDashboardPage = new NewDashboardPage();
newDashboardPage.waitForCaseWidgetLoaded();
TaskWidgetPage taskWidget = mainMenuPage.openTaskList();
taskWidget.startTask(0);
showNewDashboard();
mainMenuPage.openTaskList();
TaskDetailsPage taskDetails = taskWidget.openTaskDetail(0);
taskDetails.waitUtilsTaskDetailsDisplayed();

ScreenshotUtils.resizeBrowser(new Dimension(2560, 1440));
ScreenshotUtils.executeDecorateJs("highlightTaskStatusBanner()");
ScreenshotUtils.capturePageScreenshot(ScreenshotUtils.TASK_DETAIL_FOLDER + "task-status-banner");

ScreenshotUtils.resizeBrowser(new Dimension(2560, 1440));
ScreenshotUtils.captureElementWithMarginOptionScreenshot(taskDetails.getTaskGeneralInformation(),
ScreenshotUtils.TASK_DETAIL_FOLDER + "detailed-task-information-data-description", new ScreenshotMargin(10));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,12 @@ public void screenshotMyProfile() throws IOException {
NewDashboardPage homePage = new NewDashboardPage();

UserProfilePage userProfilePage = homePage.openMyProfilePage();
userProfilePage.restoreDefaultNotificationSettings();
ScreenshotUtils.resizeBrowser(new Dimension(1400, 1400));
ScreenshotUtils.captureElementScreenshot(userProfilePage.getUserSettingCard(),
ScreenshotUtils.MY_PROFILE_FOLDER + "my-profile");
ScreenshotUtils.resizeBrowser(new Dimension(1500, 900));
userProfilePage.checkBoxTosubscribeChannel();
userProfilePage.subscribeAllChannels();
ScreenshotUtils.executeDecorateJs("highlightNotificationChannelSettings()");
ScreenshotUtils
.captureHalfRightPageScreenShot(ScreenshotUtils.MY_PROFILE_FOLDER + "notification-channels-settings");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public void save() {
$(caseEditWidgetId).shouldBe(appear, DEFAULT_TIMEOUT);
$("[id='widget-configuration-form:new-widget-configuration-component:case-widget-preview:dashboard-cases_head']")
.shouldBe(appear, DEFAULT_TIMEOUT);
$("button[id$='widget-configuration-save-button']").shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).click();
$("button[id$='widget-configuration-save-button']").shouldBe(getClickableCondition(), DEFAULT_TIMEOUT);
clickByJavaScript($("button[id$='widget-configuration-save-button']"));
$("button[id$='widget-configuration-save-button']").shouldBe(disappear, DEFAULT_TIMEOUT);
$(caseEditWidgetId).shouldBe(disappear, DEFAULT_TIMEOUT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public void addNewTask(int currentTaskIndex) {
}

public void clickSave() {
$("[id='form:save']").shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).click();
$("[id='form:save']").shouldBe(getClickableCondition(), DEFAULT_TIMEOUT);
clickByJavaScript($("[id='form:save']"));
}

public ExpressFormDefinitionPage goToFormDefinition() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,14 @@ public void dragAndDropProcess(int fromIndex, int toIndex) {
processList.shouldBe(Condition.appear, DEFAULT_TIMEOUT);
List<SelenideElement> findAll = processList.findAll("li.ui-orderlist-item");
if (findAll.size() > toIndex) {
SelenideElement fromElement = findAll.get(fromIndex).shouldBe(clickable(), DEFAULT_TIMEOUT);
SelenideElement toElement = findAll.get(toIndex).shouldBe(clickable(), DEFAULT_TIMEOUT);
SelenideElement fromElement = findAll.get(fromIndex).$(".process-start-list-item").shouldBe(clickable(),
DEFAULT_TIMEOUT);
SelenideElement toElement = findAll.get(toIndex).$(".process-start-list-item").shouldBe(clickable(),
DEFAULT_TIMEOUT);

Actions builder = new Actions(WebDriverRunner.getWebDriver());
Action dragAndDrop = builder.clickAndHold(fromElement).pause(500).moveToElement(toElement).pause(500)
.release(toElement).build();
Action dragAndDrop = builder.clickAndHold(fromElement).pause(500).moveToElement(toElement).pause(1000)
.release(toElement).pause(1000).build();
dragAndDrop.perform();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public SelenideElement getInformationPanel() {
return $("div[id$='task-details-information-panel'").shouldBe(Condition.appear, DEFAULT_TIMEOUT);
}

public SelenideElement getStatusBanner() {
return $("div[id$='task-detail-template:task-status-banner'");
}

public void openActionPanel() {
$("[id$=':additional-options:task-detail-more-step']").shouldBe(Condition.appear, DEFAULT_TIMEOUT)
.shouldBe(getClickableCondition()).click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ public ElementsCollection countRelatedCases() {
public void openFilterWidget() {
waitForGlobalGrowlDisappear();
getTaskWidgetHeader().$(".widget__filter-sidebar-link").shouldBe(appear, DEFAULT_TIMEOUT)
.shouldBe(getClickableCondition()).click();
.shouldBe(getClickableCondition(), DEFAULT_TIMEOUT);
clickByJavaScript(getTaskWidgetHeader().$(".widget__filter-sidebar-link"));
$("[id$=':widget-saved-filters-items").shouldBe(appear, DEFAULT_TIMEOUT);
}

Expand Down Expand Up @@ -307,12 +308,12 @@ private SelenideElement getFilterCheckBox(String inputField) {
}

public void selectState(String state) {
getStateFilterCheckBox(state).shouldBe(getClickableCondition()).click();
getCloseStateFilter().shouldBe(getClickableCondition()).click();
getStateFilterCheckBox(state).shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).click();
getCloseStateFilter().shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).click();
}

public void filterTaskState() {
getFilterCheckBox(FILTER_TASK_STATE).shouldBe(getClickableCondition()).click();
getFilterCheckBox(FILTER_TASK_STATE).shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).click();
}

public ElementsCollection getActiveTaskActions(int taskIndex) {
Expand All @@ -322,7 +323,7 @@ public ElementsCollection getActiveTaskActions(int taskIndex) {
}

public void clickOnTaskActionLink(int taskIndex) {
getColumnOfCaseHasActionIndex(taskIndex, "Actions").shouldBe(getClickableCondition()).click();
getColumnOfCaseHasActionIndex(taskIndex, "Actions").shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).click();
}

public void reserveTask(int taskIndex) {
Expand Down
Loading

0 comments on commit 531843b

Please sign in to comment.