Skip to content

Commit 1761583

Browse files
committed
update: upgrade to the newest version of antd, which is a good step in preparation for React 18.
1 parent 9b09c85 commit 1761583

File tree

8 files changed

+536
-449
lines changed

8 files changed

+536
-449
lines changed

src/packages/frontend/admin/site-settings.tsx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,7 @@ import { isEqual } from "lodash";
4242

4343
import { COLORS } from "@cocalc/util/theme";
4444

45-
// Commented out since Select via antd is broken now,
46-
// at least when used here...
47-
// import { Select } from "antd";
48-
// const { Option } = Select;
49-
import { Input } from "antd";
45+
import { Input, InputRef } from "antd";
5046

5147
import {
5248
CopyToClipBoard,
@@ -78,10 +74,13 @@ class SiteSettingsComponent extends Component<
7874
SiteSettingsProps,
7975
SiteSettingsState
8076
> {
77+
private testEmailRef: React.RefObject<InputRef>;
78+
8179
constructor(props, state) {
8280
super(props, state);
8381
this.on_json_entry_change = this.on_json_entry_change.bind(this);
8482
this.on_change_entry = this.on_change_entry.bind(this);
83+
this.testEmailRef = React.createRef();
8584
this.state = { state: "view", disable_tests: false };
8685
}
8786

@@ -571,9 +570,18 @@ class SiteSettingsComponent extends Component<
571570
private async send_test_email(
572571
type: "password_reset" | "invite_email" | "mention" | "verification"
573572
): Promise<void> {
574-
const email = ReactDOM.findDOMNode(this.refs.test_email)?.value;
575-
if (email == null) return;
576-
console.log(`sending test email "${type}" to ${email}`);
573+
const email = this.testEmailRef.current?.input?.value;
574+
if (!email) {
575+
alert_message({
576+
type: "error",
577+
message: "NOT sending test email, since email field is empty",
578+
});
579+
return;
580+
}
581+
alert_message({
582+
type: "info",
583+
message: `sending test email "${type}" to ${email}`,
584+
});
577585
// saving info
578586
await this.store();
579587
this.setState({ disable_tests: true });
@@ -622,14 +630,15 @@ class SiteSettingsComponent extends Component<
622630
<Input
623631
style={{ width: "auto" }}
624632
defaultValue={this.props.email_address}
625-
ref={"test_email"}
633+
ref={this.testEmailRef}
626634
/>
627635
<Button
636+
style={{ marginLeft: "10px" }}
628637
bsSize={"small"}
629638
disabled={this.state.disable_tests}
630639
onClick={() => this.send_test_email("password_reset")}
631640
>
632-
Forgot Password
641+
Send Test Forgot Password Email
633642
</Button>
634643
{
635644
// <Button

src/packages/frontend/components/number-input.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export class NumberInput extends React.Component<Props, State> {
5858
<Col xs={16}>
5959
<Input
6060
type="text"
61-
ref="input"
6261
value={
6362
this.state.number != undefined
6463
? this.state.number

src/packages/frontend/components/search-input.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99
- `esc` to clear
1010
*/
1111

12-
import { Input } from "antd";
12+
import { Input, InputRef } from "antd";
1313
import { Button } from "../antd-bootstrap";
14-
//import { , FormGroup, InputGroup, FormControl } from "../antd-bootstrap";
1514
import { Icon } from "./icon";
16-
import { React, ReactDOM, useEffect, useState, useRef } from "../app-framework";
15+
import { React, useEffect, useState, useRef } from "../app-framework";
1716

1817
interface Props {
1918
default_value?: string;
@@ -44,20 +43,18 @@ export const SearchInput: React.FC<Props> = React.memo((props) => {
4443

4544
const [ctrl_down, set_ctrl_down] = useState<boolean>(false);
4645

47-
const input_ref = useRef(null);
46+
const input_ref = useRef<InputRef>(null);
4847

4948
useEffect(() => {
5049
if (props.autoSelect && input_ref.current) {
5150
try {
52-
ReactDOM.findDOMNode(input_ref.current).select();
51+
input_ref.current?.select();
5352
} catch (_) {}
5453
}
5554
}, []);
5655

5756
useEffect(() => {
58-
if (input_ref.current) {
59-
ReactDOM.findDOMNode(input_ref.current).focus();
60-
}
57+
input_ref.current?.focus();
6158
}, [focus]);
6259

6360
function get_opts(): { ctrl_down: boolean } {
@@ -72,7 +69,7 @@ export const SearchInput: React.FC<Props> = React.memo((props) => {
7269

7370
function clear_and_focus_search_input(): void {
7471
clear_value();
75-
ReactDOM.findDOMNode(input_ref.current)?.focus();
72+
input_ref.current?.focus();
7673
}
7774

7875
function search_button(): JSX.Element {

0 commit comments

Comments
 (0)