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

[Gitar] Cleaning up stale flag: signals with value false #1668

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
Expand Up @@ -6,9 +6,6 @@ import { JIRA_INFO } from '../../ViewIntegration/JiraIntegration/JiraIntegration
import { StyledCardsGrid } from '../IntegrationList.styles';
import { RequestIntegrationCard } from '../RequestIntegrationCard/RequestIntegrationCard';
import { OFFICIAL_SDKS } from './SDKs';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { useUiFlag } from 'hooks/useUiFlag';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

staging @gitar-bot /skip-cleanup useUiFlag

import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

staging @gitar-bot /skip-cleanup useUiConfig


interface IAvailableIntegrationsProps {
providers: AddonTypeSchema[];
Expand Down Expand Up @@ -54,9 +51,6 @@ const StyledGrayContainer = styled('div')(({ theme }) => ({
export const AvailableIntegrations: VFC<IAvailableIntegrationsProps> = ({
providers,
}) => {
const { isEnterprise } = useUiConfig();
const signalsEnabled = useUiFlag('signals');

const customProviders = [JIRA_INFO];
const serverSdks = OFFICIAL_SDKS.filter((sdk) => sdk.type === 'server');
const clientSdks = OFFICIAL_SDKS.filter((sdk) => sdk.type === 'client');
Expand Down Expand Up @@ -97,17 +91,6 @@ export const AvailableIntegrations: VFC<IAvailableIntegrationsProps> = ({
/>
),
)}
<ConditionallyRender
condition={isEnterprise() && signalsEnabled}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

staging @gitar-bot /skip-cleanup signalsEnabled

show={
<IntegrationCard
icon='signals'
title='Signals'
description='Signal endpoints allow third-party services to send signals to Unleash.'
link='/integrations/signals'
/>
}
/>
{/* TODO: sort providers from backend with custom providers */}
{customProviders?.map(
({ name, displayName, description }) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import { StyledCardsGrid } from '../IntegrationList.styles';
import { IntegrationCard } from '../IntegrationCard/IntegrationCard';
import type { VFC } from 'react';
import { Typography, styled } from '@mui/material';
import { useSignalEndpoints } from 'hooks/api/getters/useSignalEndpoints/useSignalEndpoints';
import { useUiFlag } from 'hooks/useUiFlag';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';

const StyledConfiguredSection = styled('section')(({ theme }) => ({
display: 'flex',
Expand All @@ -27,10 +23,6 @@ export const ConfiguredIntegrations: VFC<ConfiguredIntegrationsProps> = ({
addons,
providers,
}) => {
const { signalEndpoints } = useSignalEndpoints();
const signalsEnabled = useUiFlag('signals');
const { isEnterprise } = useUiConfig();

const ref = useLoading(loading || false);

return (
Expand Down Expand Up @@ -73,27 +65,6 @@ export const ConfiguredIntegrations: VFC<ConfiguredIntegrationsProps> = ({
/>
);
})}
<ConditionallyRender
condition={
isEnterprise() &&
signalsEnabled &&
signalEndpoints.length > 0
}
show={
<IntegrationCard
variant='stacked'
icon='signals'
title='Signals'
description={`${
signalEndpoints.length
} signal endpoint${
signalEndpoints.length === 1 ? '' : 's'
} configured`}
link='/integrations/signals'
configureActionText='View signal endpoints'
/>
}
/>
</StyledCardsGrid>
</StyledConfiguredSection>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type { ReactNode } from 'react';
import { useUiFlag } from 'hooks/useUiFlag';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import { useLocalStorageState } from 'hooks/useLocalStorageState';
import {
Badge,
Expand Down Expand Up @@ -86,16 +84,13 @@ interface INewInUnleashProps {

export const NewInUnleash = ({
mode = 'full',
onItemClick,
onMiniModeClick,
}: INewInUnleashProps) => {
const { trackEvent } = usePlausibleTracker();
const [seenItems, setSeenItems] = useLocalStorageState(
'new-in-unleash-seen:v1',
new Set(),
);
const { isEnterprise } = useUiConfig();
const signalsEnabled = useUiFlag('signals');

const items: NewItem[] = [
{
Expand All @@ -105,7 +100,7 @@ export const NewInUnleash = ({
preview: <SignalsPreview />,
link: '/integrations/signals',
docsLink: 'https://docs.getunleash.io/reference/signals',
show: isEnterprise() && signalsEnabled,
show: false,
longDescription: (
<>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ import useSWRInfinite, {
type SWRInfiniteConfiguration,
type SWRInfiniteKeyLoader,
} from 'swr/infinite';
import { formatApiPath } from 'utils/formatPath';
import handleErrorResponses from '../httpErrorResponseHandler';
import useUiConfig from '../useUiConfig/useUiConfig';
import type { ISignalEndpointSignal } from 'interfaces/signal';
import { useUiFlag } from 'hooks/useUiFlag';

const ENDPOINT = 'api/admin/signal-endpoints';

type SignalsResponse = {
signalEndpointSignals: ISignalEndpointSignal[];
Expand All @@ -25,25 +20,12 @@ export const useSignalEndpointSignals = (
limit = 50,
options: SWRInfiniteConfiguration = {},
) => {
const { isEnterprise } = useUiConfig();
const signalsEnabled = useUiFlag('signals');

const getKey: SWRInfiniteKeyLoader = (
pageIndex: number,
previousPageData: SignalsResponse,
) => {
// Does not meet conditions
if (!signalEndpointId || !isEnterprise || !signalsEnabled) return null;

// Reached the end
if (previousPageData && !previousPageData.signalEndpointSignals.length)
return null;

return formatApiPath(
`${ENDPOINT}/${signalEndpointId}/signals?limit=${limit}&offset=${
pageIndex * limit
}`,
);
return null;
};

const { data, error, size, setSize, mutate } =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { useMemo } from 'react';
import { formatApiPath } from 'utils/formatPath';
import handleErrorResponses from '../httpErrorResponseHandler';
import { useConditionalSWR } from '../useConditionalSWR/useConditionalSWR';
import useUiConfig from '../useUiConfig/useUiConfig';
import type { ISignalEndpointToken } from 'interfaces/signal';
import { useUiFlag } from 'hooks/useUiFlag';

const ENDPOINT = 'api/admin/signal-endpoints';

Expand All @@ -13,13 +11,10 @@ const DEFAULT_DATA = {
};

export const useSignalEndpointTokens = (signalEndpointId: number) => {
const { isEnterprise } = useUiConfig();
const signalsEnabled = useUiFlag('signals');

const { data, error, mutate } = useConditionalSWR<{
signalEndpointTokens: ISignalEndpointToken[];
}>(
isEnterprise() && signalsEnabled,
false,
DEFAULT_DATA,
formatApiPath(`${ENDPOINT}/${signalEndpointId}/tokens`),
fetcher,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import { useContext, useMemo } from 'react';
import { formatApiPath } from 'utils/formatPath';
import handleErrorResponses from '../httpErrorResponseHandler';
import { useConditionalSWR } from '../useConditionalSWR/useConditionalSWR';
import useUiConfig from '../useUiConfig/useUiConfig';
import type { ISignalEndpoint } from 'interfaces/signal';
import { useUiFlag } from 'hooks/useUiFlag';
import AccessContext from 'contexts/AccessContext';

const ENDPOINT = 'api/admin/signal-endpoints';

Expand All @@ -14,18 +11,9 @@ const DEFAULT_DATA = {
};

export const useSignalEndpoints = () => {
const { isAdmin } = useContext(AccessContext);
const { isEnterprise } = useUiConfig();
const signalsEnabled = useUiFlag('signals');

const { data, error, mutate } = useConditionalSWR<{
signalEndpoints: ISignalEndpoint[];
}>(
isEnterprise() && isAdmin && signalsEnabled,
DEFAULT_DATA,
formatApiPath(ENDPOINT),
fetcher,
);
}>(false, DEFAULT_DATA, formatApiPath(ENDPOINT), fetcher);

return useMemo(
() => ({
Expand Down
1 change: 0 additions & 1 deletion frontend/src/interfaces/uiConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export type UiFlags = {
doraMetrics?: boolean;
dependentFeatures?: boolean;
newStrategyConfiguration?: boolean;
signals?: boolean;
automatedActions?: boolean;
celebrateUnleash?: boolean;
featureSearchFeedback?: Variant;
Expand Down
5 changes: 0 additions & 5 deletions src/lib/types/experimental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export type IFlagKey =
| 'filterInvalidClientMetrics'
| 'disableMetrics'
| 'stripHeadersOnAPI'
| 'signals'
| 'automatedActions'
| 'celebrateUnleash'
| 'featureSearchFeedback'
Expand Down Expand Up @@ -137,10 +136,6 @@ const flags: IFlags = {
process.env.UNLEASH_EXPERIMENTAL_DISABLE_METRICS,
false,
),
signals: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_SIGNALS,
false,
),
automatedActions: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_AUTOMATED_ACTIONS,
false,
Expand Down
Loading