fix(Login): Improve the prompt text for the Login process

This commit is contained in:
haitaoo 2023-04-20 17:51:43 +08:00
parent 2db93af38b
commit 944e773392
11 changed files with 37 additions and 15 deletions

View File

@ -1123,6 +1123,7 @@ ui:
plugins: plugins:
login: Login login: Login
qrcode_login_tip: Please use {{ agentName }} to scan the QR code and log in. qrcode_login_tip: Please use {{ agentName }} to scan the QR code and log in.
login_failed_email_tip: Login failed, please allow this app to access your email information before try again.
oauth: oauth:
connect: Connect with {{ auth_name }} connect: Connect with {{ auth_name }}
remove: Remove {{ auth_name }} remove: Remove {{ auth_name }}

View File

@ -42,7 +42,7 @@ const Index: FC<Props> = ({
type={type} type={type}
value={fieldObject?.value || ''} value={fieldObject?.value || ''}
onChange={handleChange} onChange={handleChange}
readOnly={readOnly} disabled={readOnly}
isInvalid={fieldObject?.isInvalid} isInvalid={fieldObject?.isInvalid}
style={type === 'color' ? { width: '6rem' } : {}} style={type === 'color' ? { width: '6rem' } : {}}
/> />

View File

@ -10,6 +10,7 @@ interface Props {
enumValues: (string | boolean | number)[]; enumValues: (string | boolean | number)[];
enumNames: string[]; enumNames: string[];
formData: Type.FormDataType; formData: Type.FormDataType;
readOnly: boolean;
} }
const Index: FC<Props> = ({ const Index: FC<Props> = ({
desc, desc,
@ -18,6 +19,7 @@ const Index: FC<Props> = ({
enumValues, enumValues,
enumNames, enumNames,
formData, formData,
readOnly = false,
}) => { }) => {
const fieldObject = formData[fieldName]; const fieldObject = formData[fieldName];
const handleChange = (evt: React.ChangeEvent<HTMLSelectElement>) => { const handleChange = (evt: React.ChangeEvent<HTMLSelectElement>) => {
@ -40,6 +42,7 @@ const Index: FC<Props> = ({
name={fieldName} name={fieldName}
value={fieldObject?.value || ''} value={fieldObject?.value || ''}
onChange={handleChange} onChange={handleChange}
disabled={readOnly}
isInvalid={fieldObject?.isInvalid}> isInvalid={fieldObject?.isInvalid}>
{enumValues?.map((item, index) => { {enumValues?.map((item, index) => {
return ( return (

View File

@ -12,6 +12,7 @@ interface Props {
fieldName: string; fieldName: string;
onChange?: (fd: Type.FormDataType) => void; onChange?: (fd: Type.FormDataType) => void;
formData: Type.FormDataType; formData: Type.FormDataType;
readOnly: boolean;
} }
const Index: FC<Props> = ({ const Index: FC<Props> = ({
placeholder = '', placeholder = '',
@ -20,6 +21,7 @@ const Index: FC<Props> = ({
fieldName, fieldName,
onChange, onChange,
formData, formData,
readOnly = false,
}) => { }) => {
const fieldObject = formData[fieldName]; const fieldObject = formData[fieldName];
const handleChange = (evt: React.ChangeEvent<HTMLInputElement>) => { const handleChange = (evt: React.ChangeEvent<HTMLInputElement>) => {
@ -46,6 +48,7 @@ const Index: FC<Props> = ({
onChange={handleChange} onChange={handleChange}
isInvalid={fieldObject?.isInvalid} isInvalid={fieldObject?.isInvalid}
rows={rows} rows={rows}
disabled={readOnly}
className={classnames(className)} className={classnames(className)}
/> />
); );

View File

@ -369,6 +369,7 @@ const SchemaForm: ForwardRefRenderFunction<IRef, IProps> = (
enumValues={enumValues} enumValues={enumValues}
enumNames={enumNames} enumNames={enumNames}
formData={formData} formData={formData}
readOnly={readOnly}
/> />
) : null} ) : null}
{widget === 'radio' || widget === 'checkbox' ? ( {widget === 'radio' || widget === 'checkbox' ? (
@ -420,6 +421,7 @@ const SchemaForm: ForwardRefRenderFunction<IRef, IProps> = (
fieldName={key} fieldName={key}
onChange={onChange} onChange={onChange}
formData={formData} formData={formData}
readOnly={readOnly}
/> />
) : null} ) : null}
{widget === 'input' ? ( {widget === 'input' ? (

View File

@ -1,12 +1,14 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import classnames from 'classnames';
import { uploadImage } from '@/services'; import { uploadImage } from '@/services';
import * as Type from '@/common/interface'; import * as Type from '@/common/interface';
interface IProps { interface IProps {
type: Type.UploadType; type: Type.UploadType;
className?: string; className?: classnames.Argument;
children?: React.ReactNode; children?: React.ReactNode;
acceptType?: string; acceptType?: string;
disabled?: boolean; disabled?: boolean;
@ -49,7 +51,8 @@ const Index: React.FC<IProps> = ({
}; };
return ( return (
<label className={`btn btn-outline-secondary uploadBtn ${className}`}> <label
className={classnames('btn btn-outline-secondary uploadBtn', className)}>
{children || (status ? t('upload_img.loading') : t('upload_img.name'))} {children || (status ? t('upload_img.loading') : t('upload_img.name'))}
<input <input
type="file" type="file"

View File

@ -68,7 +68,7 @@ const Index: FC = () => {
<Card className="text-center"> <Card className="text-center">
<Card.Body> <Card.Body>
<Card.Title as="h3" className="mb-3"> <Card.Title as="h3" className="mb-3">
{agentName} {t('login')} {ucAgent?.agent_info.display_name} {t('login')}
</Card.Title> </Card.Title>
{qrcodeDataUrl ? ( {qrcodeDataUrl ? (
<> <>
@ -79,7 +79,9 @@ const Index: FC = () => {
alt={agentName} alt={agentName}
/> />
<div className="text-secondary mt-3"> <div className="text-secondary mt-3">
{t('qrcode_login_tip', { agentName })} {t('qrcode_login_tip', {
agentName: ucAgent?.agent_info.display_name,
})}
</div> </div>
</> </>
) : null} ) : null}

View File

@ -1,5 +1,8 @@
import React, { FC } from 'react'; import React, { FC } from 'react';
import { Card, Col, Carousel } from 'react-bootstrap'; import { Card, Col, Carousel } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
import { userCenterStore } from '@/stores';
const data = [ const data = [
{ {
@ -25,14 +28,17 @@ const data = [
]; ];
const Index: FC = () => { const Index: FC = () => {
const { t } = useTranslation('translation', { keyPrefix: 'plugins' });
const ucAgent = userCenterStore().agent;
return ( return (
<Col lg={4} className="mx-auto mt-3 py-5"> <Col lg={4} className="mx-auto mt-3 py-5">
<Card> <Card>
<Card.Body> <Card.Body>
<h3 className="text-center pt-3 mb-3">WeCom Login</h3> <h3 className="text-center pt-3 mb-3">
{ucAgent?.agent_info.display_name} {t('login')}
</h3>
<p className="text-danger text-center"> <p className="text-danger text-center">
Login failed, please allow this app to access your email information {t('login_failed_email_tip')}
before try again.
</p> </p>
<Carousel controls={false}> <Carousel controls={false}>

View File

@ -281,7 +281,7 @@ const Index: React.FC = () => {
<Form.Control <Form.Control
required required
type="text" type="text"
readOnly={!usersSetting.allow_update_display_name} disabled={!usersSetting.allow_update_display_name}
value={formData.display_name.value} value={formData.display_name.value}
isInvalid={formData.display_name.isInvalid} isInvalid={formData.display_name.isInvalid}
onChange={(e) => onChange={(e) =>
@ -304,7 +304,7 @@ const Index: React.FC = () => {
<Form.Control <Form.Control
required required
type="text" type="text"
readOnly={!usersSetting.allow_update_username} disabled={!usersSetting.allow_update_username}
value={formData.username.value} value={formData.username.value}
isInvalid={formData.username.isInvalid} isInvalid={formData.username.isInvalid}
onChange={(e) => onChange={(e) =>
@ -424,7 +424,7 @@ const Index: React.FC = () => {
required required
as="textarea" as="textarea"
rows={5} rows={5}
readOnly={!usersSetting.allow_update_bio} disabled={!usersSetting.allow_update_bio}
value={formData.bio.value} value={formData.bio.value}
isInvalid={formData.bio.isInvalid} isInvalid={formData.bio.isInvalid}
onChange={(e) => onChange={(e) =>
@ -450,7 +450,7 @@ const Index: React.FC = () => {
required required
type="url" type="url"
placeholder={t('website.placeholder')} placeholder={t('website.placeholder')}
readOnly={!usersSetting.allow_update_website} disabled={!usersSetting.allow_update_website}
value={formData.website.value} value={formData.website.value}
isInvalid={formData.website.isInvalid} isInvalid={formData.website.isInvalid}
onChange={(e) => onChange={(e) =>
@ -476,7 +476,7 @@ const Index: React.FC = () => {
required required
type="text" type="text"
placeholder={t('location.placeholder')} placeholder={t('location.placeholder')}
readOnly={!usersSetting.allow_update_location} disabled={!usersSetting.allow_update_location}
value={formData.location.value} value={formData.location.value}
isInvalid={formData.location.isInvalid} isInvalid={formData.location.isInvalid}
onChange={(e) => onChange={(e) =>

View File

@ -13,7 +13,6 @@ interface Props {
const Index: FC<Props> = ({ className }) => { const Index: FC<Props> = ({ className }) => {
const { t } = useTranslation('translation', { keyPrefix: 'plugins.oauth' }); const { t } = useTranslation('translation', { keyPrefix: 'plugins.oauth' });
const ucAgent = userCenterStore().agent; const ucAgent = userCenterStore().agent;
const agentName = ucAgent?.agent_info?.name || '';
const ucLoginRedirect = const ucLoginRedirect =
ucAgent?.enabled && ucAgent?.agent_info?.login_redirect_url; ucAgent?.enabled && ucAgent?.agent_info?.login_redirect_url;
@ -24,7 +23,9 @@ const Index: FC<Props> = ({ className }) => {
variant="outline-secondary" variant="outline-secondary"
href={ucAgent?.agent_info.login_redirect_url}> href={ucAgent?.agent_info.login_redirect_url}>
<SvgIcon base64={ucAgent?.agent_info.icon} /> <SvgIcon base64={ucAgent?.agent_info.icon} />
<span>{t('connect', { auth_name: agentName })}</span> <span>
{t('connect', { auth_name: ucAgent?.agent_info.display_name })}
</span>
</Button> </Button>
); );
} }

View File

@ -11,6 +11,7 @@ export interface UcAgent {
name: string; name: string;
icon: string; icon: string;
url: string; url: string;
display_name: string;
login_redirect_url: string; login_redirect_url: string;
sign_up_redirect_url: string; sign_up_redirect_url: string;
control_center: UcAgentControl[]; control_center: UcAgentControl[];