Skip to content

Apollo site #5148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ workflows:
filters:
branches:
only:
- hot-fix
- apollo-site
# This is alternate dev env for parallel testing
- "build-qa":
context : org-global
Expand Down
91 changes: 91 additions & 0 deletions src/shared/components/Contentful/PasswordScreen/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/**
* High order component that apply front-side password protection
* before loading a Contentful Viewport. It uses sessionStorage for working.
*/
import PT from 'prop-types';
import React from 'react';
import Viewport from 'components/Contentful/Viewport';
import TextInput from 'components/GUIKit/TextInput';

import './style.scss';

export default class PasswordScreen extends React.Component {
state = {};

constructor(props) {
super(props);

this.onSubmit = this.onSubmit.bind(this);
this.onPasswordInput = this.onPasswordInput.bind(this);
}

onSubmit() {
const { password } = this.props;
const { inputVal } = this.state;
this.setState({
authorized: password === inputVal,
errorMsg: password === inputVal ? '' : 'Password incorrect',
});
}

onPasswordInput(inputVal) {
const update = {
inputVal,
};
if (!inputVal) update.errorMsg = '';
this.setState(update);
}

render() {
const {
authorized, errorMsg, inputVal,
} = this.state;
const {
viewPortId, preview, spaceName, environment, baseUrl, title,
} = this.props;
return authorized ? (
<Viewport
id={viewPortId}
preview={preview}
spaceName={spaceName}
environment={environment}
baseUrl={baseUrl}
/>
) : (
<div styleName="wrapper">
<div styleName="container">
<h4>{title || 'GET ACCESS WITH PASSWORD'}</h4>
<p styleName="hint">Please enter the password you were provided</p>
<TextInput
placeholder="Password"
label="Password"
onChange={val => this.onPasswordInput(val)}
errorMsg={errorMsg}
required
/>
<div styleName="cta">
<button type="button" styleName="submit" onClick={this.onSubmit} disabled={!inputVal}>SUBMIT</button>
</div>
</div>
</div>
);
}
}

PasswordScreen.defaultProps = {
preview: false,
spaceName: null,
environment: null,
baseUrl: '',
title: 'GET ACCESS WITH PASSWORD',
};

PasswordScreen.propTypes = {
password: PT.string.isRequired,
viewPortId: PT.string.isRequired,
preview: PT.bool,
spaceName: PT.string,
environment: PT.string,
baseUrl: PT.string,
title: PT.string,
};
51 changes: 51 additions & 0 deletions src/shared/components/Contentful/PasswordScreen/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
@import "~styles/mixins";
@import "~components/Contentful/default";
@import "~components/GUIKit/Assets/Styles/default";

.wrapper {
background-color: #e9e9e9;
padding: 86px 0 121px 0;
min-height: 100vh;

.container {
text-align: center;
border-radius: 10px;
max-width: 544px;
max-height: 371px;
margin: 0 auto;
padding: 31px 65px;
background-color: #fff;

@include gui-kit-headers;
@include gui-kit-content;

h4 {
margin-bottom: 5px;
}

.hint {
font-size: 14px;
margin-bottom: 30px;
}

.cta {
margin: 50px auto 29px auto;
}

.submit {
outline: none;

@include primary-green;
@include md;

&:disabled,
&:hover:disabled {
background-color: #e9e9e9 !important;
border: none !important;
text-decoration: none !important;
color: #fafafb !important;
box-shadow: none !important;
}
}
}
}
15 changes: 14 additions & 1 deletion src/shared/components/Contentful/Route.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import PT from 'prop-types';
import React from 'react';
import { Route, Switch } from 'react-router-dom';
import Viewport from 'components/Contentful/Viewport';
import PasswordScreen from 'components/Contentful/PasswordScreen';

// Concatenates a base and segment and handles optional trailing slashes
const buildUrl = (base, segment) => `${_.trimEnd(base, '/')}/${_.trim(segment, '/')}`;
Expand Down Expand Up @@ -51,15 +52,27 @@ function ChildRoutesLoader(props) {
url={fields.socialUrl}
/>
{
// eslint-disable-next-line no-nested-ternary
fields.viewport
? (
? (!fields.password ? (
<Viewport
id={fields.viewport.sys.id}
preview={preview}
spaceName={spaceName}
environment={environment}
baseUrl={url}
/>
) : (
<PasswordScreen
password={fields.password}
viewPortId={fields.viewport.sys.id}
preview={preview}
spaceName={spaceName}
environment={environment}
baseUrl={url}
title={fields.passwordScreenTitle}
/>
)
) : <Error404 />
}
</React.Fragment>
Expand Down
2 changes: 1 addition & 1 deletion src/shared/components/Gigs/GigApply/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
}
}
}
/* stylelint-disable */
/* stylelint-disable */
.cta-buttons {
display: flex;
justify-content: center;
Expand Down
9 changes: 9 additions & 0 deletions src/shared/routes/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ function Routes({ communityId }) {
exact
path={config.START_PAGE_PATH}
/>
<Route
render={() => (
<ContentfulRoute
baseUrl="/apollo"
id="4Ie8cLj2OvuFqbU46HBGQM"
/>
)}
path="/apollo"
/>
<Topcoder />
</Switch>
</div>
Expand Down