Skip to content

Commit

Permalink
fix(UI): Fixing DataStore selection bug (#3339)
Browse files Browse the repository at this point in the history
  • Loading branch information
xoscar committed Nov 7, 2023
1 parent 7144a92 commit 540a872
Showing 1 changed file with 12 additions and 7 deletions.
@@ -1,4 +1,5 @@
import {Popover, Tabs} from 'antd';
import {useCallback} from 'react';
import {noop} from 'lodash';
import {useTheme} from 'styled-components';
import {ConfigMode, SupportedDataStores} from 'types/DataStore.types';
Expand All @@ -25,8 +26,17 @@ const DataStoreSelectionInput = ({onChange = noop, value = SupportedDataStores.J
const {dataStoreConfig} = useSettingsValues();
const configuredDataStoreType = dataStoreConfig.defaultDataStore.type;

const handleChange = useCallback(
dataStore => {
const isDisabled = isLocalModeEnabled && dataStore !== SupportedDataStores.Agent;

if (!isDisabled) onChange(dataStore);
},
[isLocalModeEnabled, onChange]
);

return (
<S.DataStoreListContainer tabPosition="left">
<S.DataStoreListContainer tabPosition="left" onChange={handleChange}>
{supportedDataStoreList.map(dataStore => {
if (dataStore === SupportedDataStores.Agent && !getFlag(Flag.IsAgentDataStoreEnabled)) {
return null;
Expand All @@ -40,12 +50,7 @@ const DataStoreSelectionInput = ({onChange = noop, value = SupportedDataStores.J
<Tabs.TabPane
key={dataStore}
tab={
<S.DataStoreItemContainer
$isDisabled={isDisabled}
$isSelected={isSelected}
key={dataStore}
onClick={() => (isDisabled ? noop() : onChange(dataStore))}
>
<S.DataStoreItemContainer $isDisabled={isDisabled} $isSelected={isSelected} key={dataStore}>
<DataStoreIcon dataStoreType={dataStore} color={isSelected ? primary : text} width="22" height="22" />

{isDisabled ? (
Expand Down

0 comments on commit 540a872

Please sign in to comment.