Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

Merge branch 'feat/ui-1.1.0' into feat/1.1.2/ui

haitaooa045060b7652
diff --cc ui/src/pages/Users/Settings/Profile/index.tsx
index ae1ae01e,acc492b0..8c767436
--- a/ui/src/pages/Users/Settings/Profile/index.tsx
+++ b/ui/src/pages/Users/Settings/Profile/index.tsx
@@@ -270,234 -254,217 +270,234 @@@ const Index: React.FC = () =>
return (
<>
<h3 className="mb-4">{t('heading')}</h3>
- <Form noValidate onSubmit={handleSubmit}>
- <Form.Group controlId="displayName" className="mb-3">
- <Form.Label>{t('display_name.label')}</Form.Label>
- <Form.Control
- required
- type="text"
- value={formData.display_name.value}
- isInvalid={formData.display_name.isInvalid}
- onChange={(e) =>
- handleChange({
- display_name: {
- value: e.target.value,
- isInvalid: false,
- errorMsg: '',
- },
- })
- }
- />
- <Form.Control.Feedback type="invalid">
- {formData.display_name.errorMsg}
- </Form.Control.Feedback>
- </Form.Group>
+ {profileAgent?.enabled && profileAgent?.redirect_url ? (
+ <a href={profileAgent.redirect_url}>
+ {t('goto_modify', { keyPrefix: 'settings' })}
+ </a>
+ ) : null}
+ {!ucAgent?.enabled || profileAgent?.enabled === false ? (
+ <Form noValidate onSubmit={handleSubmit}>
+ <Form.Group controlId="displayName" className="mb-3">
+ <Form.Label>{t('display_name.label')}</Form.Label>
+ <Form.Control
+ required
+ type="text"
+ readOnly={!usersSetting.allow_update_display_name}
+ value={formData.display_name.value}
+ isInvalid={formData.display_name.isInvalid}
+ onChange={(e) =>
+ handleChange({
+ display_name: {
+ value: e.target.value,
+ isInvalid: false,
+ errorMsg: '',
+ },
+ })
+ }
+ />
+ <Form.Control.Feedback type="invalid">
+ {formData.display_name.errorMsg}
+ </Form.Control.Feedback>
+ </Form.Group>
- <Form.Group controlId="userName" className="mb-3">
- <Form.Label>{t('username.label')}</Form.Label>
- <Form.Control
- required
- type="text"
- value={formData.username.value}
- isInvalid={formData.username.isInvalid}
- onChange={(e) =>
- handleChange({
- username: {
- value: e.target.value,
- isInvalid: false,
- errorMsg: '',
- },
- })
- }
- />
- <Form.Text as="div">{t('username.caption')}</Form.Text>
- <Form.Control.Feedback type="invalid">
- {formData.username.errorMsg}
- </Form.Control.Feedback>
- </Form.Group>
+ <Form.Group controlId="userName" className="mb-3">
+ <Form.Label>{t('username.label')}</Form.Label>
+ <Form.Control
+ required
+ type="text"
+ readOnly={!usersSetting.allow_update_username}
+ value={formData.username.value}
+ isInvalid={formData.username.isInvalid}
+ onChange={(e) =>
+ handleChange({
+ username: {
+ value: e.target.value,
+ isInvalid: false,
+ errorMsg: '',
+ },
+ })
+ }
+ />
+ <Form.Text as="div">{t('username.caption')}</Form.Text>
+ <Form.Control.Feedback type="invalid">
+ {formData.username.errorMsg}
+ </Form.Control.Feedback>
+ </Form.Group>
- <Form.Group className="mb-3">
- <Form.Group controlId="avatar" className="mb-3">
- <Form.Label>{t('avatar.label')}</Form.Label>
- <div className="mb-3">
- <Form.Select
- name="avatar.type"
- value={formData.avatar.type}
- onChange={handleAvatarChange}>
- <option value="gravatar" key="gravatar">
- {t('avatar.gravatar')}
- </option>
- <option value="default" key="default">
- {t('avatar.default')}
- </option>
- <option value="custom" key="custom">
- {t('avatar.custom')}
- </option>
- </Form.Select>
- </div>
- <div className="d-flex">
- {formData.avatar.type === 'gravatar' && (
- <Stack>
- <Avatar
- size="160px"
- avatar={formData.avatar.gravatar}
- searchStr={`s=256&d=identicon${
- count > 0 ? `&t=${new Date().valueOf()}` : ''
- }`}
- className="me-3 rounded"
- />
- <Form.Text className="text-muted mt-1">
- <Trans i18nKey="settings.profile.avatar.gravatar_text">
- You can change image on
- <a
- href="https://gravatar.com"
- target="_blank"
- rel="noreferrer">
- gravatar.com
- </a>
- </Trans>
- </Form.Text>
- </Stack>
- )}
-
- {formData.avatar.type === 'custom' && (
- <Stack>
- <Stack direction="horizontal" className="align-items-start">
++ <Form.Group controlId="avatar" className="mb-3">
+ <Form.Label>{t('avatar.label')}</Form.Label>
+ <div className="mb-3">
+ <Form.Select
+ name="avatar.type"
+ disabled={!usersSetting.allow_update_avatar}
+ value={formData.avatar.type}
+ onChange={handleAvatarChange}>
+ <option value="gravatar" key="gravatar">
+ {t('avatar.gravatar')}
+ </option>
+ <option value="default" key="default">
+ {t('avatar.default')}
+ </option>
+ <option value="custom" key="custom">
+ {t('avatar.custom')}
+ </option>
+ </Form.Select>
+ </div>
+ <div className="d-flex">
+ {formData.avatar.type === 'gravatar' && (
+ <Stack>
<Avatar
size="160px"
- searchStr="s=256"
- avatar={formData.avatar.custom}
- className="me-2 bg-gray-300 "
+ avatar={formData.avatar.gravatar}
+ searchStr={`s=256&d=identicon${
+ count > 0 ? `&t=${new Date().valueOf()}` : ''
+ }`}
+ className="me-3 rounded"
/>
- <ButtonGroup vertical className="fit-content">
- <UploadImg type="avatar" uploadCallback={avatarUpload}>
- <Icon name="cloud-upload" />
- </UploadImg>
- <Button
- variant="outline-secondary"
- onClick={removeCustomAvatar}>
- <Icon name="trash" />
- </Button>
- </ButtonGroup>
+ <Form.Text className="text-muted mt-1">
+ <Trans i18nKey="settings.profile.avatar.gravatar_text">
+ You can change image on
+ <a
+ href="https://gravatar.com"
+ target="_blank"
+ rel="noreferrer">
+ gravatar.com
+ </a>
+ </Trans>
+ </Form.Text>
</Stack>
- <Form.Text className="text-muted mt-1">
- <Trans i18nKey="settings.profile.avatar.text">
- You can upload your image.
- </Trans>
- </Form.Text>
- </Stack>
- )}
- {formData.avatar.type === 'default' && (
- <Avatar size="160px" avatar="" />
- )}
- </div>
- <Form.Control
- isInvalid={formData.avatar.isInvalid}
- className="d-none"
- />
- <Form.Control.Feedback type="invalid">
- {formData.avatar.errorMsg}
- </Form.Control.Feedback>
- </Form.Group>
+ )}
- <Form.Group controlId="bio" className="mb-3">
- <Form.Label>
- {`${t('bio.label')} ${t('optional', {
- keyPrefix: 'form',
- })}`}
- </Form.Label>
- <Form.Control
- className="font-monospace"
- required
- as="textarea"
- rows={5}
- value={formData.bio.value}
- isInvalid={formData.bio.isInvalid}
- onChange={(e) =>
- handleChange({
- bio: {
- value: e.target.value,
- isInvalid: false,
- errorMsg: '',
- },
- })
- }
- />
- <Form.Control.Feedback type="invalid">
- {formData.bio.errorMsg}
- </Form.Control.Feedback>
- </Form.Group>
+ {formData.avatar.type === 'custom' && (
+ <Stack>
+ <Stack direction="horizontal" className="align-items-start">
+ <Avatar
+ size="160px"
+ searchStr="s=256"
+ avatar={formData.avatar.custom}
+ className="me-2 bg-gray-300 "
+ />
+ <ButtonGroup vertical className="fit-content">
+ <UploadImg
+ type="avatar"
+ disabled={!usersSetting.allow_update_avatar}
+ uploadCallback={avatarUpload}>
+ <Icon name="cloud-upload" />
+ </UploadImg>
+ <Button
+ variant="outline-secondary"
+ disabled={!usersSetting.allow_update_avatar}
+ onClick={removeCustomAvatar}>
+ <Icon name="trash" />
+ </Button>
+ </ButtonGroup>
+ </Stack>
+ <Form.Text className="text-muted mt-1">
+ <Trans i18nKey="settings.profile.avatar.text">
+ You can upload your image.
+ </Trans>
+ </Form.Text>
+ </Stack>
+ )}
+ {formData.avatar.type === 'default' && (
+ <Avatar size="160px" avatar="" />
+ )}
+ </div>
+ <Form.Control
+ isInvalid={formData.avatar.isInvalid}
+ className="d-none"
+ />
+ <Form.Control.Feedback type="invalid">
+ {formData.avatar.errorMsg}
+ </Form.Control.Feedback>
+ </Form.Group>
- <Form.Group controlId="website" className="mb-3">
- <Form.Label>{`${t('website.label')} ${t('optional', {
- keyPrefix: 'form',
- })}`}</Form.Label>
- <Form.Control
- required
- type="url"
- placeholder={t('website.placeholder')}
- value={formData.website.value}
- isInvalid={formData.website.isInvalid}
- onChange={(e) =>
- handleChange({
- website: {
- value: e.target.value,
- isInvalid: false,
- errorMsg: '',
- },
- })
- }
- />
- <Form.Control.Feedback type="invalid">
- {formData.website.errorMsg}
- </Form.Control.Feedback>
- </Form.Group>
+ <Form.Group controlId="bio" className="mb-3">
+ <Form.Label>
+ {`${t('bio.label')} ${t('optional', {
+ keyPrefix: 'form',
+ })}`}
+ </Form.Label>
+ <Form.Control
+ className="font-monospace"
+ required
+ as="textarea"
+ rows={5}
+ readOnly={!usersSetting.allow_update_bio}
+ value={formData.bio.value}
+ isInvalid={formData.bio.isInvalid}
+ onChange={(e) =>
+ handleChange({
+ bio: {
+ value: e.target.value,
+ isInvalid: false,
+ errorMsg: '',
+ },
+ })
+ }
+ />
+ <Form.Control.Feedback type="invalid">
+ {formData.bio.errorMsg}
+ </Form.Control.Feedback>
+ </Form.Group>
- <Form.Group controlId="email" className="mb-3">
- <Form.Label>{`${t('location.label')} ${t('optional', {
- keyPrefix: 'form',
- })}`}</Form.Label>
- <Form.Control
- required
- type="text"
- placeholder={t('location.placeholder')}
- value={formData.location.value}
- isInvalid={formData.location.isInvalid}
- onChange={(e) =>
- handleChange({
- location: {
- value: e.target.value,
- isInvalid: false,
- errorMsg: '',
- },
- })
- }
- />
- <Form.Control.Feedback type="invalid">
- {formData.location.errorMsg}
- </Form.Control.Feedback>
- </Form.Group>
+ <Form.Group controlId="website" className="mb-3">
+ <Form.Label>{`${t('website.label')} ${t('optional', {
+ keyPrefix: 'form',
+ })}`}</Form.Label>
+ <Form.Control
+ required
+ type="url"
+ placeholder={t('website.placeholder')}
+ readOnly={!usersSetting.allow_update_website}
+ value={formData.website.value}
+ isInvalid={formData.website.isInvalid}
+ onChange={(e) =>
+ handleChange({
+ website: {
+ value: e.target.value,
+ isInvalid: false,
+ errorMsg: '',
+ },
+ })
+ }
+ />
+ <Form.Control.Feedback type="invalid">
+ {formData.website.errorMsg}
+ </Form.Control.Feedback>
+ </Form.Group>
+
+ <Form.Group controlId="email" className="mb-3">
+ <Form.Label>{`${t('location.label')} ${t('optional', {
+ keyPrefix: 'form',
+ })}`}</Form.Label>
+ <Form.Control
+ required
+ type="text"
+ placeholder={t('location.placeholder')}
+ readOnly={!usersSetting.allow_update_location}
+ value={formData.location.value}
+ isInvalid={formData.location.isInvalid}
+ onChange={(e) =>
+ handleChange({
+ location: {
+ value: e.target.value,
+ isInvalid: false,
+ errorMsg: '',
+ },
+ })
+ }
+ />
+ <Form.Control.Feedback type="invalid">
+ {formData.location.errorMsg}
+ </Form.Control.Feedback>
+ </Form.Group>
- <Button variant="primary" type="submit">
- {t('btn_name')}
- </Button>
- </Form>
+ <Button variant="primary" type="submit">
+ {t('btn_name')}
+ </Button>
+ </Form>
+ ) : null}
</>
);
};