Skip to content

Commit

Permalink
馃悰 fix: disabled autogenerate field icon when empty system role (#2076)
Browse files Browse the repository at this point in the history
* fix: disabled autogenerate field icon when empty system role

* 馃悰 fix: update systemrole guard

* 馃悰 fix: revert action.ts file change

* 馃悰 fix: added space
  • Loading branch information
techcontributor committed May 4, 2024
1 parent d6eeac0 commit 27095f5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 27 deletions.
57 changes: 31 additions & 26 deletions src/features/AgentSetting/AgentMeta/AutoGenerateInput.tsx
Expand Up @@ -5,37 +5,42 @@ import { Wand2 } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';


export interface AutoGenerateInputProps extends InputProps {
canAutoGenerate?: boolean;
loading?: boolean;
onGenerate?: () => void;
}

const AutoGenerateInput = memo<AutoGenerateInputProps>(({ loading, onGenerate, ...props }) => {
const { t } = useTranslation('common');
const theme = useTheme();
const AutoGenerateInput = memo<AutoGenerateInputProps>(
({ loading, onGenerate, canAutoGenerate, ...props }) => {
const { t } = useTranslation('common');
const theme = useTheme();

return (
<Input
suffix={
onGenerate && (
<ActionIcon
active
icon={Wand2}
loading={loading}
onClick={onGenerate}
size={'small'}
style={{
color: theme.colorInfo,
marginRight: -4,
}}
title={t('autoGenerate')}
/>
)
}
type={'block'}
{...props}
/>
);
});
return (
<Input
suffix={
onGenerate && (
<ActionIcon
active
disable={!canAutoGenerate}
icon={Wand2}
loading={loading}
onClick={onGenerate}
size="small"
style={{
color: theme.colorInfo,
marginRight: -4,
}}
title={t('autoGenerate')}
/>
)
}
type="block"
{...props}
/>
);
},
);

export default AutoGenerateInput;
4 changes: 3 additions & 1 deletion src/features/AgentSetting/AgentMeta/AutoGenerateSelect.tsx
Expand Up @@ -7,12 +7,13 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';

export interface AutoGenerateInputProps extends SelectProps {
canAutoGenerate?: boolean;
loading?: boolean;
onGenerate?: () => void;
}

const AutoGenerateSelect = memo<AutoGenerateInputProps>(
({ loading, onGenerate, value, ...props }) => {
({ loading, onGenerate, value, canAutoGenerate, ...props }) => {
const { t } = useTranslation('common');
const theme = useTheme();

Expand All @@ -25,6 +26,7 @@ const AutoGenerateSelect = memo<AutoGenerateInputProps>(
onGenerate && (
<ActionIcon
active
disable={!canAutoGenerate}
icon={Wand2}
loading={loading}
onClick={onGenerate}
Expand Down
2 changes: 2 additions & 0 deletions src/features/AgentSetting/AgentMeta/index.tsx
Expand Up @@ -63,6 +63,8 @@ const AgentMeta = memo(() => {
return {
children: (
<AutoGenerate
canAutoGenerate={hasSystemRole}
disabled={!hasSystemRole}
loading={loading[item.key as keyof SessionLoadingState]}
onChange={item.onChange}
onGenerate={() => {
Expand Down

0 comments on commit 27095f5

Please sign in to comment.