Skip to content

Commit 423f5f3

Browse files
Hid release functionality for env other than local/ux-dev. Resolves #1153. (#1154)
1 parent b195bd8 commit 423f5f3

File tree

7 files changed

+82
-13
lines changed

7 files changed

+82
-13
lines changed

spa/src/app/app.component.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { ActivatedRouteStub } from "./test/activated-route.stub";
3838
import { CCToolbarNavSubMenuComponent } from "./shared/cc-toolbar-nav-sub-menu/cc-toolbar-nav-sub-menu.component";
3939
import { CCToolbarNavSubMenuItemComponent } from "./shared/cc-toolbar-nav-sub-menu-item/cc-toolbar-nav-sub-menu-item.component";
4040
import { CCToolbarNavDropDownComponent } from "./shared/cc-toolbar-nav-drop-down/cc-toolbar-nav-drop-down.component";
41+
import { ReleaseService } from "./files/shared/release.service";
4142

4243

4344
describe("AppComponent:", () => {
@@ -101,6 +102,9 @@ describe("AppComponent:", () => {
101102
}, {
102103
provide: LocalStorageService,
103104
useValue: jasmine.createSpyObj("LocalStorageService", ["get", "set"])
105+
}, {
106+
provide: ReleaseService,
107+
useValue: jasmine.createSpyObj("ReleaseService", ["buildReleaseView", "createReleaseDatasetView", "fetch2020MarchRelease", "isReleaseVisible"])
104108
}]
105109
});
106110

