Skip to content

Commit

Permalink
Merge pull request #1377 from deepsidhu85/fix-analysis-share
Browse files Browse the repository at this point in the history
Fixed analysis results manage results
  • Loading branch information
ericenns authored Oct 7, 2022
2 parents 31fdfd0 + 2f67c52 commit deaecb2
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* [Developer]: Update to Spring Boot 2.7.3 and update various other dependencies. See [PR 1369](https://github.com/phac-nml/irida/pull/1369)
* [Developer]: Fixed issue with disabled user accounts requesting a password reset. See [PR 1373](https://github.com/phac-nml/irida/pull/1373)
* [Developer/UI]: Updated sample details view to use Ant Design and moved into a modal which can be launched from anywhere the sample name is listed. See [PR 1370](https://github.com/phac-nml/irida/pull/1370)
* [UI]: Updated analysis results manage results page to not allow a project collaborator to view the save results back to a sample section. See [PR 1377](https://github.com/phac-nml/irida/pull/1377)

## [22.05.5] - 2022/06/28
* [UI]: Fixed bug preventing export of project samples table due to invalid url. [PR 1331](https://github.com/phac-nml/irida/pull/1331)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import ca.corefacility.bioinformatics.irida.ria.web.dto.ResponseDetails;
import ca.corefacility.bioinformatics.irida.ria.web.utilities.DateUtilities;
import ca.corefacility.bioinformatics.irida.security.permissions.analysis.UpdateAnalysisSubmissionPermission;
import ca.corefacility.bioinformatics.irida.security.permissions.sample.UpdateSamplePermission;
import ca.corefacility.bioinformatics.irida.service.*;
import ca.corefacility.bioinformatics.irida.service.sample.MetadataTemplateService;
import ca.corefacility.bioinformatics.irida.service.sample.SampleService;
Expand Down Expand Up @@ -93,14 +94,16 @@ public class AnalysisAjaxController {
private AnalysisTypesService analysisTypesService;
private EmailController emailController;

private UpdateSamplePermission updateSamplePermission;

@Autowired
public AnalysisAjaxController(AnalysisSubmissionService analysisSubmissionService,
IridaWorkflowsService iridaWorkflowsService, UserService userService, SampleService sampleService,
ProjectService projectService, UpdateAnalysisSubmissionPermission updateAnalysisPermission,
MetadataTemplateService metadataTemplateService, SequencingObjectService sequencingObjectService,
AnalysisSubmissionSampleProcessor analysisSubmissionSampleProcessor, MessageSource messageSource,
ExecutionManagerConfig configFile, AnalysisAudit analysisAudit, AnalysisTypesService analysisTypesService,
EmailController emailController) {
EmailController emailController, UpdateSamplePermission updateSamplePermission) {

this.analysisSubmissionService = analysisSubmissionService;
this.workflowsService = iridaWorkflowsService;
Expand All @@ -116,6 +119,7 @@ public AnalysisAjaxController(AnalysisSubmissionService analysisSubmissionServic
this.analysisAudit = analysisAudit;
this.analysisTypesService = analysisTypesService;
this.emailController = emailController;
this.updateSamplePermission = updateSamplePermission;
}

/**
Expand Down Expand Up @@ -212,11 +216,15 @@ public AnalysisDetails ajaxGetDataForDetailsTab(@PathVariable Long submissionId,

response.setStatus(HttpServletResponse.SC_OK);

Collection<Sample> samples = sampleService.getSamplesForAnalysisSubmission(submission);

boolean canModifySample = updateSamplePermission.isAllowed(authentication, samples);

// details is a DTO (Data Transfer Object)
return new AnalysisDetails(analysisDescription, workflowName, version, priority, duration,
submission.getCreatedDate(), priorities, emailPipelineResultCompleted, emailPipelineResultError,
canShareToSamples, updateAnalysisPermission.isAllowed(authentication, submission),
submission.getUpdateSamples());
submission.getUpdateSamples(), canModifySample);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ public class AnalysisDetails {
private boolean updatePermission;
private boolean updateSamples;

private boolean allowedToModifySample;

public AnalysisDetails() {
}

public AnalysisDetails(String analysisDescription, String workflowName, String version, String priority, Long duration,
Date createdDate, AnalysisSubmission.Priority[] priorities, boolean emailPipelineResultCompleted, boolean emailPipelineResultError,
boolean canShareToSamples, boolean updatePermission, boolean updateSamples) {
boolean canShareToSamples, boolean updatePermission, boolean updateSamples, boolean allowedToModifySample) {
this.analysisDescription=analysisDescription;
this.workflowName = workflowName;
this.version = version;
Expand All @@ -40,6 +42,7 @@ public AnalysisDetails(String analysisDescription, String workflowName, String v
this.canShareToSamples = canShareToSamples;
this.updatePermission = updatePermission;
this.updateSamples = updateSamples;
this.allowedToModifySample = allowedToModifySample;
}

public String getAnalysisDescription() {
Expand Down Expand Up @@ -137,4 +140,12 @@ public boolean isUpdateSamples() {
public void setUpdateSamples(boolean updateSamples) {
this.updateSamples = updateSamples;
}

public boolean isAllowedToModifySample() {
return allowedToModifySample;
}

public void setAllowedToModifySample(boolean allowedToModifySample) {
this.allowedToModifySample = allowedToModifySample;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ const initialContext = {
createdDate: null,
priority: null,
priorities: [],
canShareToSamples: false,
updatePermission: false,
updateSamples: false,
canShareToSamples: false, // submission has ability to save results back to samples
updatePermission: false, // user can update the submission details/parameters
updateSamples: false, // Update samples from results on completion
allowedToModifySample: false, // User can modify sample
};

const AnalysisDetailsContext = React.createContext(initialContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,12 @@ export default function AnalysisShare() {
) : null}

{analysisDetailsContext.canShareToSamples &&
analysisDetailsContext.allowedToModifySample &&
analysisContext.isCompleted ? (
<section style={{ marginTop: SPACE_MD }}>
<section
style={{ marginTop: SPACE_MD }}
className="t-save-results-to-samples"
>
<Title level={4}>{i18n("AnalysisShare.saveResults")}</Title>
{renderSaveToRelatedSamples()}
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,22 @@ public void testSharedProjects() {
assertTrue(page.hasSharedWithProjects(), "Analysis shared with projects");
}

@Test
public void testSaveResultBackToSamplesProjectManager() {
LoginPage.loginAsManager(driver());
AnalysisDetailsPage page = AnalysisDetailsPage.initPage(driver(), 11L, "settings/share");
assertTrue(page.compareTabTitle("Manage Results"), "Page title should equal");
assertTrue(page.saveToSamplesVisible(), "Save results back to sample should be visible to a project manager");
}

@Test
public void testSaveResultBackToSamplesProjectUser() {
LoginPage.loginAsUser(driver());
AnalysisDetailsPage page = AnalysisDetailsPage.initPage(driver(), 11L, "settings/share");
assertTrue(page.compareTabTitle("Manage Results"), "Page title should equal");
assertFalse(page.saveToSamplesVisible(), "Save results back to sample should not be visible to a project user");
}

@Test
public void testSistrOutput() throws IOException {
fileUtilities.copyFileToDirectory(outputFileBaseDirectory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public class AnalysisDetailsPage extends AbstractPage {
@FindBy(className = "ant-menu-title-content")
private List<WebElement> menuItems;


public AnalysisDetailsPage(WebDriver driver) {
super(driver);
}
Expand Down Expand Up @@ -527,4 +528,12 @@ public boolean galaxyHistoryIdVisible() {
}
return false;
}

public boolean saveToSamplesVisible() {
try {
return driver.findElement(By.className("t-save-results-to-samples")).isDisplayed();
} catch (Exception e) {
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import ca.corefacility.bioinformatics.irida.ria.web.analysis.dto.*;
import ca.corefacility.bioinformatics.irida.ria.web.analysis.auditing.AnalysisAudit;
import ca.corefacility.bioinformatics.irida.security.permissions.analysis.UpdateAnalysisSubmissionPermission;
import ca.corefacility.bioinformatics.irida.security.permissions.sample.UpdateSamplePermission;
import ca.corefacility.bioinformatics.irida.service.*;
import ca.corefacility.bioinformatics.irida.service.sample.MetadataTemplateService;
import ca.corefacility.bioinformatics.irida.service.sample.SampleService;
Expand Down Expand Up @@ -66,6 +67,8 @@ public class AnalysisAjaxControllerTest {
private AnalysisTypesService analysisTypesServiceMock;
private EmailController emailControllerMock;

private UpdateSamplePermission updateSamplePermission;

/**
* Analysis Output File key names from
* {@link TestDataFactory#constructAnalysis()}
Expand All @@ -89,11 +92,12 @@ public void init() {
httpServletResponseMock = mock(HttpServletResponse.class);
analysisTypesServiceMock = mock(AnalysisTypesService.class);
emailControllerMock = mock(EmailController.class);
updateSamplePermission = mock(UpdateSamplePermission.class);

analysisAjaxController = new AnalysisAjaxController(analysisSubmissionServiceMock, iridaWorkflowsServiceMock,
userServiceMock, sampleService, projectServiceMock, updatePermission, metadataTemplateService,
sequencingObjectService, analysisSubmissionSampleProcessor, messageSourceMock, configFileMock,
analysisAuditMock, analysisTypesServiceMock, emailControllerMock);
analysisAuditMock, analysisTypesServiceMock, emailControllerMock, updateSamplePermission);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
credentialsNonExpired="true" locale="en" />


<project_user id="1" project_id="1" user_id="1"
projectRole="PROJECT_OWNER" metadataRole="LEVEL_4" createdDate="2013-07-18 14:20:19.0"/>
<project_user id="2" project_id="1" user_id="2"
projectRole="PROJECT_USER" metadataRole="LEVEL_4" createdDate="2013-07-18 14:20:19.0"/>

<sequencing_object id="1" created_date="2014-07-30 08:24:34"
sequencing_run_id="1" />
<sequencing_object id="2" created_date="2014-08-01 08:24:34"
Expand Down Expand Up @@ -199,5 +204,6 @@
<analysis_submission_sequencing_object analysis_submission_id="14" sequencing_object_id="1" />

<project_analysis_submission id="1" project_id="1" analysis_submission_id="4" created_date="2013-07-18 14:20:19.0"/>
<project_analysis_submission id="2" project_id="1" analysis_submission_id="11" created_date="2013-07-18 14:20:19.0"/>

</dataset>

0 comments on commit deaecb2

Please sign in to comment.