Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3399708
D12054.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D12054.diff
View Options
diff --git a/web/modals/keyserver-selection/add-keyserver-modal.react.js b/web/modals/keyserver-selection/add-keyserver-modal.react.js
--- a/web/modals/keyserver-selection/add-keyserver-modal.react.js
+++ b/web/modals/keyserver-selection/add-keyserver-modal.react.js
@@ -16,6 +16,14 @@
import Input from '../input.react.js';
import Modal from '../modal.react.js';
+type KeyserverCheckStatus =
+ | { +status: 'inactive' }
+ | { +status: 'loading' }
+ | { +status: 'error' };
+const keyserverCheckStatusInactive = { status: 'inactive' };
+const keyserverCheckStatusLoading = { status: 'loading' };
+const keyserverCheckStatusError = { status: 'error' };
+
function AddKeyserverModal(): React.Node {
const { popModal } = useModalContext();
@@ -29,8 +37,9 @@
const [keyserverURL, setKeyserverURL] = React.useState<string>(
customServer && staffCanSee ? customServer : '',
);
- const [showErrorMessage, setShowErrorMessage] =
- React.useState<boolean>(false);
+ const [status, setStatus] = React.useState<KeyserverCheckStatus>(
+ keyserverCheckStatusInactive,
+ );
const onChangeKeyserverURL = React.useCallback(
(event: SyntheticEvent<HTMLInputElement>) =>
@@ -41,16 +50,17 @@
const isKeyserverURLValidCallback = useIsKeyserverURLValid(keyserverURL);
const onClickAddKeyserver = React.useCallback(async () => {
- setShowErrorMessage(false);
if (!currentUserID || !keyserverURL) {
return;
}
+ setStatus(keyserverCheckStatusLoading);
const keyserverVersionData = await isKeyserverURLValidCallback();
if (!keyserverVersionData) {
- setShowErrorMessage(true);
+ setStatus(keyserverCheckStatusError);
return;
}
+ setStatus(keyserverCheckStatusInactive);
const newKeyserverInfo: KeyserverInfo = defaultKeyserverInfo(keyserverURL);
@@ -71,6 +81,7 @@
isKeyserverURLValidCallback,
]);
+ const showErrorMessage = status.status === 'error';
const errorMessage = React.useMemo(() => {
let errorText;
if (showErrorMessage) {
@@ -81,6 +92,7 @@
return <div className={css.errorMessage}>{errorText}</div>;
}, [showErrorMessage]);
+ const buttonDisabled = !keyserverURL || status.status === 'loading';
const addKeyserverButton = React.useMemo(
() => (
<Button
@@ -88,12 +100,12 @@
buttonColor={buttonThemes.primary}
className={css.button}
onClick={onClickAddKeyserver}
- disabled={!keyserverURL}
+ disabled={buttonDisabled}
>
Add keyserver
</Button>
),
- [keyserverURL, onClickAddKeyserver],
+ [buttonDisabled, onClickAddKeyserver],
);
const addKeyserverModal = React.useMemo(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 3, 4:27 AM (21 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2610208
Default Alt Text
D12054.diff (2 KB)
Attached To
Mode
D12054: [web] Disable AddKeyserverModal button while keyserver check is in progress
Attached
Detach File
Event Timeline
Log In to Comment