improve DialogButton
This commit is contained in:
parent
08bc342fd6
commit
3cef51144f
@ -16,20 +16,28 @@ import { LazyImportComponent } from './LazyImportComponent';
|
||||
const MarkdownRender = React.lazy(() => import('./MarkdownRender'));
|
||||
|
||||
export const DialogButton: FC<{
|
||||
text?: string | null
|
||||
text?: string | null,
|
||||
icon?: ReactElement,
|
||||
tooltip?: string | null,
|
||||
className?: string,
|
||||
title: string,
|
||||
contentText: string,
|
||||
content?: string | ReactElement | null
|
||||
markdown?: boolean,
|
||||
onConfirm?: () => void,
|
||||
size?: 'small' | 'medium' | 'large',
|
||||
shape?: 'rounded' | 'circular' | 'square',
|
||||
appearance?: 'secondary' | 'primary' | 'outline' | 'subtle' | 'transparent',
|
||||
cancelButton?: boolean,
|
||||
confirmButton?: boolean,
|
||||
cancelButtonText?: string,
|
||||
confirmButtonText?: string,
|
||||
}> = ({
|
||||
text, icon, tooltip, className, title, contentText, markdown,
|
||||
onConfirm, size, shape, appearance
|
||||
text, icon, tooltip, className, title, content, markdown,
|
||||
onConfirm, size, shape, appearance,
|
||||
cancelButton = true,
|
||||
confirmButton = true,
|
||||
cancelButtonText = 'Cancel',
|
||||
confirmButtonText = 'Confirm'
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@ -48,19 +56,24 @@ export const DialogButton: FC<{
|
||||
{
|
||||
markdown ?
|
||||
<LazyImportComponent lazyChildren={MarkdownRender}>
|
||||
{contentText}
|
||||
{content}
|
||||
</LazyImportComponent> :
|
||||
contentText
|
||||
content
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<DialogTrigger disableButtonEnhancement>
|
||||
<Button appearance="secondary">{t('Cancel')}</Button>
|
||||
</DialogTrigger>
|
||||
<DialogTrigger disableButtonEnhancement>
|
||||
<Button appearance="primary" onClick={onConfirm}>{t('Confirm')}
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
{cancelButton && (
|
||||
<DialogTrigger disableButtonEnhancement>
|
||||
<Button appearance="secondary">{t(cancelButtonText)}</Button>
|
||||
</DialogTrigger>
|
||||
)}
|
||||
{confirmButton && (
|
||||
<DialogTrigger disableButtonEnhancement>
|
||||
<Button appearance="primary" onClick={onConfirm}>
|
||||
{t(confirmButtonText)}
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
)}
|
||||
</DialogActions>
|
||||
</DialogBody>
|
||||
</DialogSurface>
|
||||
|
@ -9,7 +9,7 @@ import { defaultModelConfigs, defaultModelConfigsMac } from '../pages/defaultCon
|
||||
export const ResetConfigsButton: FC<{ afterConfirm?: () => void }> = ({ afterConfirm }) => {
|
||||
const { t } = useTranslation();
|
||||
return <DialogButton icon={<ArrowReset20Regular />} tooltip={t('Reset All Configs')} title={t('Reset All Configs')}
|
||||
contentText={t('Are you sure you want to reset all configs? This will obtain the latest preset configs, but will override your custom configs and cannot be undone.')}
|
||||
content={t('Are you sure you want to reset all configs? This will obtain the latest preset configs, but will override your custom configs and cannot be undone.')}
|
||||
onConfirm={() => {
|
||||
commonStore.setModelConfigs(commonStore.platform !== 'darwin' ? defaultModelConfigs : defaultModelConfigsMac, false);
|
||||
commonStore.setCurrentConfigIndex(0, true);
|
||||
|
@ -651,7 +651,7 @@ const ChatPanel: FC = observer(() => {
|
||||
<DialogButton tooltip={t('Clear')}
|
||||
icon={<Delete28Regular />}
|
||||
size={mq ? 'large' : 'small'} shape="circular" appearance="subtle" title={t('Clear')}
|
||||
contentText={t('Are you sure you want to clear the conversation? It cannot be undone.')}
|
||||
content={t('Are you sure you want to clear the conversation? It cannot be undone.')}
|
||||
onConfirm={() => {
|
||||
if (generating) {
|
||||
for (const id in chatSseControllers) {
|
||||
|
@ -284,7 +284,7 @@ const CompletionPanel: FC = observer(() => {
|
||||
onSubmit(commonStore.completionSubmittedPrompt);
|
||||
}} />
|
||||
<DialogButton className="grow" text={t('Reset')} title={t('Reset')}
|
||||
contentText={t('Are you sure you want to reset this page? It cannot be undone.')}
|
||||
content={t('Are you sure you want to reset this page? It cannot be undone.')}
|
||||
onConfirm={() => {
|
||||
setPreset(defaultPresets.find((preset) => preset.name === name)!);
|
||||
}} />
|
||||
|
@ -387,7 +387,7 @@ const CompositionPanel: FC = observer(() => {
|
||||
onSubmit(commonStore.compositionSubmittedPrompt);
|
||||
}} />
|
||||
<DialogButton className="grow" text={t('Reset')} title={t('Reset')}
|
||||
contentText={t('Are you sure you want to reset this page? It cannot be undone.')}
|
||||
content={t('Are you sure you want to reset this page? It cannot be undone.')}
|
||||
onConfirm={() => {
|
||||
const isABC = commonStore.getCurrentModelConfig().modelParameters.modelName.toLowerCase().includes('abc');
|
||||
const defaultPrompt = isABC ? defaultCompositionABCPrompt : defaultCompositionPrompt;
|
||||
|
@ -391,7 +391,7 @@ const LoraFinetune: FC = observer(() => {
|
||||
setDataParams({ dataPath: data.value });
|
||||
}} />
|
||||
<DialogButton text={t('Help')} title={t('Help')} markdown
|
||||
contentText={t('The data path should be a directory or a file in jsonl format (more formats will be supported in the future).\n\n' +
|
||||
content={t('The data path should be a directory or a file in jsonl format (more formats will be supported in the future).\n\n' +
|
||||
'When you provide a directory path, all the txt files within that directory will be automatically converted into training data. ' +
|
||||
'This is commonly used for large-scale training in writing, code generation, or knowledge bases.\n\n' +
|
||||
'The jsonl format file can be referenced at https://github.com/josStorer/RWKV-Runner/blob/master/finetune/data/sample.jsonl.\n' +
|
||||
|
Loading…
Reference in New Issue
Block a user