spa/src/app/app.component.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { selectConfigConfig } from "./config/_ngrx/config.selectors";
1919
import { SetViewStateAction } from "./files/_ngrx/file-facet-list/set-view-state.action";
2020
import { ClearReleaseReferrerAction } from "./files/_ngrx/release/clear-release-referrer.action";
2121
import { FetchProjectEditsRequestAction } from "./files/_ngrx/project-edits/fetch-project-edits-request.action";
22+
import { ReleaseService } from "./files/shared/release.service";
2223
import { EntityName } from "./files/shared/entity-name.model";
2324
import { FileFacetName } from "./files/shared/file-facet-name.model";
2425
import { QueryStringFacet } from "./files/shared/query-string-facet.model";
@@ -49,13 +50,15 @@ export class AppComponent implements OnInit, OnDestroy {
4950

5051
/**
5152
* @param {DeviceDetectorService} deviceService
53+
* @param {ReleaseService} releaseService
5254
* @param {Store<AppState>} store
5355
* @param {ActivatedRoute} activatedRoute
5456
* @param {Location} location
5557
* @param {Router} router
5658
* @param {Renderer2} renderer
5759
*/
5860
constructor(private deviceService: DeviceDetectorService,
61+
private releaseService: ReleaseService,
5962
private store: Store<AppState>,
6063
private activatedRoute: ActivatedRoute,
6164
private location: Location,
@@ -106,11 +109,16 @@ export class AppComponent implements OnInit, OnDestroy {
106109
}
107110

108111
/**
109-
* Returns true when the url path is not the releases or project detail pages.
112+
* Returns true when the url path is not the releases or project detail pages, and if we're currently on an
113+
* environment where release is visible.
110114
*
111115
* @returns {boolean}
112116
*/
113117
public showRelease() {
118+
119+
if ( !this.releaseService.isReleaseVisible() ) {
120+
return false;
121+
}
114122

115123
return !( this.router.url.includes("/releases/") || this.router.url.includes("/projects/") );
116124
}

spa/src/app/config/config.service.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,26 @@ export class ConfigService {
151151
return "";
152152
}
153153

154+
/**
155+
* Returns true if the current environment is local.
156+
*
157+
* @returns {boolean}
158+
*/
159+
public isEnvLocal(): boolean {
160+
161+
return this.deployment === "local";
162+
}
163+
164+
/**
165+
* Returns true if the current environment is ux-dev.
166+
*
167+
* @returns {boolean}
168+
*/
169+
public isEnvUxDev(): boolean {
170+
171+
return this.deployment === "ux-dev";
172+
}
173+
154174
/**
155175
* Save the data URL as a local variable ogetAPIURLn this instance, and update the corresponding config value in the store.
156176
*

spa/src/app/files/project-nav/project-nav.component.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ import { Subject } from "rxjs";
1313
import { takeUntil } from "rxjs/operators";
1414

1515
// App dependencies
16-
import { NavItem } from "../../shared/nav/nav-item.model";
17-
import { EntityName } from "../shared/entity-name.model";
1816
import { ProjectNav } from "./project-nav.model";
17+
import { EntityName } from "../shared/entity-name.model";
18+
import { NavItem } from "../../shared/nav/nav-item.model";
19+
import { ReleaseService } from "../shared/release.service";
1920

2021
@Component({
2122
selector: "project-nav",
@@ -42,8 +43,11 @@ export class ProjectNavComponent {
4243
/**
4344
* @param {ActivatedRoute} route
4445
* @param {DeviceDetectorService} deviceService
46+
* @param {ReleaseService} releaseService
4547
*/
46-
constructor(private route: ActivatedRoute, private deviceService: DeviceDetectorService) {
48+
constructor(private route: ActivatedRoute,
49+
private deviceService: DeviceDetectorService,
50+
private releaseService: ReleaseService) {
4751
}
4852

4953
/**
@@ -73,7 +77,7 @@ export class ProjectNavComponent {
7377
];
7478

7579
// Check if project is a part of the release and add "releases" to the nav accordingly
76-
if ( this.projectInRelease ) {
80+
if ( this.releaseService.isReleaseVisible() && this.projectInRelease ) {
7781

7882
navItemList.push(this.projectReleases);
7983
}
@@ -174,14 +178,16 @@ export class ProjectNavComponent {
174178
routerLink: this.buildRouterLinkForSection(projectId, ProjectNav.DATA_CITATION)
175179
};
176180

177-
this.projectReleases = {
178-
disabled: false,
179-
display: "Releases",
180-
subNavItems: [{
181+
if ( this.releaseService.isReleaseVisible() ) {
182+
this.projectReleases = {
181183
disabled: false,
182-
display: "2020 March Data Release",
183-
routerLink: this.buildRouterLinkForSection(projectId, ProjectNav.DATA_RELEASE_2020_MAR)
184-
}]
184+
display: "Releases",
185+
subNavItems: [{
186+
disabled: false,
187+
display: "2020 March Data Release",
188+
routerLink: this.buildRouterLinkForSection(projectId, ProjectNav.DATA_RELEASE_2020_MAR)
189+
}]
190+
}
185191
}
186192
});
187193
}

spa/src/app/files/shared/release.service.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { ReleaseDatasetView } from "../releases/release-dataset-view.model";
1919
import { ReleaseFileView } from "../releases/release-file-view.model";
2020
import { ReleaseFileType } from "../releases/release-file-type.model";
2121
import { ReleaseVisualizationView } from "../releases/release-visualization-view.model";
22+
import { ConfigService } from "../../config/config.service";
2223

2324
@Injectable()
2425
export class ReleaseService {
@@ -38,6 +39,11 @@ export class ReleaseService {
3839
[`${ReleaseFileType.PIPELINE_INPUT}loom`, "Gene matrix file generated with DCP standardized pipelines (Optimus and Smart-seq2) and used as Cumulus input."]
3940
]);
4041

42+
/**
43+
* @param {ConfigService} configService
44+
*/
45+
constructor(private configService: ConfigService) {}
46+
4147
/**
4248
* Build view model of release. That is, project datasets grouped by organ.
4349
*
@@ -118,6 +124,17 @@ export class ReleaseService {
118124
return of(release2020March as Release);
119125
}
120126

127+
/**
128+
* Returns true if release functionality is visible for the current environment - currently only visible on local
129+
* and ux-dev.
130+
*
131+
* @returns {boolean}
132+
*/
133+
public isReleaseVisible(): boolean {
134+
135+
return this.configService.isEnvLocal() || this.configService.isEnvUxDev();
136+
}
137+
121138
/**
122139
* Create view models for each release file in the specified dataset.
123140
*

spa/src/app/site/hca-toolbar/hca-toolbar.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
<span class="fontsize-xxs">APIs</span>
5252
</a>
5353
</cc-toolbar-nav-item>
54-
<cc-toolbar-nav-item [ngClass]="{'active': isReleasesActiveUrl(), 'drop-down-menu': true}">
54+
<cc-toolbar-nav-item *ngIf="isReleaseVisible()"
55+
[ngClass]="{'active': isReleasesActiveUrl(), 'drop-down-menu': true}">
5556
<button class="link" (click)="toggleDropDownMenu($event)">
5657
<span class="fontsize-xs">March 2020 Release</span>
5758
<span class="fontsize-xxs">Explore, visualize, and interact with 24 annotated datasets</span>

spa/src/app/site/hca-toolbar/hca-toolbar.component.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { filter, takeUntil } from "rxjs/operators";
1414

1515
// App dependencies
1616
import { ConfigService } from "../../config/config.service";
17+
import { ReleaseService } from "../../files/shared/release.service";
1718
import { HCAToolbarState } from "./hca-toolbar.state";
1819
import { selectModalOpen } from "../../modal/_ngrx/modal.selectors";
1920
import { AppState } from "../../_ngrx/app.state";
@@ -42,10 +43,12 @@ export class HCAToolbarComponent implements OnDestroy, OnInit {
4243
/**
4344
* @param {Store<AppState>} store
4445
* @param {ConfigService} configService
46+
* @param {ReleaseService} releaseService
4547
* @param {Router} router
4648
*/
4749
constructor(private store: Store<AppState>,
4850
private configService: ConfigService,
51+
private releaseService: ReleaseService,
4952
private router: Router) {
5053
this.portalUrl = this.configService.getPortalURL();
5154
}
@@ -95,6 +98,16 @@ export class HCAToolbarComponent implements OnDestroy, OnInit {
9598
return this.currentUrl && this.currentUrl.includes("releases");
9699
}
97100

101+
/**
102+
* Returns true if release functionality is available on the current environment.
103+
*
104+
* @returns {boolean}
105+
*/
106+
public isReleaseVisible(): boolean {
107+
108+
return this.releaseService.isReleaseVisible();
109+
}
110+
98111
/**
99112
* Event registering the opening or closing of the toolbar nav drop down menu.
100113
*

0 commit comments

Comments
 (0)