Skip to content

Commit

Permalink
Feat/1.2.1/UI (#623)
Browse files Browse the repository at this point in the history
  • Loading branch information
shuashuai authored Nov 15, 2023
1 parent b454515 commit 175c042
Show file tree
Hide file tree
Showing 22 changed files with 145 additions and 57 deletions.
6 changes: 3 additions & 3 deletions i18n/de_DE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -722,9 +722,9 @@ ui:
btn_save_edits: Änderungen speichern
btn_cancel: Stornieren
dates:
long_date: MMM D
long_date_with_year: "MMM D, JJJJ"
long_date_with_time: "MMM T, JJJJ [at] HH:mm"
long_date: DD. MMM
long_date_with_year: "DD. MMM YYYY"
long_date_with_time: "DD. MMM YYYY [at] HH:mm"
now: jetzt
x_seconds_ago: "vor {{count}}s"
x_minutes_ago: "vor {{count}}m"
Expand Down
28 changes: 22 additions & 6 deletions i18n/en_US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1400,23 +1400,33 @@ ui:
dashboard:
title: Dashboard
welcome: Welcome to Answer Admin!
site_statistics: Site Statistics
site_statistics: Site statistics
questions: "Questions:"
answers: "Answers:"
comments: "Comments:"
votes: "Votes:"
active_users: "Active users:"
users: "Users:"
flags: "Flags:"
site_health_status: Site Health Status
site_health_status: Site health status
version: "Version:"
https: "HTTPS:"
uploading_files: "Uploading files:"
upload_folder: "Upload folder:"
run_mode: "Running mode:"
private: Private
public: Public
smtp: "SMTP:"
timezone: "Timezone:"
system_info: System Info
system_info: System info
go_version: "Go version:"
database: "Database:"
database_size: "Database size:"
storage_used: "Storage used:"
uptime: "Uptime:"
answer_links: Answer Links
answer_links: Answer links
plugins: Plugins
github: GitHub
blog: Blog
contact: Contact
documents: Documents
feedback: Feedback
support: Support
Expand All @@ -1431,6 +1441,8 @@ ui:
allowed: Allowed
enabled: Enabled
disabled: Disabled
writable: Writable
not_writable: Not writable
flags:
title: Flags
pending: Pending
Expand Down Expand Up @@ -1704,6 +1716,10 @@ ui:
title: Private
label: Login required
text: Only logged in users can access this community.
password_login:
title: Password login
label: Allow email and password login
text: "WARNING: If turn off, you may be unable to log in if you have not previously configured other login method."
installed_plugins:
title: Installed Plugins
plugin_link: Plugins extend and expand the functionality of Answer. You may find plugins in the <1>Answer Plugin Repository</1>.
Expand Down
7 changes: 6 additions & 1 deletion ui/src/common/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ export interface AdminSettingsLogin {
login_required: boolean;
allow_email_registrations: boolean;
allow_email_domains: string[];
allow_password_login: boolean;
}

/**
Expand Down Expand Up @@ -507,11 +508,15 @@ export interface AdminDashboard {
user_count: number;
report_count: number;
uploading_files: boolean;
smtp: boolean;
smtp: 'enabled' | 'disabled' | 'not_configured';
time_zone: string;
occupying_storage_space: string;
app_start_time: number;
https: boolean;
login_required: boolean;
go_version: string;
database_version: string;
database_size: string;
version_info: {
remote_version: string;
version: string;
Expand Down
20 changes: 12 additions & 8 deletions ui/src/components/Comment/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,17 @@ const Comment = ({ objectId, mode, commentId }) => {
);
};
return (
<div className="comments-wrap">
{comments.map((item, index) => {
<div
className={classNames(
'comments-wrap',
comments.length > 0 && 'bg-light px-3 py-2 rounded',
)}>
{comments.map((item) => {
return (
<div
key={item.comment_id}
id={item.comment_id}
className={classNames(
'border-bottom py-2 comment-item',
index === 0 && 'border-top',
)}>
className="border-bottom py-2 comment-item">
{item.showEdit ? (
<Form
className="mt-2"
Expand Down Expand Up @@ -397,7 +398,7 @@ const Comment = ({ objectId, mode, commentId }) => {
);
})}

<div className="mt-2">
<div className={classNames(comments.length > 0 && 'py-2')}>
<Button
variant="link"
className="p-0 btn-no-border"
Expand Down Expand Up @@ -425,7 +426,10 @@ const Comment = ({ objectId, mode, commentId }) => {
{visibleComment && (
<Form
mode={mode}
className="mt-2"
className={classNames(
'mt-2',
comments.length <= 0 && 'bg-light p-3 rounded',
)}
onSendReply={(value) => handleSendReply({ value, type: 'comment' })}
onCancel={() => setVisibleComment(!visibleComment)}
/>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const Header: FC = () => {
const tagMatch = useMatch('/tags/:slugName');
let askUrl = '/questions/ask';
if (tagMatch && tagMatch.params.slugName) {
askUrl = `${askUrl}?tags=${tagMatch.params.slugName}`;
askUrl = `${askUrl}?tags=${encodeURIComponent(tagMatch.params.slugName)}`;
}

useEffect(() => {
Expand Down
5 changes: 0 additions & 5 deletions ui/src/components/PluginRender/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ const Index: FC<Props> = ({
const pluginSlice: Plugin[] = [];
const plugins = PluginKit.getPlugins().filter((plugin) => plugin.activated);

console.log('default list', plugins);
plugins.forEach((plugin) => {
console.log('plugininfo ====', plugin);
if (type && slug_name) {
if (plugin.info.slug_name === slug_name && plugin.info.type === type) {
pluginSlice.push(plugin);
Expand Down Expand Up @@ -78,15 +76,13 @@ const Index: FC<Props> = ({
}

if (type === 'editor') {
console.log('444');
const nodes = React.Children.map(children, (child, index) => {
if (index === 15) {
return (
<>
{child}
{pluginSlice.map((ps) => {
const PluginFC = ps.component;
console.log('333', ps.info.slug_name);
return (
// @ts-ignore
<PluginFC key={ps.info.slug_name} {...props} />
Expand All @@ -98,7 +94,6 @@ const Index: FC<Props> = ({
}
return child;
});
console.log('222', nodes?.length);

return <div className={className}>{nodes}</div>;
}
Expand Down
1 change: 0 additions & 1 deletion ui/src/components/SchemaForm/components/Check.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const Index: FC<Props> = ({
},
};
if (typeof onChange === 'function') {
console.log('fieldName', fieldName, enumValues);
onChange(state);
}
};
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/Tag/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const Index: FC<IProps> = ({
className = '',
textClassName = '',
}) => {
href ||= pathFactory.tagLanding(data?.slug_name);
href ||= pathFactory.tagLanding(encodeURIComponent(data.slug_name));

return (
<Link
Expand Down
29 changes: 29 additions & 0 deletions ui/src/pages/Admin/Dashboard/components/AnswerLinks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,40 @@ const AnswerLinks = () => {
{t('documents')}
</a>
</Col>
<Col xs={6}>
<a
href="https://answer.apache.org/plugins"
target="_blank"
rel="noreferrer">
{t('plugins')}
</a>
</Col>
<Col xs={6}>
<a href="https://meta.answer.dev" target="_blank" rel="noreferrer">
{t('support')}
</a>
</Col>
<Col xs={6}>
<a href="https://answer.dev/docs" target="_blank" rel="noreferrer">
{t('github')}
</a>
</Col>
<Col xs={6}>
<a
href="https://answer.apache.org/blog"
target="_blank"
rel="noreferrer">
{t('blog')}
</a>
</Col>
<Col xs={6}>
<a
href="https://answer.apache.org/contact"
target="_blank"
rel="noreferrer">
{t('contact')}
</a>
</Col>
</Row>
</Card.Body>
</Card>
Expand Down
24 changes: 14 additions & 10 deletions ui/src/pages/Admin/Dashboard/components/HealthStatus/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,29 +76,33 @@ const HealthStatus: FC<IProps> = ({ data }) => {
)}
</Col>
<Col xs={6} className="mb-1">
<span className="text-secondary me-1">{t('https')}</span>
<strong>{data.https ? t('yes') : t('no')}</strong>
<span className="text-secondary me-1">{t('run_mode')}</span>
<strong>{data.login_required ? t('private') : t('public')}</strong>
</Col>
<Col xs={6} className="mb-1">
<span className="text-secondary me-1">{t('uploading_files')}</span>
<span className="text-secondary me-1">{t('upload_folder')}</span>
<strong>
{data.uploading_files ? t('allowed') : t('not_allowed')}
{data.uploading_files ? t('writable') : t('not_writable')}
</strong>
</Col>
<Col xs={6} className="mb-1">
<span className="text-secondary me-1">{t('https')}</span>
<strong>{data.https ? t('yes') : t('no')}</strong>
</Col>
<Col xs={6}>
<span className="text-secondary me-1">{t('timezone')}</span>
<strong>{data.time_zone.split('/')?.[1]}</strong>
</Col>
<Col xs={6}>
<span className="text-secondary me-1">{t('smtp')}</span>
{data.smtp ? (
<strong>{t('enabled')}</strong>
{data.smtp !== 'not_configured' ? (
<strong>{t(data.smtp)}</strong>
) : (
<Link to="/admin/smtp" className="ms-2">
{t('config')}
</Link>
)}
</Col>
<Col xs={6}>
<span className="text-secondary me-1">{t('timezone')}</span>
<strong>{data.time_zone}</strong>
</Col>
</Row>
</Card.Body>
</Card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const Statistics: FC<IProps> = ({ data }) => {
<strong>{data.vote_count}</strong>
</Col>
<Col xs={6}>
<span className="text-secondary me-1">{t('active_users')}</span>
<span className="text-secondary me-1">{t('users')}</span>
<strong>{data.user_count}</strong>
</Col>
<Col xs={6}>
Expand Down
12 changes: 12 additions & 0 deletions ui/src/pages/Admin/Dashboard/components/SystemInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,22 @@ const SystemInfo: FC<IProps> = ({ data }) => {
<Card.Body>
<h6 className="mb-3">{t('system_info')}</h6>
<Row>
<Col xs={6}>
<span className="text-secondary me-1">{t('go_version')}</span>
<strong>{data.go_version}</strong>
</Col>
<Col xs={6}>
<span className="text-secondary me-1">{t('database')}</span>
<strong>{data.database_version}</strong>
</Col>
<Col xs={6}>
<span className="text-secondary me-1">{t('storage_used')}</span>
<strong>{data.occupying_storage_space}</strong>
</Col>
<Col xs={6}>
<span className="text-secondary me-1">{t('database_size')}</span>
<strong>{data.database_size}</strong>
</Col>
{data.app_start_time ? (
<Col xs={6}>
<span className="text-secondary me-1">{t('uptime')}</span>
Expand Down
13 changes: 13 additions & 0 deletions ui/src/pages/Admin/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ const Index: FC = () => {
description: t('email_registration.text'),
default: true,
},
allow_password_login: {
type: 'boolean',
title: t('password_login.title'),
description: t('password_login.text'),
default: true,
},
allow_email_domains: {
type: 'string',
title: t('allowed_email_domains.title'),
Expand All @@ -73,6 +79,12 @@ const Index: FC = () => {
label: t('email_registration.label'),
},
},
allow_password_login: {
'ui:widget': 'switch',
'ui:options': {
label: t('password_login.label'),
},
},
allow_email_domains: {
'ui:widget': 'textarea',
},
Expand Down Expand Up @@ -105,6 +117,7 @@ const Index: FC = () => {
allow_email_registrations: formData.allow_email_registrations.value,
allow_email_domains: allowedEmailDomains,
login_required: formData.login_required.value,
allow_password_login: formData.allow_password_login.value,
};

putLoginSetting(reqParams)
Expand Down
Loading

0 comments on commit 175c042

Please sign in to comment.