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

EPMRPP-89932 || Add possibility to configure autocomplete suggestions when inviting users #1957

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import com.epam.ta.reportportal.entity.jasper.ReportFormat;
import com.epam.ta.reportportal.entity.project.ProjectInfo;
import com.epam.ta.reportportal.entity.user.User;
import com.epam.ta.reportportal.entity.user.UserRole;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.util.ProjectExtractor;
import com.epam.ta.reportportal.ws.model.DeleteBulkRQ;
Expand All @@ -69,13 +70,15 @@
import java.io.IOException;
import java.io.OutputStream;
import java.security.Principal;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import org.jooq.Operator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.security.access.prepost.PreAuthorize;
Expand Down Expand Up @@ -112,6 +115,8 @@ public class ProjectController {
private final UpdatePreferenceHandler updatePreference;
private final GetJasperReportHandler<ProjectInfo> jasperReportHandler;

private final boolean isUserSuggestions;

@Autowired
public ProjectController(ProjectExtractor projectExtractor, GetProjectHandler getProjectHandler,
GetProjectInfoHandler projectInfoHandler,
Expand All @@ -120,7 +125,8 @@ public ProjectController(ProjectExtractor projectExtractor, GetProjectHandler ge
GetUserHandler getUserHandler, GetPreferenceHandler getPreference,
UpdatePreferenceHandler updatePreference,
@Qualifier("projectJasperReportHandler")
GetJasperReportHandler<ProjectInfo> jasperReportHandler) {
GetJasperReportHandler<ProjectInfo> jasperReportHandler,
@Value("${rp.environment.variable.user.suggestions:true}") boolean isUserSuggestions) {
this.projectExtractor = projectExtractor;
this.getProjectHandler = getProjectHandler;
this.projectInfoHandler = projectInfoHandler;
Expand All @@ -131,6 +137,7 @@ public ProjectController(ProjectExtractor projectExtractor, GetProjectHandler ge
this.getPreference = getPreference;
this.updatePreference = updatePreference;
this.jasperReportHandler = jasperReportHandler;
this.isUserSuggestions = isUserSuggestions;
}

@Transactional
Expand Down Expand Up @@ -276,6 +283,9 @@ public List<String> getProjectUsers(@PathVariable String projectName,
public Iterable<SearchUserResource> searchForUser(@PathVariable String projectName,
@RequestParam(value = "term") String term,
Pageable pageable, @AuthenticationPrincipal ReportPortalUser user) {
if (!user.getUserRole().equals(UserRole.ADMINISTRATOR) && !isUserSuggestions) {
return Collections.emptyList();
}
return getProjectHandler.getUserNames(term,
projectExtractor.extractProjectDetails(user, projectName), pageable);
}
Expand Down
Loading