mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
feat(core): adjust admin panel style (#7116)
This commit is contained in:
@@ -18,7 +18,13 @@ function validateConfigType<K extends keyof FlattenedAppRuntimeConfig>(
|
|||||||
key: K,
|
key: K,
|
||||||
value: any
|
value: any
|
||||||
) {
|
) {
|
||||||
const want = defaultRuntimeConfig[key].type;
|
const config = defaultRuntimeConfig[key];
|
||||||
|
|
||||||
|
if (!config) {
|
||||||
|
throw new BadRequestException(`Unknown runtime config key '${key}'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const want = config.type;
|
||||||
const get = runtimeConfigType(value);
|
const get = runtimeConfigType(value);
|
||||||
if (get !== want) {
|
if (get !== want) {
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
|
|||||||
@@ -4,11 +4,9 @@ import { ArrowRightBigIcon, Logo1Icon } from '@blocksuite/icons';
|
|||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
|
|
||||||
import * as styles from './index.css';
|
import * as styles from './index.css';
|
||||||
import { formatValue } from './utils';
|
|
||||||
|
|
||||||
export type ModifiedValues = {
|
export type ModifiedValues = {
|
||||||
id: string;
|
id: string;
|
||||||
key: string;
|
|
||||||
expiredValue: any;
|
expiredValue: any;
|
||||||
newValue: any;
|
newValue: any;
|
||||||
};
|
};
|
||||||
@@ -46,20 +44,27 @@ export const AdminPanelHeader = ({
|
|||||||
type: 'primary',
|
type: 'primary',
|
||||||
},
|
},
|
||||||
onConfirm: onConfirm,
|
onConfirm: onConfirm,
|
||||||
children: (
|
children:
|
||||||
<div className={styles.changedValues}>
|
modifiedValues.length > 0 ? (
|
||||||
{modifiedValues.length > 0
|
<pre className={styles.changedValues}>
|
||||||
? modifiedValues.map(
|
<p>{'{'}</p>
|
||||||
({ id, key, expiredValue, newValue }) => (
|
{modifiedValues.map(({ id, expiredValue, newValue }) => (
|
||||||
<div key={id}>
|
<p key={id}>
|
||||||
{key}: {formatValue(expiredValue)} =>{' '}
|
{' '} {id}:{' '}
|
||||||
{formatValue(newValue)}
|
<span className={styles.expiredValue}>
|
||||||
</div>
|
{JSON.stringify(expiredValue)}
|
||||||
)
|
</span>
|
||||||
)
|
<span className={styles.newValue}>
|
||||||
: 'There is no change.'}
|
{JSON.stringify(newValue)}
|
||||||
</div>
|
</span>
|
||||||
),
|
,
|
||||||
|
</p>
|
||||||
|
))}
|
||||||
|
<p>{'}'}</p>
|
||||||
|
</pre>
|
||||||
|
) : (
|
||||||
|
'There is no change.'
|
||||||
|
),
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ export const navText = style({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const settingItem = style({
|
export const settingItem = style({
|
||||||
maxWidth: '800px',
|
maxWidth: '960px',
|
||||||
minHeight: '100px',
|
minHeight: '100px',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
gap: 8,
|
gap: 8,
|
||||||
@@ -134,7 +134,17 @@ export const settingItemTitle = style({
|
|||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
wordBreak: 'break-all',
|
wordBreak: 'break-all',
|
||||||
wordWrap: 'break-word',
|
wordWrap: 'break-word',
|
||||||
marginBottom: 8,
|
marginBottom: 6,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const settingItemId = style({
|
||||||
|
fontSize: cssVar('fontXs'),
|
||||||
|
color: cssVar('textSecondaryColor'),
|
||||||
|
borderRadius: 4,
|
||||||
|
borderColor: cssVar('borderColor'),
|
||||||
|
backgroundColor: cssVar('backgroundSecondaryColor'),
|
||||||
|
padding: '2px 4px',
|
||||||
|
wordBreak: 'keep-all',
|
||||||
});
|
});
|
||||||
|
|
||||||
export const settingItemDescription = style({
|
export const settingItemDescription = style({
|
||||||
@@ -155,3 +165,15 @@ export const changedValues = style({
|
|||||||
color: cssVar('textPrimaryColor'),
|
color: cssVar('textPrimaryColor'),
|
||||||
fontSize: cssVar('fontSm'),
|
fontSize: cssVar('fontSm'),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const expiredValue = style({
|
||||||
|
color: cssVar('textHighlightForegroundRed'),
|
||||||
|
background: cssVar('textHighlightRed'),
|
||||||
|
textDecoration: 'line-through',
|
||||||
|
marginRight: 2,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const newValue = style({
|
||||||
|
color: cssVar('textHighlightForegroundGreen'),
|
||||||
|
background: cssVar('textHighlightGreen'),
|
||||||
|
});
|
||||||
|
|||||||
@@ -4,14 +4,12 @@ import * as styles from './index.css';
|
|||||||
|
|
||||||
export const RuntimeSettingRow = ({
|
export const RuntimeSettingRow = ({
|
||||||
id,
|
id,
|
||||||
title,
|
|
||||||
description,
|
description,
|
||||||
lastUpdatedTime,
|
lastUpdatedTime,
|
||||||
operation,
|
operation,
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
id: string;
|
id: string;
|
||||||
title: string;
|
|
||||||
description: string;
|
description: string;
|
||||||
lastUpdatedTime: string;
|
lastUpdatedTime: string;
|
||||||
operation: ReactNode;
|
operation: ReactNode;
|
||||||
@@ -21,8 +19,10 @@ export const RuntimeSettingRow = ({
|
|||||||
return (
|
return (
|
||||||
<div id={id} className={styles.settingItem}>
|
<div id={id} className={styles.settingItem}>
|
||||||
<div className={styles.LeftItem}>
|
<div className={styles.LeftItem}>
|
||||||
<div className={styles.settingItemTitle}>{title}</div>
|
<div className={styles.settingItemTitle}>{description}</div>
|
||||||
<div className={styles.settingItemDescription}>{description}</div>
|
<div>
|
||||||
|
<code className={styles.settingItemId}>{id}</code>
|
||||||
|
</div>
|
||||||
<div className={styles.settingItemDescription}>
|
<div className={styles.settingItemDescription}>
|
||||||
last updated at: {formatTime}
|
last updated at: {formatTime}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export const moduleContainer = style({
|
|||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
padding: '16px',
|
padding: '16px',
|
||||||
maxWidth: '800px',
|
maxWidth: '960px',
|
||||||
margin: 'auto',
|
margin: 'auto',
|
||||||
gap: 16,
|
gap: 16,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -107,9 +107,7 @@ export const AdminPanel = () => {
|
|||||||
>
|
>
|
||||||
<div className={styles.module}>{moduleName}</div>
|
<div className={styles.module}>{moduleName}</div>
|
||||||
{configs?.map(config => {
|
{configs?.map(config => {
|
||||||
const { id, key, type, description, updatedAt } =
|
const { id, type, description, updatedAt } = config;
|
||||||
config;
|
|
||||||
const title = `${key} (${id})`;
|
|
||||||
const isValueEqual = isEqual(
|
const isValueEqual = isEqual(
|
||||||
config.value,
|
config.value,
|
||||||
configValues[id]
|
configValues[id]
|
||||||
@@ -121,8 +119,7 @@ export const AdminPanel = () => {
|
|||||||
return (
|
return (
|
||||||
<RuntimeSettingRow
|
<RuntimeSettingRow
|
||||||
key={id}
|
key={id}
|
||||||
id={key}
|
id={id}
|
||||||
title={title}
|
|
||||||
description={description}
|
description={description}
|
||||||
lastUpdatedTime={updatedAt}
|
lastUpdatedTime={updatedAt}
|
||||||
operation={renderInput(
|
operation={renderInput(
|
||||||
|
|||||||
Reference in New Issue
Block a user