Skip to content

Commit 3c8a337

Browse files
authored
Merge pull request #5148 from topcoder-platform/apollo-site
Apollo site
2 parents 763eb71 + 44e06b8 commit 3c8a337

File tree

6 files changed

+167
-3
lines changed

6 files changed

+167
-3
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ workflows:
238238
filters:
239239
branches:
240240
only:
241-
- hot-fix
241+
- apollo-site
242242
# This is alternate dev env for parallel testing
243243
- "build-qa":
244244
context : org-global
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/**
2+
* High order component that apply front-side password protection
3+
* before loading a Contentful Viewport. It uses sessionStorage for working.
4+
*/
5+
import PT from 'prop-types';
6+
import React from 'react';
7+
import Viewport from 'components/Contentful/Viewport';
8+
import TextInput from 'components/GUIKit/TextInput';
9+
10+
import './style.scss';
11+
12+
export default class PasswordScreen extends React.Component {
13+
state = {};
14+
15+
constructor(props) {
16+
super(props);
17+
18+
this.onSubmit = this.onSubmit.bind(this);
19+
this.onPasswordInput = this.onPasswordInput.bind(this);
20+
}
21+
22+
onSubmit() {
23+
const { password } = this.props;
24+
const { inputVal } = this.state;
25+
this.setState({
26+
authorized: password === inputVal,
27+
errorMsg: password === inputVal ? '' : 'Password incorrect',
28+
});
29+
}
30+
31+
onPasswordInput(inputVal) {
32+
const update = {
33+
inputVal,
34+
};
35+
if (!inputVal) update.errorMsg = '';
36+
this.setState(update);
37+
}
38+
39+
render() {
40+
const {
41+
authorized, errorMsg, inputVal,
42+
} = this.state;
43+
const {
44+
viewPortId, preview, spaceName, environment, baseUrl, title,
45+
} = this.props;
46+
return authorized ? (
47+
<Viewport
48+
id={viewPortId}
49+
preview={preview}
50+
spaceName={spaceName}
51+
environment={environment}
52+
baseUrl={baseUrl}
53+
/>
54+
) : (
55+
<div styleName="wrapper">
56+
<div styleName="container">
57+
<h4>{title || 'GET ACCESS WITH PASSWORD'}</h4>
58+
<p styleName="hint">Please enter the password you were provided</p>
59+
<TextInput
60+
placeholder="Password"
61+
label="Password"
62+
onChange={val => this.onPasswordInput(val)}
63+
errorMsg={errorMsg}
64+
required
65+
/>
66+
<div styleName="cta">
67+
<button type="button" styleName="submit" onClick={this.onSubmit} disabled={!inputVal}>SUBMIT</button>
68+
</div>
69+
</div>
70+
</div>
71+
);
72+
}
73+
}
74+
75+
PasswordScreen.defaultProps = {
76+
preview: false,
77+
spaceName: null,
78+
environment: null,
79+
baseUrl: '',
80+
title: 'GET ACCESS WITH PASSWORD',
81+
};
82+
83+
PasswordScreen.propTypes = {
84+
password: PT.string.isRequired,
85+
viewPortId: PT.string.isRequired,
86+
preview: PT.bool,
87+
spaceName: PT.string,
88+
environment: PT.string,
89+
baseUrl: PT.string,
90+
title: PT.string,
91+
};
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
@import "~styles/mixins";
2+
@import "~components/Contentful/default";
3+
@import "~components/GUIKit/Assets/Styles/default";
4+
5+
.wrapper {
6+
background-color: #e9e9e9;
7+
padding: 86px 0 121px 0;
8+
min-height: 100vh;
9+
10+
.container {
11+
text-align: center;
12+
border-radius: 10px;
13+
max-width: 544px;
14+
max-height: 371px;
15+
margin: 0 auto;
16+
padding: 31px 65px;
17+
background-color: #fff;
18+
19+
@include gui-kit-headers;
20+
@include gui-kit-content;
21+
22+
h4 {
23+
margin-bottom: 5px;
24+
}
25+
26+
.hint {
27+
font-size: 14px;
28+
margin-bottom: 30px;
29+
}
30+
31+
.cta {
32+
margin: 50px auto 29px auto;
33+
}
34+
35+
.submit {
36+
outline: none;
37+
38+
@include primary-green;
39+
@include md;
40+
41+
&:disabled,
42+
&:hover:disabled {
43+
background-color: #e9e9e9 !important;
44+
border: none !important;
45+
text-decoration: none !important;
46+
color: #fafafb !important;
47+
box-shadow: none !important;
48+
}
49+
}
50+
}
51+
}

src/shared/components/Contentful/Route.jsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import PT from 'prop-types';
1212
import React from 'react';
1313
import { Route, Switch } from 'react-router-dom';
1414
import Viewport from 'components/Contentful/Viewport';
15+
import PasswordScreen from 'components/Contentful/PasswordScreen';
1516

1617
// Concatenates a base and segment and handles optional trailing slashes
1718
const buildUrl = (base, segment) => `${_.trimEnd(base, '/')}/${_.trim(segment, '/')}`;
@@ -51,15 +52,27 @@ function ChildRoutesLoader(props) {
5152
url={fields.socialUrl}
5253
/>
5354
{
55+
// eslint-disable-next-line no-nested-ternary
5456
fields.viewport
55-
? (
57+
? (!fields.password ? (
5658
<Viewport
5759
id={fields.viewport.sys.id}
5860
preview={preview}
5961
spaceName={spaceName}
6062
environment={environment}
6163
baseUrl={url}
6264
/>
65+
) : (
66+
<PasswordScreen
67+
password={fields.password}
68+
viewPortId={fields.viewport.sys.id}
69+
preview={preview}
70+
spaceName={spaceName}
71+
environment={environment}
72+
baseUrl={url}
73+
title={fields.passwordScreenTitle}
74+
/>
75+
)
6376
) : <Error404 />
6477
}
6578
</React.Fragment>

src/shared/components/Gigs/GigApply/style.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@
242242
}
243243
}
244244
}
245-
/* stylelint-disable */
245+
/* stylelint-disable */
246246
.cta-buttons {
247247
display: flex;
248248
justify-content: center;

src/shared/routes/index.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,15 @@ function Routes({ communityId }) {
127127
exact
128128
path={config.START_PAGE_PATH}
129129
/>
130+
<Route
131+
render={() => (
132+
<ContentfulRoute
133+
baseUrl="/apollo"
134+
id="4Ie8cLj2OvuFqbU46HBGQM"
135+
/>
136+
)}
137+
path="/apollo"
138+
/>
130139
<Topcoder />
131140
</Switch>
132141
</div>

0 commit comments

Comments
 (0)