aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/basicAuth/Component.js
diff options
context:
space:
mode:
authorLibravatar muhamedsalih-tw <104364298+muhamedsalih-tw@users.noreply.github.com>2022-11-02 06:31:36 +0530
committerLibravatar GitHub <noreply@github.com>2022-11-02 01:01:36 +0000
commit302d595f7c289387e53a0ef7df4d574ed4e25d70 (patch)
tree2385e59eaca9c78921d9b0b3681cfba1b3eef168 /src/features/basicAuth/Component.js
parentRe-enable editing of the address bar to manually access a different url withi... (diff)
downloadferdium-app-302d595f7c289387e53a0ef7df4d574ed4e25d70.tar.gz
ferdium-app-302d595f7c289387e53a0ef7df4d574ed4e25d70.tar.zst
ferdium-app-302d595f7c289387e53a0ef7df4d574ed4e25d70.zip
Transform to TS and refactored components w.r.t deletion if duplicated Input component (#729)
Diffstat (limited to 'src/features/basicAuth/Component.js')
-rw-r--r--src/features/basicAuth/Component.js101
1 files changed, 0 insertions, 101 deletions
diff --git a/src/features/basicAuth/Component.js b/src/features/basicAuth/Component.js
deleted file mode 100644
index acba5a90d..000000000
--- a/src/features/basicAuth/Component.js
+++ /dev/null
@@ -1,101 +0,0 @@
1import { Component } from 'react';
2import PropTypes from 'prop-types';
3import injectSheet from 'react-jss';
4import { observer } from 'mobx-react';
5import { defineMessages, injectIntl } from 'react-intl';
6import classnames from 'classnames';
7
8import Modal from '../../components/ui/Modal';
9import Input from '../../components/ui/Input';
10import Button from '../../components/ui/button';
11
12import { state, resetState, sendCredentials, cancelLogin } from './store';
13import Form from './Form';
14
15import styles from './styles';
16import globalMessages from '../../i18n/globalMessages';
17import { H1 } from '../../components/ui/headline';
18
19const messages = defineMessages({
20 signIn: {
21 id: 'feature.basicAuth.signIn',
22 defaultMessage: 'Sign In',
23 },
24});
25
26class BasicAuthModal extends Component {
27 static propTypes = {
28 classes: PropTypes.object.isRequired,
29 };
30
31 submit(e) {
32 e.preventDefault();
33
34 const values = Form.values();
35
36 sendCredentials(values.user, values.password);
37 resetState();
38 }
39
40 cancel() {
41 cancelLogin();
42 this.close();
43 }
44
45 close() {
46 resetState();
47 state.isModalVisible = false;
48 }
49
50 render() {
51 const { classes } = this.props;
52
53 const { isModalVisible, authInfo } = state;
54
55 if (!authInfo) {
56 return null;
57 }
58
59 const { intl } = this.props;
60
61 return (
62 <Modal
63 isOpen={isModalVisible}
64 className={classes.modal}
65 close={this.cancel.bind(this)}
66 showClose={false}
67 >
68 <H1>{intl.formatMessage(messages.signIn)}</H1>
69 <p>
70 http
71 {authInfo.port === 443 && 's'}
72 ://
73 {authInfo.host}
74 </p>
75 <form
76 onSubmit={this.submit.bind(this)}
77 className={classnames('franz-form', classes.form)}
78 >
79 <Input field={Form.$('user')} showLabel={false} />
80 <Input
81 field={Form.$('password')}
82 showLabel={false}
83 showPasswordToggle
84 />
85 <div className={classes.buttons}>
86 <Button
87 type="button"
88 label={intl.formatMessage(globalMessages.cancel)}
89 buttonType="secondary"
90 onClick={this.cancel.bind(this)}
91 />
92 <Button type="submit" label={intl.formatMessage(messages.signIn)} />
93 </div>
94 </form>
95 </Modal>
96 );
97 }
98}
99export default injectIntl(
100 injectSheet(styles, { injectTheme: true })(observer(BasicAuthModal)),
101);