Skip to content

Commit 20eb2af

Browse files
committed
Frontend: reintroducing site redirection for "staging" version
1 parent ae8dcba commit 20eb2af

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

frontend/src/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import {getElemsByClass, getElemById} from './ts/dom-utils';
44
import {widgetFactory} from './ts/widget';
55
import {scrollTop} from './ts/scrolltop';
66

7+
// #if STAGING
8+
import {stagingRedirect} from './ts/staging';
9+
// #endif
10+
711
/**
812
* Entrypoint
913
* The main entrypoint for the application
@@ -17,6 +21,12 @@ function entrypoint(): void {
1721
// register scroll to top btn functionality
1822
const btn = getElemById('scrollToTopBtn');
1923
scrollTop(btn as HTMLButtonElement);
24+
25+
// #if STAGING
26+
// This is used to redirect non AdaCore staff to the main site if
27+
// the staging site is accidentally reached
28+
stagingRedirect();
29+
// #endif
2030
}
2131

2232
(function(): void {

frontend/src/ts/staging.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import Cookies from 'js-cookie';
2+
3+
/**
4+
* Redirects the user to main learn site if not AdaCore employee
5+
*
6+
* @export
7+
*/
8+
export function stagingRedirect(): void {
9+
/* istanbul ignore next */
10+
if (!Cookies.get('AdaCore_staff')) {
11+
const msg = 'You have reached learn-staging, the learn testing site. ' +
12+
'This is reserved for testers only. You will be directed to the main ' +
13+
'learn.adacore.com site after pressing OK.';
14+
alert(msg);
15+
window.location.href = 'http://learn.adacore.com';
16+
}
17+
}

0 commit comments

Comments
 (0)