Skip to content

Commit

Permalink
Merge branch 'main' into melinda/add-availability-page
Browse files Browse the repository at this point in the history
  • Loading branch information
melindafekete committed Nov 4, 2024
2 parents 713623e + 2e99452 commit 5f1de88
Show file tree
Hide file tree
Showing 69 changed files with 1,449 additions and 423 deletions.
8 changes: 6 additions & 2 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"a11y": {
"useSemanticElements": "off"
},
"correctness": {
"noUnsafeOptionalChaining": "off",
"useExhaustiveDependencies": "off",
Expand All @@ -15,7 +18,8 @@
"noUselessConstructor": "off",
"useOptionalChain": "warn",
"noStaticOnlyClass": "off",
"noForEach": "off"
"noForEach": "off",
"noUselessFragments": "off"
},
"style": {
"noNonNullAssertion": "off",
Expand Down
16 changes: 8 additions & 8 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"gen:api:clean": "yarn gen:api && rm -rf src/openapi/apis && sed -i.bak '1q' src/openapi/index.ts && rm src/openapi/index.ts.bak"
},
"devDependencies": {
"@biomejs/biome": "1.8.3",
"@biomejs/biome": "1.9.4",
"@codemirror/lang-json": "6.0.1",
"@emotion/react": "11.11.4",
"@emotion/styled": "11.11.5",
Expand All @@ -53,20 +53,20 @@
"@types/css-mediaquery": "^0.1.4",
"@types/debounce": "1.2.4",
"@types/deep-diff": "1.0.5",
"@types/jest": "29.5.13",
"@types/jest": "29.5.14",
"@types/lodash.clonedeep": "4.5.9",
"@types/lodash.isequal": "^4.5.8",
"@types/lodash.mapvalues": "^4.6.9",
"@types/lodash.omit": "4.5.9",
"@types/node": "^20.12.12",
"@types/react": "18.3.11",
"@types/react": "18.3.12",
"@types/react-dom": "18.3.1",
"@types/react-router-dom": "5.3.3",
"@types/react-table": "7.7.20",
"@types/react-test-renderer": "18.3.0",
"@types/semver": "7.5.8",
"@types/uuid": "^9.0.0",
"@uiw/codemirror-theme-duotone": "4.23.5",
"@uiw/codemirror-theme-duotone": "4.23.6",
"@uiw/react-codemirror": "4.23.5",
"@vitejs/plugin-react": "4.3.3",
"cartesian": "^1.0.1",
Expand All @@ -77,7 +77,7 @@
"copy-to-clipboard": "3.3.3",
"countries-and-timezones": "^3.4.0",
"css-mediaquery": "^0.1.2",
"cypress": "13.15.0",
"cypress": "13.15.1",
"cypress-vite": "^1.4.0",
"date-fns": "2.30.0",
"date-fns-tz": "^2.0.0",
Expand All @@ -93,7 +93,7 @@
"lodash.mapvalues": "^4.6.0",
"lodash.omit": "4.5.0",
"millify": "^6.0.0",
"msw": "2.5.0",
"msw": "2.5.1",
"orval": "^6.31.0",
"pkginfo": "0.4.1",
"plausible-tracker": "0.3.9",
Expand All @@ -111,7 +111,7 @@
"react-router-dom": "6.16.0",
"react-table": "7.8.0",
"react-test-renderer": "18.3.1",
"sass": "1.80.3",
"sass": "1.80.4",
"semver": "7.6.3",
"swr": "2.2.5",
"tss-react": "4.9.13",
Expand All @@ -133,7 +133,7 @@
"vite": "5.4.10",
"semver": "7.6.3",
"ws": "^8.18.0",
"@types/react": "18.3.11"
"@types/react": "18.3.12"
},
"jest": {
"moduleNameMapper": {
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/assets/icons/projectStatus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions frontend/src/assets/img/aiPreview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion frontend/src/component/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { InternalBanners } from './banners/internalBanners/InternalBanners';
import { ExternalBanners } from './banners/externalBanners/ExternalBanners';
import { LicenseBanner } from './banners/internalBanners/LicenseBanner';
import { Demo } from './demo/Demo';
import { LoginRedirect } from './common/LoginRedirect/LoginRedirect';

const StyledContainer = styled('div')(() => ({
'& ul': {
Expand All @@ -47,6 +48,8 @@ export const App = () => {
}
}, [authDetails, user]);

const isLoggedIn = Boolean(user?.id);

return (
<SWRProvider>
<Suspense fallback={<Loader type='fullscreen' />}>
Expand Down Expand Up @@ -92,7 +95,13 @@ export const App = () => {
/>
<Route
path='*'
element={<NotFound />}
element={
isLoggedIn ? (
<NotFound />
) : (
<LoginRedirect />
)
}
/>
</Routes>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
} from 'hooks/useTrafficData';
import { customHighlightPlugin } from 'component/common/Chart/customHighlightPlugin';
import { formatTickValue } from 'component/common/Chart/formatTickValue';
import { useTrafficLimit } from './hooks/useTrafficLimit';

const StyledBox = styled(Box)(({ theme }) => ({
display: 'grid',
Expand Down Expand Up @@ -136,13 +137,11 @@ const createBarChartOptions = (
},
});

const proPlanIncludedRequests = 53_000_000;

export const NetworkTrafficUsage: VFC = () => {
usePageTitle('Network - Data Usage');
const theme = useTheme();

const { isOss, isPro } = useUiConfig();
const { isOss } = useUiConfig();

const {
record,
Expand All @@ -157,7 +156,7 @@ export const NetworkTrafficUsage: VFC = () => {
calculateEstimatedMonthlyCost,
} = useTrafficDataEstimation();

const includedTraffic = isPro() ? proPlanIncludedRequests : 0;
const includedTraffic = useTrafficLimit();

const options = useMemo(() => {
return createBarChartOptions(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { renderHook } from '@testing-library/react';
import { useTrafficLimit } from './useTrafficLimit';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import { useUiFlag } from 'hooks/useUiFlag';
import { vi, describe, it, expect } from 'vitest';

vi.mock('hooks/api/getters/useUiConfig/useUiConfig');
vi.mock('hooks/useUiFlag');

describe('useTrafficLimit', () => {
it('should return requests limit if user is on pro plan', () => {
vi.mocked(useUiConfig).mockReturnValue({
isPro: () => true,
isEnterprise: () => false,
uiConfig: {
billing: 'pay-as-you-go',
},
} as any);
vi.mocked(useUiFlag).mockReturnValue(false);

const { result } = renderHook(() => useTrafficLimit());

expect(result.current).toBe(53_000_000);
});

it('should return PAYG plan requests limit if enterprise-payg is enabled and billing is pay-as-you-go', () => {
vi.mocked(useUiConfig).mockReturnValue({
isPro: () => false,
isEnterprise: () => true,
uiConfig: { billing: 'pay-as-you-go' },
} as any);
vi.mocked(useUiFlag).mockReturnValue(true);

const { result } = renderHook(() => useTrafficLimit());

expect(result.current).toBe(53_000_000);
});

it('should return 0 if user is not on pro plan and pay-as-you-go conditions are not met', () => {
vi.mocked(useUiConfig).mockReturnValue({
isPro: () => false,
isEnterprise: () => false,
uiConfig: {},
} as any);
vi.mocked(useUiFlag).mockReturnValue(false);

const { result } = renderHook(() => useTrafficLimit());

expect(result.current).toBe(0);
});

it('should return 0 if user is not on pro plan and flag is disabled', () => {
vi.mocked(useUiConfig).mockReturnValue({
isPro: () => false,
isEnterprise: () => true,
uiConfig: { billing: 'pay-as-you-go' },
} as any);
vi.mocked(useUiFlag).mockReturnValue(false);

const { result } = renderHook(() => useTrafficLimit());

expect(result.current).toBe(0);
});

it('should return 0 if enterprise PAYG is enabled but billing is not pay-as-you-go', () => {
vi.mocked(useUiConfig).mockReturnValue({
isPro: () => false,
isEnterprise: () => false,
uiConfig: { billing: 'subscription' },
} as any);
vi.mocked(useUiFlag).mockReturnValue(true);

const { result } = renderHook(() => useTrafficLimit());

expect(result.current).toBe(0);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import { useUiFlag } from 'hooks/useUiFlag';

const proPlanIncludedRequests = 53_000_000;
const paygPlanIncludedRequests = proPlanIncludedRequests;

export const useTrafficLimit = () => {
const { isPro, isEnterprise, uiConfig } = useUiConfig();
const isEnterprisePaygEnabled = useUiFlag('enterprise-payg');

if (isPro()) {
return proPlanIncludedRequests;
}

if (
isEnterprisePaygEnabled &&
isEnterprise() &&
uiConfig.billing === 'pay-as-you-go'
) {
return paygPlanIncludedRequests;
}

return 0;
};
30 changes: 16 additions & 14 deletions frontend/src/component/ai/AIChat.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { mutate } from 'swr';
import { ReactComponent as AIIcon } from 'assets/icons/AI.svg';
import { IconButton, styled, useMediaQuery } from '@mui/material';
import { IconButton, styled, Tooltip, useMediaQuery } from '@mui/material';
import { useEffect, useRef, useState } from 'react';
import useToast from 'hooks/useToast';
import { formatUnknownError } from 'utils/formatUnknownError';
Expand Down Expand Up @@ -198,19 +198,21 @@ export const AIChat = () => {
if (!open) {
return (
<StyledAIIconContainer demoStepsVisible={demoStepsVisible}>
<StyledAIIconButton
size='large'
onClick={() => {
trackEvent('unleash-ai-chat', {
props: {
eventType: 'open',
},
});
setOpen(true);
}}
>
<AIIcon />
</StyledAIIconButton>
<Tooltip arrow title='Unleash AI'>
<StyledAIIconButton
size='large'
onClick={() => {
trackEvent('unleash-ai-chat', {
props: {
eventType: 'open',
},
});
setOpen(true);
}}
>
<AIIcon />
</StyledAIIconButton>
</Tooltip>
</StyledAIIconContainer>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ test('Preview parent feature', async () => {
feature='featureA'
project='default'
type='release'
archivedAt={null}
searchQuery=''
dependencyType='child'
onTypeClick={() => {}}
Expand Down Expand Up @@ -44,6 +45,7 @@ test('Preview child features', async () => {
feature='featureA'
project='default'
type='release'
archivedAt={null}
searchQuery=''
dependencyType='parent'
onTypeClick={() => {}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ test('Display full overview information', () => {
type: 'release',
dependencyType: 'child',
project: 'my_project',
archivedAt: null,
},
}}
/>,
Expand Down Expand Up @@ -54,6 +55,7 @@ test('Display minimal overview information', () => {
type: '',
dependencyType: null,
project: 'my_project',
archivedAt: null,
},
}}
/>,
Expand All @@ -65,3 +67,26 @@ test('Display minimal overview information', () => {
'/projects/my_project/features/my_feature',
);
});

test('show archived information', () => {
const FeatureOverviewCell = makeFeatureOverviewCell(noOp, noOp);

render(
<FeatureOverviewCell
row={{
original: {
name: 'archived_feature',
tags: [],
description: '',
type: '',
dependencyType: null,
project: 'my_project',
archivedAt: '2024-11-09',
},
}}
/>,
);

expect(screen.getByText('archived_feature')).toBeInTheDocument();
expect(screen.getByText('Archived')).toBeInTheDocument();
});
Loading

0 comments on commit 5f1de88

Please sign in to comment.