Skip to content

Pass screen updates #5184

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 7 commits into from
Nov 10, 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 @@ -260,7 +260,7 @@ workflows:
filters:
branches:
only:
- develop
- pass-screen-updates
# Production builds are exectuted
# when PR is merged to the master
# Don't change anything in this configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ exports[`Default render 1`] = `
defaultValue=""
onBlur={[Function]}
onChange={[Function]}
onKeyPress={[Function]}
placeholder=""
type="text"
/>
Expand Down
31 changes: 25 additions & 6 deletions src/shared/components/Contentful/PasswordScreen/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ export default class PasswordScreen extends React.Component {

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

Expand All @@ -41,7 +43,7 @@ export default class PasswordScreen extends React.Component {
authorized, errorMsg, inputVal,
} = this.state;
const {
viewPortId, preview, spaceName, environment, baseUrl, title,
viewPortId, preview, spaceName, environment, baseUrl, title, btnText, content,
} = this.props;
return authorized ? (
<Viewport
Expand All @@ -62,11 +64,24 @@ export default class PasswordScreen extends React.Component {
onChange={val => this.onPasswordInput(val)}
errorMsg={errorMsg}
required
type="password"
onEnterKey={this.onSubmit}
/>
<div styleName="cta">
<button type="button" styleName="submit" onClick={this.onSubmit} disabled={!inputVal}>SUBMIT</button>
<button type="button" styleName="submit" onClick={this.onSubmit} disabled={!inputVal}>{btnText}</button>
</div>
</div>
{
content ? (
<Viewport
id={content.sys.id}
preview={preview}
spaceName={spaceName}
environment={environment}
baseUrl={baseUrl}
/>
) : null
}
</div>
);
}
Expand All @@ -78,6 +93,8 @@ PasswordScreen.defaultProps = {
environment: null,
baseUrl: '',
title: 'GET ACCESS WITH PASSWORD',
btnText: 'SUBMIT',
content: null,
};

PasswordScreen.propTypes = {
Expand All @@ -88,4 +105,6 @@ PasswordScreen.propTypes = {
environment: PT.string,
baseUrl: PT.string,
title: PT.string,
btnText: PT.string,
content: PT.shape(),
};
2 changes: 2 additions & 0 deletions src/shared/components/Contentful/Route.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ function ChildRoutesLoader(props) {
environment={environment}
baseUrl={url}
title={fields.passwordScreenTitle}
btnText={fields.passwordScreenButtonText}
content={fields.passwordScreenContent}
/>
)
) : <Error404 />
Expand Down
13 changes: 12 additions & 1 deletion src/shared/components/GUIKit/TextInput/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ function TextInput({
onChange,
required,
size,
type,
onEnterKey,
}) {
const [val, setVal] = useState(value);
const delayedOnChange = useRef(
Expand All @@ -28,7 +30,7 @@ function TextInput({
<div className="textInputContainer" styleName={`container ${sizeStyle}`}>
<input
defaultValue={value}
type="text"
type={type}
placeholder={`${placeholder}${placeholder && required ? ' *' : ''}`}
styleName={`${value || val ? 'haveValue' : ''} ${errorMsg ? 'haveError' : ''}`}
onChange={(e) => {
Expand All @@ -39,6 +41,11 @@ function TextInput({
delayedOnChange(e.target.value, onChange);
setVal(e.target.value);
}}
onKeyPress={(e) => {
if (e.key === 'Enter') {
onEnterKey();
}
}}
/>
{label ? (
<label htmlFor="textBoxInput">
Expand All @@ -58,6 +65,8 @@ TextInput.defaultProps = {
onChange: () => {},
required: false,
size: 'lg',
type: 'text',
onEnterKey: () => {},
};

TextInput.propTypes = {
Expand All @@ -68,6 +77,8 @@ TextInput.propTypes = {
onChange: PT.func,
required: PT.bool,
size: PT.oneOf(['xs', 'lg']),
type: PT.string,
onEnterKey: PT.func,
};

export default TextInput;