~emersion/public-inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH gamja v2] Add "auth" parameter to tune connect form

Details
Message ID
<20210610154059.21183-1-sir@cmpwn.com>
DKIM signature
pass
Download raw message
Patch: +34 -6
---
 README.md                  |  5 +++++
 components/app.js          | 11 ++++++++++-
 components/connect-form.js | 24 +++++++++++++++++++-----
 3 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md
index 7100e46..862d228 100644
--- a/README.md
+++ b/README.md
@@ -85,6 +85,11 @@ gamja default settings can be set using a `config.json` file at the root:
		"url": "wss://irc.example.org",
		// Channel(s) to auto-join (string or array of strings).
		"autojoin": "#gamja",
		// Controls how the password UI is presented to the user. Set to
		// "mandatory" to require a password, "optional" to accept one but not
		// require it, and "disabled" to never ask for a password. Defaults to
		// "optional".
		"auth": "optional",
		// Interval in seconds to send PING commands (number). Set to 0 to
		// disable. Enabling PINGs can have an impact on client power usage and
		// should only be enabled if necessary.
diff --git a/components/app.js b/components/app.js
index 920cb90..343c7e4 100644
--- a/components/app.js
+++ b/components/app.js
@@ -99,6 +99,7 @@ export default class App extends Component {
			saslPlain: null,
			autoconnect: false,
			autojoin: [],
			auth: "optional",
		},
		servers: new Map(),
		buffers: new Map(),
@@ -173,6 +174,9 @@ export default class App extends Component {
			} else {
				connectParams.autojoin = [config.server.autojoin];
			}
			if (typeof config.server.auth !== "undefined") {
				connectParams.auth = config.server.auth;
			}
		}

		var autoconnect = store.autoconnect.load();
@@ -200,7 +204,12 @@ export default class App extends Component {
		}

		this.setState((state) => {
			return { connectParams: { ...state.connectParams, ...connectParams } };
			return {
				connectParams: {
					...state.connectParams,
					...connectParams,
				},
			};
		});

		if (connectParams.autoconnect) {
diff --git a/components/connect-form.js b/components/connect-form.js
index 4deb947..312f894 100644
--- a/components/connect-form.js
+++ b/components/connect-form.js
@@ -98,6 +98,24 @@ export default class ConnectForm extends Component {
			`;
		}

		let auth = html`
		<label>
			Password:<br/>
			<input
				type="password"
				name="password"
				value=${this.state.password}
				disabled=${disabled}
				required=${this.props.params.auth === "mandatory"}
				placeholder=${this.props.params.auth === "optional" ? "(optional)" : ""}
			/>
		</label>
		<br/><br/>
		`;
		if (this.props.params.auth === "disabled") {
			auth = "";
		}

		return html`
			<form onChange=${this.handleChange} onSubmit=${this.handleSubmit}>
				<h2>Connect to IRC</h2>
@@ -108,11 +126,7 @@ export default class ConnectForm extends Component {
				</label>
				<br/><br/>

				<label>
					Password:<br/>
					<input type="password" name="password" value=${this.state.password} disabled=${disabled}/>
				</label>
				<br/><br/>
				${auth}

				<label>
					<input type="checkbox" name="rememberMe" checked=${this.state.rememberMe} disabled=${disabled}/>
-- 
2.32.0
Details
Message ID
<DBHtuCtGcRZnxHkol24kQy3XltzTtZ_GyIfmN0JF8r1s_o-tWCI0gljVjaWZ9vZ-o8gafwbghOELkiwm8mzthENbnEkP0pM-JYFjAj8Zp5g=@emersion.fr>
In-Reply-To
<20210610154059.21183-1-sir@cmpwn.com> (view parent)
DKIM signature
pass
Download raw message
Moved "auth" to a standalone ConnectForm param instead of a member of
connectParam. LGTM otherwise.

Pushed, thanks!
Reply to thread Export thread (mbox)