[Update] Config Page: Translation Tab: DeeplAuthKey. Add disable and loading ui when it's pending status.

This commit is contained in:
Sakamoto Shiina
2024-12-07 05:28:13 +09:00
parent 9c5625ac85
commit c65bb4578c
6 changed files with 36 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
import clsx from "clsx";
import React, { useRef, forwardRef, useImperativeHandle } from "react"; import React, { useRef, forwardRef, useImperativeHandle } from "react";
import styles from "./_Entry.module.scss"; import styles from "./_Entry.module.scss";
@@ -9,6 +10,9 @@ const _Entry = forwardRef((props, ref) => {
inputRef.current.focus(); inputRef.current.focus();
} }
})); }));
const input_class_names = clsx(styles.entry_input_area, {
[styles.is_disabled]: props.is_disabled
});
return ( return (
<div className={styles.entry_container}> <div className={styles.entry_container}>
@@ -18,7 +22,7 @@ const _Entry = forwardRef((props, ref) => {
> >
<input <input
ref={inputRef} ref={inputRef}
className={styles.entry_input_area} className={input_class_names}
value={props.ui_variable === null ? "" : props.ui_variable} value={props.ui_variable === null ? "" : props.ui_variable}
onChange={(e) => props.onChange(e)} onChange={(e) => props.onChange(e)}
/> />

View File

@@ -16,4 +16,9 @@
height: 100%; height: 100%;
font-size: 1.4rem; font-size: 1.4rem;
resize: none; resize: none;
color: var(--dark_basic_text_color);
&.is_disabled {
color: var(--dark_500_color);
pointer-events: none;
}
} }

View File

@@ -1,6 +1,7 @@
import styles from "./DeeplAuthKey.module.scss"; import styles from "./DeeplAuthKey.module.scss";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import clsx from "clsx"; import clsx from "clsx";
import CircularProgress from "@mui/material/CircularProgress";
import ExternalLink from "@images/external_link.svg?react"; import ExternalLink from "@images/external_link.svg?react";
import { _Entry } from "../_atoms/_entry/_Entry"; import { _Entry } from "../_atoms/_entry/_Entry";
import { useState, useRef } from "react"; import { useState, useRef } from "react";
@@ -29,11 +30,22 @@ export const DeeplAuthKey = (props) => {
} }
}, [props.variable]); }, [props.variable]);
const is_disabled = props.state === "pending";
const save_button_class_names = clsx(styles.save_button, {
[styles.is_disabled]: is_disabled
});
return ( return (
<div className={styles.container}> <div className={styles.container}>
<div className={styles.entry_section_wrapper}> <div className={styles.entry_section_wrapper}>
<_Entry ref={entryRef} width="30rem" onChange={onchangeEntryAuthKey} ui_variable={props.variable}/> <_Entry ref={entryRef} width="30rem" onChange={onchangeEntryAuthKey} ui_variable={props.variable} is_disabled={is_disabled}/>
<button className={styles.save_button} onClick={saveAuthKey}>Save</button> <button className={save_button_class_names} onClick={saveAuthKey}>
{is_disabled
? <CircularProgress size="1.4rem" sx={{ color: "var(--dark_basic_text_color)" }}/>
: <p className={styles.save_button_label}>Save</p>
}
</button>
{is_editable {is_editable
? null ? null
: :

View File

@@ -44,17 +44,25 @@
.save_button { .save_button {
padding: 0.8rem 1.2rem; padding: 0.8rem 1.2rem;
background-color: var(--primary_600_color); background-color: var(--primary_600_color);
color: var(--dark_basic_text_color);
font-size: 1.4rem;
border-radius: 0.4rem; border-radius: 0.4rem;
text-align: center; text-align: center;
flex-shrink: 0; flex-shrink: 0;
min-width: 5.4rem;
&:hover { &:hover {
background-color: var(--primary_500_color); background-color: var(--primary_500_color);
} }
&:active { &:active {
background-color: var(--primary_700_color); background-color: var(--primary_700_color);
} }
&.is_disabled {
pointer-events: none;
background-color: var(--primary_800_color);
}
}
.save_button_label {
color: var(--dark_basic_text_color);
font-size: 1.4rem;
} }
.open_webpage_button_wrapper { .open_webpage_button_wrapper {

View File

@@ -1,4 +1,5 @@
.container { .container {
} }
.entry_wrapper { .entry_wrapper {

View File

@@ -124,6 +124,7 @@ const DeeplAuthKey_Box = () => {
{translator: t("main_page.translator")} {translator: t("main_page.translator")}
)} )}
variable={input_value} variable={input_value}
state={currentDeepLAuthKey.state}
onChangeFunction={onChangeFunction} onChangeFunction={onChangeFunction}
saveFunction={saveFunction} saveFunction={saveFunction}
/> />