mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
feat: project level outdated sdks, project level banner (#7083)
At first, I was creating a new component, Project Banner, which was 90% of the old banner and 10% new code, but it did not feel right. The current banner is actually smart enough to be used in any container. So now, I have moved the outdated SDK banner to the project level. I like the simplicity of the change. ![image](https://github.com/Unleash/unleash/assets/964450/e57c1ace-e8f9-4866-a063-6f9ae561c6c0)
This commit is contained in:
parent
659b3391c3
commit
17e340ab40
@ -22,8 +22,6 @@ import { ExternalBanners } from './banners/externalBanners/ExternalBanners';
|
|||||||
import { EdgeUpgradeBanner } from './banners/EdgeUpgradeBanner/EdgeUpgradeBanner';
|
import { EdgeUpgradeBanner } from './banners/EdgeUpgradeBanner/EdgeUpgradeBanner';
|
||||||
import { LicenseBanner } from './banners/internalBanners/LicenseBanner';
|
import { LicenseBanner } from './banners/internalBanners/LicenseBanner';
|
||||||
import { Demo } from './demo/Demo';
|
import { Demo } from './demo/Demo';
|
||||||
import { OutdatedSdksBanner } from './banners/OutdatedSdksBanner/OutdatedSdksBanner';
|
|
||||||
import { useUiFlag } from '../hooks/useUiFlag';
|
|
||||||
|
|
||||||
const StyledContainer = styled('div')(() => ({
|
const StyledContainer = styled('div')(() => ({
|
||||||
'& ul': {
|
'& ul': {
|
||||||
@ -50,8 +48,6 @@ export const App = () => {
|
|||||||
}
|
}
|
||||||
}, [authDetails, user]);
|
}, [authDetails, user]);
|
||||||
|
|
||||||
const outdatedSdksBannerEnabled = useUiFlag('outdatedSdksBanner');
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SWRProvider>
|
<SWRProvider>
|
||||||
<Suspense fallback={<Loader />}>
|
<Suspense fallback={<Loader />}>
|
||||||
@ -71,10 +67,6 @@ export const App = () => {
|
|||||||
<ExternalBanners />
|
<ExternalBanners />
|
||||||
<InternalBanners />
|
<InternalBanners />
|
||||||
<EdgeUpgradeBanner />
|
<EdgeUpgradeBanner />
|
||||||
<ConditionallyRender
|
|
||||||
condition={outdatedSdksBannerEnabled}
|
|
||||||
show={<OutdatedSdksBanner />}
|
|
||||||
/>
|
|
||||||
<StyledContainer>
|
<StyledContainer>
|
||||||
<ToastRenderer />
|
<ToastRenderer />
|
||||||
<Routes>
|
<Routes>
|
||||||
|
@ -7,7 +7,11 @@ import { OutdatedSdksBanner } from './OutdatedSdksBanner';
|
|||||||
const server = testServerSetup();
|
const server = testServerSetup();
|
||||||
|
|
||||||
const setupApi = (outdatedSdks: OutdatedSdksSchema) => {
|
const setupApi = (outdatedSdks: OutdatedSdksSchema) => {
|
||||||
testServerRoute(server, '/api/admin/metrics/sdks/outdated', outdatedSdks);
|
testServerRoute(
|
||||||
|
server,
|
||||||
|
'/api/admin/projects/default/sdks/outdated',
|
||||||
|
outdatedSdks,
|
||||||
|
);
|
||||||
testServerRoute(server, '/api/admin/ui-config', {
|
testServerRoute(server, '/api/admin/ui-config', {
|
||||||
flags: {
|
flags: {
|
||||||
outdatedSdksBanner: true,
|
outdatedSdksBanner: true,
|
||||||
@ -24,7 +28,7 @@ test('Show outdated SDKs and apps using them', async () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
render(<OutdatedSdksBanner />);
|
render(<OutdatedSdksBanner project={'default'} />);
|
||||||
|
|
||||||
const link = await screen.findByText('Please update those versions');
|
const link = await screen.findByText('Please update those versions');
|
||||||
|
|
||||||
|
@ -8,10 +8,14 @@ import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
|||||||
|
|
||||||
const StyledList = styled('ul')({ margin: 0 });
|
const StyledList = styled('ul')({ margin: 0 });
|
||||||
|
|
||||||
export const OutdatedSdksBanner = () => {
|
interface IOutdatedSdksBannerProps {
|
||||||
|
project: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const OutdatedSdksBanner = ({ project }: IOutdatedSdksBannerProps) => {
|
||||||
const {
|
const {
|
||||||
data: { sdks },
|
data: { sdks },
|
||||||
} = useOutdatedSdks();
|
} = useOutdatedSdks(project);
|
||||||
const { trackEvent } = usePlausibleTracker();
|
const { trackEvent } = usePlausibleTracker();
|
||||||
|
|
||||||
const applicationClickedWithVersion = (sdkVersion: string) => {
|
const applicationClickedWithVersion = (sdkVersion: string) => {
|
||||||
@ -73,7 +77,7 @@ export const OutdatedSdksBanner = () => {
|
|||||||
<>
|
<>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={sdks.length > 0}
|
condition={sdks.length > 0}
|
||||||
show={<Banner banner={outdatedSdksBanner} />}
|
show={<Banner banner={outdatedSdksBanner} inline />}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -8,6 +8,9 @@ import useProjectOverview, {
|
|||||||
import { usePageTitle } from 'hooks/usePageTitle';
|
import { usePageTitle } from 'hooks/usePageTitle';
|
||||||
import { useLastViewedProject } from 'hooks/useLastViewedProject';
|
import { useLastViewedProject } from 'hooks/useLastViewedProject';
|
||||||
import { ProjectOverviewChangeRequests } from './ProjectOverviewChangeRequests';
|
import { ProjectOverviewChangeRequests } from './ProjectOverviewChangeRequests';
|
||||||
|
import { OutdatedSdksBanner } from '../../banners/OutdatedSdksBanner/OutdatedSdksBanner';
|
||||||
|
import { useUiFlag } from '../../../hooks/useUiFlag';
|
||||||
|
import { ConditionallyRender } from '../../common/ConditionallyRender/ConditionallyRender';
|
||||||
|
|
||||||
const refreshInterval = 15 * 1000;
|
const refreshInterval = 15 * 1000;
|
||||||
|
|
||||||
@ -36,6 +39,8 @@ const ProjectOverview: FC = () => {
|
|||||||
const projectId = useRequiredPathParam('projectId');
|
const projectId = useRequiredPathParam('projectId');
|
||||||
const projectName = useProjectOverviewNameOrId(projectId);
|
const projectName = useProjectOverviewNameOrId(projectId);
|
||||||
|
|
||||||
|
const outdatedSdksBannerEnabled = useUiFlag('outdatedSdksBanner');
|
||||||
|
|
||||||
const { project } = useProjectOverview(projectId, {
|
const { project } = useProjectOverview(projectId, {
|
||||||
refreshInterval,
|
refreshInterval,
|
||||||
});
|
});
|
||||||
@ -50,6 +55,10 @@ const ProjectOverview: FC = () => {
|
|||||||
<StyledContainer key={projectId}>
|
<StyledContainer key={projectId}>
|
||||||
<StyledContentContainer>
|
<StyledContentContainer>
|
||||||
<ProjectOverviewChangeRequests project={projectId} />
|
<ProjectOverviewChangeRequests project={projectId} />
|
||||||
|
<ConditionallyRender
|
||||||
|
condition={outdatedSdksBannerEnabled}
|
||||||
|
show={<OutdatedSdksBanner project={projectId} />}
|
||||||
|
/>
|
||||||
|
|
||||||
<StyledProjectToggles>
|
<StyledProjectToggles>
|
||||||
<ProjectFeatureToggles
|
<ProjectFeatureToggles
|
||||||
|
@ -2,9 +2,8 @@ import { fetcher, useApiGetter } from '../useApiGetter/useApiGetter';
|
|||||||
import type { OutdatedSdksSchema } from '../../../../openapi';
|
import type { OutdatedSdksSchema } from '../../../../openapi';
|
||||||
import { formatApiPath } from 'utils/formatPath';
|
import { formatApiPath } from 'utils/formatPath';
|
||||||
|
|
||||||
const PATH = 'api/admin/metrics/sdks/outdated';
|
export const useOutdatedSdks = (project: string) => {
|
||||||
|
const PATH = `api/admin/projects/${project}/sdks/outdated`;
|
||||||
export const useOutdatedSdks = () => {
|
|
||||||
const { data, refetch, loading, error } = useApiGetter<OutdatedSdksSchema>(
|
const { data, refetch, loading, error } = useApiGetter<OutdatedSdksSchema>(
|
||||||
formatApiPath(PATH),
|
formatApiPath(PATH),
|
||||||
() => fetcher(formatApiPath(PATH), 'Outdated SDKs'),
|
() => fetcher(formatApiPath(PATH), 'Outdated SDKs'),
|
||||||
|
Loading…
Reference in New Issue
Block a user