Skip to content

Commit 76069c0

Browse files
MillenniumFalconMechanicNoopDog
authored andcommitted
Added release files modal. Resolves #1047. (#1079)
1 parent 94b8abd commit 76069c0

File tree

48 files changed

+1621
-104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1621
-104
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Human Cell Atlas
3+
* https://www.humancellatlas.org/
4+
*
5+
* Action triggered when release files modal referrer indicator should be cleared.
6+
*/
7+
8+
// Core dependencies
9+
import { Action } from "@ngrx/store";
10+
11+
export class ClearReleaseFilesReferrerAction implements Action {
12+
public static ACTION_TYPE = "RELEASES.CLEAR_RELEASE_FILES_REFERRER";
13+
public readonly type = ClearReleaseFilesReferrerAction.ACTION_TYPE;
14+
constructor() {}
15+
}
16+

spa/src/app/files/_ngrx/release/clear-release-referrer.action.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Human Cell Atlas
33
* https://www.humancellatlas.org/
44
*
5-
* Action triggered when release referrer indicator should be cleared.
5+
* Action triggered when release list page referrer indicator should be cleared.
66
*/
77

88
// Core dependencies

spa/src/app/files/_ngrx/release/fetch-releases-success.action.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import { Action } from "@ngrx/store";
1010

1111
// App dependencies
12-
import { Release } from "../../releases/2020-march/release.model";
12+
import { Release } from "../../releases/release.model";
1313

