diff options
author | Vijay A <vraravam@users.noreply.github.com> | 2022-05-14 14:51:08 -0500 |
---|---|---|
committer | Vijay A <vraravam@users.noreply.github.com> | 2022-05-14 14:51:08 -0500 |
commit | 85cb50a20b8f3d7b0c3599fe6baa1d3e3040f0ae (patch) | |
tree | 201f63fd866b1a3e301699661a9383f53a43e65e /src/components/auth | |
parent | Added TODOs for tech debt (diff) | |
download | ferdium-app-85cb50a20b8f3d7b0c3599fe6baa1d3e3040f0ae.tar.gz ferdium-app-85cb50a20b8f3d7b0c3599fe6baa1d3e3040f0ae.tar.zst ferdium-app-85cb50a20b8f3d7b0c3599fe6baa1d3e3040f0ae.zip |
Minor refactoring for aligning on usage of 'intl' package
Diffstat (limited to 'src/components/auth')
-rw-r--r-- | src/components/auth/ChangeServer.js | 12 | ||||
-rw-r--r-- | src/components/auth/Invite.js | 13 | ||||
-rw-r--r-- | src/components/auth/Locked.js | 11 | ||||
-rw-r--r-- | src/components/auth/Login.js | 13 | ||||
-rw-r--r-- | src/components/auth/Password.js | 11 | ||||
-rw-r--r-- | src/components/auth/Signup.js | 17 |
6 files changed, 42 insertions, 35 deletions
diff --git a/src/components/auth/ChangeServer.js b/src/components/auth/ChangeServer.js index aa4598928..a7aa33ab1 100644 --- a/src/components/auth/ChangeServer.js +++ b/src/components/auth/ChangeServer.js | |||
@@ -50,11 +50,12 @@ class ChangeServer extends Component { | |||
50 | 50 | ||
51 | defaultServers = [this.ferdiumServer, this.franzServer, this.ferdiServer]; | 51 | defaultServers = [this.ferdiumServer, this.franzServer, this.ferdiServer]; |
52 | 52 | ||
53 | form = new Form( | 53 | form = (() => { |
54 | { | 54 | const { intl } = this.props; |
55 | return new Form({ | ||
55 | fields: { | 56 | fields: { |
56 | server: { | 57 | server: { |
57 | label: this.props.intl.formatMessage(messages.label), | 58 | label: intl.formatMessage(messages.label), |
58 | value: this.props.server, | 59 | value: this.props.server, |
59 | options: [ | 60 | options: [ |
60 | { value: this.ferdiumServer, label: 'Ferdium (Default)' }, | 61 | { value: this.ferdiumServer, label: 'Ferdium (Default)' }, |
@@ -69,14 +70,15 @@ class ChangeServer extends Component { | |||
69 | ], | 70 | ], |
70 | }, | 71 | }, |
71 | customServer: { | 72 | customServer: { |
72 | label: this.props.intl.formatMessage(messages.customServerLabel), | 73 | label: intl.formatMessage(messages.customServerLabel), |
73 | value: '', | 74 | value: '', |
74 | validators: [url, required], | 75 | validators: [url, required], |
75 | }, | 76 | }, |
76 | }, | 77 | }, |
77 | }, | 78 | }, |
78 | this.props.intl, | 79 | intl, |
79 | ); | 80 | ); |
81 | })(); | ||
80 | 82 | ||
81 | componentDidMount() { | 83 | componentDidMount() { |
82 | if (this.defaultServers.includes(this.props.server)) { | 84 | if (this.defaultServers.includes(this.props.server)) { |
diff --git a/src/components/auth/Invite.js b/src/components/auth/Invite.js index 81618b3bd..84adb320f 100644 --- a/src/components/auth/Invite.js +++ b/src/components/auth/Invite.js | |||
@@ -61,6 +61,7 @@ class Invite extends Component { | |||
61 | state = { showSuccessInfo: false }; | 61 | state = { showSuccessInfo: false }; |
62 | 62 | ||
63 | componentDidMount() { | 63 | componentDidMount() { |
64 | const { intl } = this.props; | ||
64 | this.form = new Form( | 65 | this.form = new Form( |
65 | { | 66 | { |
66 | fields: { | 67 | fields: { |
@@ -68,8 +69,8 @@ class Invite extends Component { | |||
68 | ...Array.from({ length: 3 }).fill({ | 69 | ...Array.from({ length: 3 }).fill({ |
69 | fields: { | 70 | fields: { |
70 | name: { | 71 | name: { |
71 | label: this.props.intl.formatMessage(messages.nameLabel), | 72 | label: intl.formatMessage(messages.nameLabel), |
72 | placeholder: this.props.intl.formatMessage( | 73 | placeholder: intl.formatMessage( |
73 | messages.nameLabel, | 74 | messages.nameLabel, |
74 | ), | 75 | ), |
75 | onChange: () => { | 76 | onChange: () => { |
@@ -78,8 +79,8 @@ class Invite extends Component { | |||
78 | // related: ['invite.0.email'], // path accepted but does not work | 79 | // related: ['invite.0.email'], // path accepted but does not work |
79 | }, | 80 | }, |
80 | email: { | 81 | email: { |
81 | label: this.props.intl.formatMessage(messages.emailLabel), | 82 | label: intl.formatMessage(messages.emailLabel), |
82 | placeholder: this.props.intl.formatMessage( | 83 | placeholder: intl.formatMessage( |
83 | messages.emailLabel, | 84 | messages.emailLabel, |
84 | ), | 85 | ), |
85 | onChange: () => { | 86 | onChange: () => { |
@@ -92,7 +93,7 @@ class Invite extends Component { | |||
92 | ], | 93 | ], |
93 | }, | 94 | }, |
94 | }, | 95 | }, |
95 | this.props.intl, | 96 | intl, |
96 | ); | 97 | ); |
97 | 98 | ||
98 | document.querySelector('input:first-child')?.focus(); | 99 | document.querySelector('input:first-child')?.focus(); |
@@ -185,7 +186,7 @@ class Invite extends Component { | |||
185 | > | 186 | > |
186 | {embed && ( | 187 | {embed && ( |
187 | <div className="settings__header"> | 188 | <div className="settings__header"> |
188 | <H1>{this.props.intl.formatMessage(messages.settingsHeadline)}</H1> | 189 | <H1>{intl.formatMessage(messages.settingsHeadline)}</H1> |
189 | </div> | 190 | </div> |
190 | )} | 191 | )} |
191 | {!embed ? ( | 192 | {!embed ? ( |
diff --git a/src/components/auth/Locked.js b/src/components/auth/Locked.js index e09a7d540..710810f2b 100644 --- a/src/components/auth/Locked.js +++ b/src/components/auth/Locked.js | |||
@@ -52,18 +52,19 @@ class Locked extends Component { | |||
52 | error: globalErrorPropType.isRequired, | 52 | error: globalErrorPropType.isRequired, |
53 | }; | 53 | }; |
54 | 54 | ||
55 | form = new Form( | 55 | form = (() => { |
56 | { | 56 | const { intl } = this.props; |
57 | return new Form({ | ||
57 | fields: { | 58 | fields: { |
58 | password: { | 59 | password: { |
59 | label: this.props.intl.formatMessage(messages.passwordLabel), | 60 | label: intl.formatMessage(messages.passwordLabel), |
60 | value: '', | 61 | value: '', |
61 | type: 'password', | 62 | type: 'password', |
62 | }, | 63 | }, |
63 | }, | 64 | }, |
64 | }, | 65 | }, |
65 | this.props.intl, | 66 | intl, |
66 | ); | 67 | )})(); |
67 | 68 | ||
68 | submit(e) { | 69 | submit(e) { |
69 | e.preventDefault(); | 70 | e.preventDefault(); |
diff --git a/src/components/auth/Login.js b/src/components/auth/Login.js index d6c9e6feb..f1c58a020 100644 --- a/src/components/auth/Login.js +++ b/src/components/auth/Login.js | |||
@@ -73,24 +73,25 @@ class Login extends Component { | |||
73 | error: globalErrorPropType.isRequired, | 73 | error: globalErrorPropType.isRequired, |
74 | }; | 74 | }; |
75 | 75 | ||
76 | form = new Form( | 76 | form = (() => { |
77 | { | 77 | const { intl } = this.props; |
78 | return new Form({ | ||
78 | fields: { | 79 | fields: { |
79 | email: { | 80 | email: { |
80 | label: this.props.intl.formatMessage(messages.emailLabel), | 81 | label: intl.formatMessage(messages.emailLabel), |
81 | value: '', | 82 | value: '', |
82 | validators: [required, email], | 83 | validators: [required, email], |
83 | }, | 84 | }, |
84 | password: { | 85 | password: { |
85 | label: this.props.intl.formatMessage(messages.passwordLabel), | 86 | label: intl.formatMessage(messages.passwordLabel), |
86 | value: '', | 87 | value: '', |
87 | validators: [required], | 88 | validators: [required], |
88 | type: 'password', | 89 | type: 'password', |
89 | }, | 90 | }, |
90 | }, | 91 | }, |
91 | }, | 92 | }, |
92 | this.props.intl, | 93 | intl, |
93 | ); | 94 | )})(); |
94 | 95 | ||
95 | submit(e) { | 96 | submit(e) { |
96 | e.preventDefault(); | 97 | e.preventDefault(); |
diff --git a/src/components/auth/Password.js b/src/components/auth/Password.js index 8a5ef28f3..0e87cb028 100644 --- a/src/components/auth/Password.js +++ b/src/components/auth/Password.js | |||
@@ -48,18 +48,19 @@ class Password extends Component { | |||
48 | status: MobxPropTypes.arrayOrObservableArray.isRequired, | 48 | status: MobxPropTypes.arrayOrObservableArray.isRequired, |
49 | }; | 49 | }; |
50 | 50 | ||
51 | form = new Form( | 51 | form = (() => { |
52 | { | 52 | const { intl } = this.props; |
53 | return new Form({ | ||
53 | fields: { | 54 | fields: { |
54 | email: { | 55 | email: { |
55 | label: this.props.intl.formatMessage(messages.emailLabel), | 56 | label: intl.formatMessage(messages.emailLabel), |
56 | value: '', | 57 | value: '', |
57 | validators: [required, email], | 58 | validators: [required, email], |
58 | }, | 59 | }, |
59 | }, | 60 | }, |
60 | }, | 61 | }, |
61 | this.props.intl, | 62 | intl, |
62 | ); | 63 | )})(); |
63 | 64 | ||
64 | submit(e) { | 65 | submit(e) { |
65 | e.preventDefault(); | 66 | e.preventDefault(); |
diff --git a/src/components/auth/Signup.js b/src/components/auth/Signup.js index 1c7b8e247..930b24491 100644 --- a/src/components/auth/Signup.js +++ b/src/components/auth/Signup.js | |||
@@ -73,34 +73,35 @@ class Signup extends Component { | |||
73 | error: globalErrorPropType.isRequired, | 73 | error: globalErrorPropType.isRequired, |
74 | }; | 74 | }; |
75 | 75 | ||
76 | form = new Form( | 76 | form = (() => { |
77 | { | 77 | const { intl } = this.props; |
78 | return new Form({ | ||
78 | fields: { | 79 | fields: { |
79 | firstname: { | 80 | firstname: { |
80 | label: this.props.intl.formatMessage(messages.firstnameLabel), | 81 | label: intl.formatMessage(messages.firstnameLabel), |
81 | value: '', | 82 | value: '', |
82 | validators: [required], | 83 | validators: [required], |
83 | }, | 84 | }, |
84 | lastname: { | 85 | lastname: { |
85 | label: this.props.intl.formatMessage(messages.lastnameLabel), | 86 | label: intl.formatMessage(messages.lastnameLabel), |
86 | value: '', | 87 | value: '', |
87 | validators: [required], | 88 | validators: [required], |
88 | }, | 89 | }, |
89 | email: { | 90 | email: { |
90 | label: this.props.intl.formatMessage(messages.emailLabel), | 91 | label: intl.formatMessage(messages.emailLabel), |
91 | value: '', | 92 | value: '', |
92 | validators: [required, email], | 93 | validators: [required, email], |
93 | }, | 94 | }, |
94 | password: { | 95 | password: { |
95 | label: this.props.intl.formatMessage(messages.passwordLabel), | 96 | label: intl.formatMessage(messages.passwordLabel), |
96 | value: '', | 97 | value: '', |
97 | validators: [required, minLength(6)], | 98 | validators: [required, minLength(6)], |
98 | type: 'password', | 99 | type: 'password', |
99 | }, | 100 | }, |
100 | }, | 101 | }, |
101 | }, | 102 | }, |
102 | this.props.intl, | 103 | intl, |
103 | ); | 104 | )})(); |
104 | 105 | ||
105 | submit(e) { | 106 | submit(e) { |
106 | e.preventDefault(); | 107 | e.preventDefault(); |