Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix the disabled status of service provider configuration #5171

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
'use client';

import { Icon } from '@lobehub/ui';
import { Button, Dropdown } from 'antd';
import { Button, ButtonProps, Dropdown } from 'antd';
import { createStyles } from 'antd-style';
import { ChevronDownIcon, SquareArrowOutUpRight } from 'lucide-react';
import Link from 'next/link';
import { memo } from 'react';
import React, { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { FlexboxProps } from 'react-layout-kit';

import { useOpenSettings } from '@/hooks/useInterceptingRoutes';
import { SettingsTabs } from '@/store/global/initialState';
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
import { DiscoverProviderItem } from '@/types/discover';

const useStyles = createStyles(({ css }) => ({
Expand All @@ -30,6 +31,7 @@ const ProviderConfig = memo<ProviderConfigProps>(({ data }) => {
const { styles } = useStyles();
const { t } = useTranslation('discover');
const openSettings = useOpenSettings(SettingsTabs.LLM);
const { showLLM } = useServerConfigStore(featureFlagsSelectors);

const icon = <Icon icon={SquareArrowOutUpRight} size={{ fontSize: 16 }} />;

Expand All @@ -56,13 +58,23 @@ const ProviderConfig = memo<ProviderConfigProps>(({ data }) => {

if (!items || items?.length === 0)
return (
<Button onClick={openSettings} size={'large'} style={{ flex: 1 }} type={'primary'}>
<Button
disabled={!showLLM}
onClick={openSettings}
size={'large'}
style={{ flex: 1 }}
type={'primary'}
>
{t('providers.config')}
</Button>
);

return (
<Dropdown.Button
buttonsRender={(buttons) => {
const [leftButton, rightButton] = buttons as React.ReactElement<ButtonProps>[];
return [{ ...leftButton, props: { ...leftButton.props, disabled: !showLLM } }, rightButton];
}}
className={styles.button}
icon={<Icon icon={ChevronDownIcon} />}
menu={{ items }}
Expand Down
Loading