Skip to content

Commit f2bdeb6

Browse files
Merge pull request #5184 from topcoder-platform/pass-screen-updates
Pass screen updates
2 parents 12d27f6 + c833dcc commit f2bdeb6

File tree

5 files changed

+41
-8
lines changed

5 files changed

+41
-8
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ workflows:
259259
filters:
260260
branches:
261261
only:
262-
- develop
262+
- pass-screen-updates
263263
# Production builds are exectuted
264264
# when PR is merged to the master
265265
# Don't change anything in this configuration

__tests__/shared/components/GUIKit/TextInput/__snapshots__/index.jsx.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ exports[`Default render 1`] = `
99
defaultValue=""
1010
onBlur={[Function]}
1111
onChange={[Function]}
12+
onKeyPress={[Function]}
1213
placeholder=""
1314
type="text"
1415
/>

src/shared/components/Contentful/PasswordScreen/index.jsx

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ export default class PasswordScreen extends React.Component {
2121

2222
onSubmit() {
2323
const { password } = this.props;
24-
const { inputVal } = this.state;
25-
this.setState({
26-
authorized: password === inputVal,
27-
errorMsg: password === inputVal ? '' : 'Password incorrect',
24+
this.setState((state) => {
25+
const { inputVal } = state;
26+
return {
27+
authorized: password === inputVal,
28+
errorMsg: password === inputVal ? '' : 'Password incorrect',
29+
};
2830
});
2931
}
3032

@@ -41,7 +43,7 @@ export default class PasswordScreen extends React.Component {
4143
authorized, errorMsg, inputVal,
4244
} = this.state;
4345
const {
44-
viewPortId, preview, spaceName, environment, baseUrl, title,
46+
viewPortId, preview, spaceName, environment, baseUrl, title, btnText, content,
4547
} = this.props;
4648
return authorized ? (
4749
<Viewport
@@ -62,11 +64,24 @@ export default class PasswordScreen extends React.Component {
6264
onChange={val => this.onPasswordInput(val)}
6365
errorMsg={errorMsg}
6466
required
67+
type="password"
68+
onEnterKey={this.onSubmit}
6569
/>
6670
<div styleName="cta">
67-
<button type="button" styleName="submit" onClick={this.onSubmit} disabled={!inputVal}>SUBMIT</button>
71+
<button type="button" styleName="submit" onClick={this.onSubmit} disabled={!inputVal}>{btnText}</button>
6872
</div>
6973
</div>
74+
{
75+
content ? (
76+
<Viewport
77+
id={content.sys.id}
78+
preview={preview}
79+
spaceName={spaceName}
80+
environment={environment}
81+
baseUrl={baseUrl}
82+
/>
83+
) : null
84+
}
7085
</div>
7186
);
7287
}
@@ -78,6 +93,8 @@ PasswordScreen.defaultProps = {
7893
environment: null,
7994
baseUrl: '',
8095
title: 'GET ACCESS WITH PASSWORD',
96+
btnText: 'SUBMIT',
97+
content: null,
8198
};
8299

83100
PasswordScreen.propTypes = {
@@ -88,4 +105,6 @@ PasswordScreen.propTypes = {
88105
environment: PT.string,
89106
baseUrl: PT.string,
90107
title: PT.string,
108+
btnText: PT.string,
109+
content: PT.shape(),
91110
};

src/shared/components/Contentful/Route.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ function ChildRoutesLoader(props) {
7171
environment={environment}
7272
baseUrl={url}
7373
title={fields.passwordScreenTitle}
74+
btnText={fields.passwordScreenButtonText}
75+
content={fields.passwordScreenContent}
7476
/>
7577
)
7678
) : <Error404 />

src/shared/components/GUIKit/TextInput/index.jsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ function TextInput({
1717
onChange,
1818
required,
1919
size,
20+
type,
21+
onEnterKey,
2022
}) {
2123
const [val, setVal] = useState(value);
2224
const delayedOnChange = useRef(
@@ -28,7 +30,7 @@ function TextInput({
2830
<div className="textInputContainer" styleName={`container ${sizeStyle}`}>
2931
<input
3032
defaultValue={value}
31-
type="text"
33+
type={type}
3234
placeholder={`${placeholder}${placeholder && required ? ' *' : ''}`}
3335
styleName={`${value || val ? 'haveValue' : ''} ${errorMsg ? 'haveError' : ''}`}
3436
onChange={(e) => {
@@ -39,6 +41,11 @@ function TextInput({
3941
delayedOnChange(e.target.value, onChange);
4042
setVal(e.target.value);
4143
}}
44+
onKeyPress={(e) => {
45+
if (e.key === 'Enter') {
46+
onEnterKey();
47+
}
48+
}}
4249
/>
4350
{label ? (
4451
<label htmlFor="textBoxInput">
@@ -58,6 +65,8 @@ TextInput.defaultProps = {
5865
onChange: () => {},
5966
required: false,
6067
size: 'lg',
68+
type: 'text',
69+
onEnterKey: () => {},
6170
};
6271

6372
TextInput.propTypes = {
@@ -68,6 +77,8 @@ TextInput.propTypes = {
6877
onChange: PT.func,
6978
required: PT.bool,
7079
size: PT.oneOf(['xs', 'lg']),
80+
type: PT.string,
81+
onEnterKey: PT.func,
7182
};
7283

7384
export default TextInput;

0 commit comments

Comments
 (0)