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

feat(web): support disabled data stores #3184

Merged
merged 2 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ interface IProps {
children: React.ReactNode;
}

const flagValues = {[Flag.IsAnalyticsPageEnabled]: true, [Flag.IsAgentDataStoreEnabled]: false};
const flagValues = {
[Flag.IsAnalyticsPageEnabled]: true,
[Flag.IsAgentDataStoreEnabled]: false,
[Flag.IsLocalModeEnabled]: false,
};

const getComponent = <T,>(id: string, fallback: React.ComponentType<T>) => fallback;
const getFlag = (flag: Flag) => flagValues[flag];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import styled from 'styled-components';
import styled, {css} from 'styled-components';
import {Typography} from 'antd';
import {CheckCircleOutlined} from '@ant-design/icons';

Expand Down Expand Up @@ -34,13 +34,20 @@ export const DataStoreListContainer = styled.div`
flex-direction: column;
`;

export const DataStoreItemContainer = styled.div<{$isSelected: boolean}>`
export const DataStoreItemContainer = styled.div<{$isDisabled: boolean; $isSelected: boolean}>`
display: flex;
align-items: center;
gap: 10px;
padding: 12px 22px;
cursor: pointer;
border-left: ${({theme, $isSelected}) => $isSelected && `2px solid ${theme.color.primary}`};

${({$isDisabled}) =>
$isDisabled &&
css`
cursor: not-allowed;
opacity: 0.5;
`}
`;

export const Circle = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const supportedDataStoreList = Object.values(SupportedDataStores);

const DataStoreSelectionInput = ({onChange = noop, value = SupportedDataStores.JAEGER}: IProps) => {
const {getFlag} = useCustomization();
const isLocalModeEnabled = getFlag(Flag.IsLocalModeEnabled);
const {
color: {text, primary},
} = useTheme();
Expand All @@ -33,10 +34,32 @@ const DataStoreSelectionInput = ({onChange = noop, value = SupportedDataStores.J

const isSelected = value === dataStore;
const isConfigured = configuredDataStoreType === dataStore && dataStoreConfig.mode === ConfigMode.READY;
const isDisabled = isLocalModeEnabled && dataStore !== SupportedDataStores.Agent;
return (
<S.DataStoreItemContainer $isSelected={isSelected} key={dataStore} onClick={() => onChange(dataStore)}>
<S.DataStoreItemContainer
$isDisabled={isDisabled}
$isSelected={isSelected}
key={dataStore}
onClick={() => (isDisabled ? noop() : onChange(dataStore))}
>
<DataStoreIcon dataStoreType={dataStore} color={isSelected ? primary : text} width="22" height="22" />
<S.DataStoreName $isSelected={isSelected}>{SupportedDataStoresToName[dataStore]}</S.DataStoreName>

{isDisabled ? (
<Popover
content={
<div>
In localMode only the Agent data store can be used. <br /> If you want to connect to a different
data store <br /> please create a new environment
</div>
}
placement="right"
>
<S.DataStoreName $isSelected={isSelected}>{SupportedDataStoresToName[dataStore]}</S.DataStoreName>
</Popover>
) : (
<S.DataStoreName $isSelected={isSelected}>{SupportedDataStoresToName[dataStore]}</S.DataStoreName>
)}

{isConfigured && (
<Popover content="This data source is currently configured" placement="right">
<S.InfoIcon />
Expand Down
1 change: 1 addition & 0 deletions web/src/providers/Customization/Customization.provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export enum Operation {
export enum Flag {
IsAnalyticsPageEnabled = 'isAnalyticsPageEnabled',
IsAgentDataStoreEnabled = 'isAgentDataStoreEnabled',
IsLocalModeEnabled = 'isLocalModeEnabled',
}

interface IContext {
Expand Down