1414
export class FetchReleasesSuccessAction implements Action {
1515
public static ACTION_TYPE = "RELEASES.RELEASES_SUCCESS";

spa/src/app/files/_ngrx/release/release.reducer.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@ import { FetchReleasesRequestAction } from "./fetch-releases-request.action";
1414
import { FetchReleasesSuccessAction } from "./fetch-releases-success.action";
1515
import { ReleaseState } from "./release.state";
1616
import { SetReleaseReferrerAction } from "./set-release-referrer.action";
17+
import { ClearReleaseFilesReferrerAction } from "./clear-release-files-referrer.action";
18+
import { SetReleaseFilesReferrerAction } from "./set-release-files-referrer.action";
1719

1820
export function reducer(state: ReleaseState = ReleaseState.getDefaultState(), action: Action): ReleaseState {
1921

2022
switch (action.type) {
2123

24+
case ClearReleaseFilesReferrerAction.ACTION_TYPE:
25+
return state.clearReleaseFilesReferrer();
26+
2227
case ClearReleaseReferrerAction.ACTION_TYPE:
2328
return state.clearReleaseReferrer();
2429

@@ -27,6 +32,9 @@ export function reducer(state: ReleaseState = ReleaseState.getDefaultState(), ac
2732

2833
case FetchReleasesSuccessAction.ACTION_TYPE:
2934
return state.fetchReleasesSuccess(action as FetchReleasesSuccessAction);
35+
36+
case SetReleaseFilesReferrerAction.ACTION_TYPE:
37+
return state.setReleaseFilesReferrer();
3038

3139
case SetReleaseReferrerAction.ACTION_TYPE:
3240
return state.setReleaseReferrer();

spa/src/app/files/_ngrx/release/release.selectors.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@ export const selectReleaseByName =
3131
/**
3232
* Returns the release with only the specified project, if project is a part of the release.
3333
*/
34-
export const selectReleaseByNameAndProjectId =
34+
export const selectReleaseByProjectId =
3535
createSelector(selectReleases, (state, props) => {
36+
3637
const release = state.releasesByName.get(props.name);
38+
39+
// Filter down the set of projects in this release to just the project we are looking for
3740
const project = release.projects.find(project => project.entryId === props.projectId);
3841
return Object.assign({}, release, {
3942
projects: project ? [project] : []
@@ -46,3 +49,37 @@ export const selectReleaseByNameAndProjectId =
4649
export const selectReleaseReferrer =
4750
createSelector(selectReleases, (state) => state.releaseReferrer);
4851

52+
/**
53+
* Return the release files referrer.
54+
*/
55+
export const selectReleaseFilesReferrer =
56+
createSelector(selectReleases, (state) => state.releaseFilesReferrer);
57+
58+
/**
59+
* Return the dataset with the specified ID, for the specified project and release.
60+
*/
61+
export const selectReleaseByDataset =
62+
createSelector(selectReleases, (state, props) => {
63+
64+
const release = state.releasesByName.get(props.name);
65+
const project = release.projects.find(project => project.entryId === props.projectId);
66+
67+
// If project is not part of the release, return release with an empty array of projects
68+
if ( !project ) {
69+
return Object.assign({}, release, {
70+
projects: []
71+
});
72+
}
73+
74+
// Filter the datasets down the one we are looking for and modify the project to contain just that single dataset.
75+
const dataset = project.datasets.find(dataset => dataset.datasetId === props.datasetId);
76+
const projectWithFilteredDatasets = Object.assign({}, project, {
77+
datasets: dataset ? [dataset] : []
78+
});
79+
80+
// Return release containing just the project and dataset we're looking for
81+
return Object.assign({}, release, {
82+
projects: [projectWithFilteredDatasets]
83+
});
84+
});
85+

spa/src/app/files/_ngrx/release/release.state.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@
66
*/
77

88
// App dependencies
9-
import { Release } from "../../releases/2020-march/release.model";
9+
import { Release } from "../../releases/release.model";
1010
import { FetchReleasesSuccessAction } from "./fetch-releases-success.action";
1111
import { Releases } from "./releases.model";
1212

1313
const DEFAULT_RELEASE_STATE = {
1414
releasesByName: new Map(),
15+
releaseFilesReferrer: false,
1516
releaseReferrer: false
1617
};
1718

1819
export class ReleaseState implements Releases {
1920

2021
releasesByName: Map<string, Release>;
22+
releaseFilesReferrer: boolean;
2123
releaseReferrer: boolean;
2224

2325
/**
@@ -27,6 +29,17 @@ export class ReleaseState implements Releases {
2729
Object.assign(this, state);
2830
}
2931

32+
/**
33+
* Set release files referrer to false.
34+
*/
35+
public clearReleaseFilesReferrer(): ReleaseState {
36+
37+
return new ReleaseState({
38+
releasesByName: this.releasesByName,
39+
releaseFilesReferrer: false,
40+
releaseReferrer: this.releaseReferrer
41+
});
42+
}
3043

3144
/**
3245
* Set release referrer to false.
@@ -35,6 +48,7 @@ export class ReleaseState implements Releases {
3548

3649
return new ReleaseState({
3750
releasesByName: this.releasesByName,
51+
releaseFilesReferrer: this.releaseFilesReferrer,
3852
releaseReferrer: false
3953
});
4054
}
@@ -59,18 +73,32 @@ export class ReleaseState implements Releases {
5973

6074
return new ReleaseState({
6175
releasesByName,
76+
releaseFilesReferrer: this.releaseFilesReferrer,
6277
releaseReferrer: this.releaseReferrer
6378
});
6479
}
6580

81+
/**
82+
* Set release files referrer to true.
83+
*/
84+
public setReleaseFilesReferrer(): ReleaseState {
85+
86+
return new ReleaseState({
87+
releasesByName: this.releasesByName,
88+
releaseReferrer: this.releaseReferrer,
89+
releaseFilesReferrer: true
90+
});
91+
}
92+
6693
/**
6794
* Set release referrer to true.
6895
*/
6996
public setReleaseReferrer(): ReleaseState {
7097

7198
return new ReleaseState({
7299
releasesByName: this.releasesByName,
73-
releaseReferrer: true
100+
releaseReferrer: true,
101+
releaseFilesReferrer: this.releaseFilesReferrer
74102
});
75103
}
76104

spa/src/app/files/_ngrx/release/releases.model.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
*/
77

88
// App dependencies
9-
import { Release } from "../../releases/2020-march/release.model";
9+
import { Release } from "../../releases/release.model";
1010

1111
export interface Releases {
1212
releasesByName: Map<string, Release>;
13+
releaseFilesReferrer: boolean;
1314
releaseReferrer: boolean;
1415
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Human Cell Atlas
3+
* https://www.humancellatlas.org/
4+
*
5+
* Action triggered when release files modal should return to the release list page on close, and not the project
6+
* release tab.
7+
*/
8+
9+
// Core dependencies
10+
import { Action } from "@ngrx/store";
11+
12+
export class SetReleaseFilesReferrerAction implements Action {
13+
public static ACTION_TYPE = "RELEASES.SET_RELEASE_FILES_REFERRER";
14+
public readonly type = SetReleaseFilesReferrerAction.ACTION_TYPE;
15+
constructor() {}
16+
}
17+

spa/src/app/files/_ngrx/release/set-release-referrer.action.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22
* Human Cell Atlas
33
* https://www.humancellatlas.org/
44
*
5-
* Action triggered when project-specific pages should return to the release page, and not the natural app page.
6-
* Specifically:
7-
*
8-
* 1. Project detail back button returns to release page and not to projects tab
9-
* 2. Release files modal close button returns to release page and not to project detail release tab
5+
* Action triggered when project-specific pages should return to the release list page, and not the natural app page.
6+
* Specifically, project detail back button returns to release list page and not to projects tab.
107
*/
118

129
// Core dependencies

spa/src/app/files/files.module.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ import { ProjectReleaseComponent } from "./project-release/project-release.compo
100100
import { ProjectSummaryStatsComponent } from "./project-summary-stats-component/project-summary-stats.component";
101101
import { ProjectViewFactory } from "./project-view/project-view.factory";
102102
import { ReleaseComponent } from "./releases/release.component";
103+
import { ReleaseFileComponent } from "./releases/release-file/release-file.component";
104+
import { ReleaseFileDownloadComponent } from "./releases/release-file-download/release-file-download.component";
105+
import { ReleaseFilesModalComponent } from "./releases/release-files-modal/release-files-modal.component";
106+
import { ReleaseFilesModalContainerComponent } from "./releases/release-files-modal-container/release-files-modal-container.component";
103107
import { ReleaseTableComponent } from "./releases/release-table/release-table.component";
104108
import { ReleaseTitleOverlineComponent } from "./releases/release-title-overline/release-title-overline.component";
105109
import { SearchTermService } from "./shared/search-term.service";
@@ -212,13 +216,18 @@ import { ReleaseService } from "./shared/release.service";
212216
ProjectSummaryStatsComponent,
213217
ProjectSupplementaryLinksComponent,
214218
ReleaseComponent,
219+
ReleaseFileComponent,
220+
ReleaseFileDownloadComponent,
221+
ReleaseFilesModalComponent,
222+
ReleaseFilesModalContainerComponent,
215223
ReleaseTableComponent,
216224
ReleaseTitleOverlineComponent,
217225
TableScroll
218226
],
219227
entryComponents: [
220228
ProjectDownloadManifestModalComponent,
221-
ProjectDownloadMatrixModalComponent
229+
ProjectDownloadMatrixModalComponent,
230+
ReleaseFilesModalComponent
222231
],
223232
providers: [
224233
ConfigService,

0 commit comments

Comments
 (0)