Skip to content

Commit

Permalink
Merge branch 'master' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
ericenns committed Oct 21, 2022
2 parents a081bb6 + 293a37b commit 4395b5c
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 34 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
# Changelog

## [Unreleased]

## [22.09.1] - 2022/10/21
* [UI]: Fixed when sharing or exporting sample on the project sample page, and other minor bugs. See [PR 1382](https://github.com/phac-nml/irida/pull/1382)

## [22.09] - 2022/10/07
* [Developer/UI]: Refreshed the create new user account page. See [PR 1285](https://github.com/phac-nml/irida/pull/1285)
* [Developer/UI]: Added in typescript support to webpack build, moving forward all new frontend development will use typescript. See [PR 1294](https://github.com/phac-nml/irida/pull/1294) for more.
Expand Down Expand Up @@ -131,8 +135,9 @@

## [...previous](https://github.com/phac-nml/irida/blob/21.09.2/CHANGELOG.md)

[Unreleased]: https://github.com/phac-nml/irida/compare/22.09...HEAD
[Unreleased]: https://github.com/phac-nml/irida/compare/22.09.1...HEAD

[22.09.1]: https://github.com/phac-nml/irida/compare/22.09...22.09.1
[22.09]: https://github.com/phac-nml/irida/compare/22.05.5...22.09
[22.05.5]: https://github.com/phac-nml/irida/compare/22.05.4...22.05.5
[22.05.4]: https://github.com/phac-nml/irida/compare/22.05.3...22.05.4
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ ShareSamples.projects=Select a project to share samples with
ShareSamples.ready=These samples are ready to copy
ShareSamples.exists=Samples that exist in the target project and will not be copied
ShareSamples.avatar.unlocked=This sample is modifiable in this project.
ShareSamples.avatar.locked=This same is not modifiable in this project.
ShareSamples.avatar.locked=This sample is not modifiable in this project.
ShareSamples.remove=Remove
ShareSamplesList.title=Review samples to share
ShareSamples.no-samples.message=All samples exist in the target project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function CartToolsContent({ count, toggleSidebar, collapsed }) {
export default function CartTools({ ...props }) {
return (
<BrowserRouter>
<CartToolsContent {...props} />}
<CartToolsContent {...props} />
</BrowserRouter>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import { getColourForRestriction } from "../../../utilities/restriction-utilitie
import { TargetMetadataRestriction } from "../../../components/metadata/TargetMetadataRestriction";

import { useDispatch, useSelector } from "react-redux";
import { getAllMetadataFieldsForProjects } from "../../../apis/metadata/field";
import {
getAllMetadataFieldsForProjects,
getMetadataRestrictions,
} from "../../../apis/metadata/field";
import { setNewProjectMetadataRestrictions } from "./newProjectSlice";
import { getMetadataRestrictions } from "../../../apis/metadata/field";

/**
* Component to render metadata restrictions for samples that are in the cart (if any).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { connect } from "react-redux";
import { IconShare } from "../../../../../components/icons/Icons";
import { actions as cartActions } from "../../../../../redux/reducers/cart";
import { setBaseUrl } from "../../../../../utilities/url-utilities";
import { storeSamples } from "../../../../../utilities/session-utilities";

/**
* React component for the share sample button. Formats the selected
Expand All @@ -24,14 +25,11 @@ function ShareSamplesButtonComponent({ selected }) {
projectId: sample["irida-static-project-id"],
projectName: sample["irida-static-project-name"],
}));
window.sessionStorage.setItem(
"share",
JSON.stringify({
samples,
projectId,
timestamp: Date.now(),
})
);
storeSamples({
samples,
projectId,
path: `share`,
});

// Redirect user to share page
window.location.href = setBaseUrl(`/projects/${projectId}/share`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function getNCBIPlatformsAsCascaderOptions(): Promise<
*/
export async function hydrateStoredSamples(): Promise<SampleRecord[]> {
try {
const { samples, projectId } = await getStoredSamples();
const { samples, projectId } = await getStoredSamples(`ncbi`);
return getFilesForSamples({
ids: samples.map((sample) => sample.id),
projectId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ export default function SamplesMenu() {

const onNCBI = () => {
if (selected.size === 0) return;
formatAndStoreSamples();
formatAndStoreSamples(`ncbi`);
window.location.href = setBaseUrl(`/projects/${projectId}/ncbi`);
};

const onExport = (type) => {
dispatch(exportSamplesToFile(type));
};

const formatAndStoreSamples = () => {
const formatAndStoreSamples = (path) => {
const samples = Object.values(selected).map(
({ id, sampleName: name, owner, projectId }) => ({
id,
Expand All @@ -135,7 +135,7 @@ export default function SamplesMenu() {
projectId,
})
);
storeSamples({ samples, projectId });
storeSamples({ samples, projectId, path });
};

/**
Expand All @@ -144,7 +144,7 @@ export default function SamplesMenu() {
*/
const shareSamples = () => {
if (selected.size === 0) return;
formatAndStoreSamples();
formatAndStoreSamples(`share`);
// Redirect user to share page
window.location.href = setBaseUrl(`/projects/${projectId}/share`);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,17 @@ export function SamplesTable() {
<div style={{ padding: 8 }} className={filterName}>
<div style={{ marginBottom: 8, display: "block" }}>
<RangePicker
onChange={(dates) =>
setSelectedKeys([
[dates[0].startOf("day"), dates[1].endOf("day")],
])
}
value={selectedKeys[0]}
onChange={(dates) => {
if (dates !== null) {
setSelectedKeys([
[dates[0].startOf("day"), dates[1].endOf("day")],
]);
confirm({ closeDropdown: false });
} else {
handleClearSearch(clearFilters, confirm);
}
}}
/>
</div>
<Space>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ export const updateMetadataRestriction = createAction(
* @type {{currentProject, samples}}
*/
const initialState = (() => {
const stringData = window.sessionStorage.getItem("samples");
const match = window.location.href.match(/projects\/(\d+)/);
if (!match) {
return {};
}
const [, id] = match;
const stringData = window.sessionStorage.getItem(`share-${id}`);

if (stringData === null) {
return {};
Expand Down
21 changes: 16 additions & 5 deletions src/main/webapp/resources/js/utilities/session-utilities.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
import { StoredSample } from "../types/irida";

const SAMPLE_STORE = "samples";

export interface SessionSample {
projectId: number;
samples: StoredSample[];
timestamp: Date;
}

/**
* Store samples into sessionStorage
* @param samples - List of samples to store
* @param projectId - Current project identifier
* @param path - path the samples will be used at
*/
export function storeSamples({
samples,
projectId,
path,
}: {
samples: StoredSample[];
projectId: number;
path: string;
}): void {
sessionStorage.setItem(
SAMPLE_STORE,
`${path}-${projectId}`,
JSON.stringify({
projectId,
samples,
Expand All @@ -25,8 +31,13 @@ export function storeSamples({
);
}

export async function getStoredSamples(): Promise<SessionSample> {
const stored = sessionStorage.getItem(SAMPLE_STORE);
/**
* Retrieve samples stored into local storage
* @param path - location where the sample will be used
*/
export async function getStoredSamples(path: string): Promise<SessionSample> {
const [, id] = window.location.href.match(/projects\/(\d+)/) || [];
const stored = sessionStorage.getItem(`${path}-${id}`);
if (stored) {
return Promise.resolve(JSON.parse(stored));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package ca.corefacility.bioinformatics.irida.ria.integration.projects;

import org.junit.jupiter.api.Test;
import org.openqa.selenium.Dimension;

import ca.corefacility.bioinformatics.irida.ria.integration.AbstractIridaUIITChromeDriver;
import ca.corefacility.bioinformatics.irida.ria.integration.pages.LoginPage;
import ca.corefacility.bioinformatics.irida.ria.integration.pages.projects.ProjectLineListPage;

import ca.corefacility.bioinformatics.irida.ria.integration.pages.projects.ShareSamplesPage;
import com.github.springtestdbunit.annotation.DatabaseSetup;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.Dimension;

import static org.junit.jupiter.api.Assertions.*;

Expand Down Expand Up @@ -140,6 +139,9 @@ public void testPageAsManager() {
assertTrue(page.isShareButtonEnabled(), "Share button should now be enabled");
page.shareSelectedSamples();
assertTrue(driver().getCurrentUrl().contains("share"), "Should be on the share samples page");

ShareSamplesPage shareSamplesPage = ShareSamplesPage.initPage(driver());
shareSamplesPage.searchForProject("project2");
shareSamplesPage.gotToNextStep();
assertEquals(3, shareSamplesPage.getNumberOfSamplesDisplayed());
}
}

0 comments on commit 4395b5c

Please sign in to comment.