mirror of
https://github.com/Unleash/unleash.git
synced 2025-08-13 13:48:59 +02:00
load cards into grid
This commit is contained in:
parent
839a1d0104
commit
7b0fbb22d6
@ -19,22 +19,10 @@ import { ActionCell } from 'component/common/Table/cells/ActionCell/ActionCell';
|
||||
import { ConfigureAddonsButton } from './ConfigureAddonButton/ConfigureAddonsButton';
|
||||
import { IntegrationIcon } from '../IntegrationIcon/IntegrationIcon';
|
||||
import { IntegrationNameCell } from '../IntegrationNameCell/IntegrationNameCell';
|
||||
import { IAddonInstallation } from 'interfaces/addons';
|
||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||
|
||||
interface IProvider {
|
||||
name: string;
|
||||
displayName: string;
|
||||
description: string;
|
||||
documentationUrl: string;
|
||||
parameters: object[];
|
||||
events: string[];
|
||||
installation?: IAddonInstallation;
|
||||
deprecated?: string;
|
||||
}
|
||||
import type { AddonTypeSchema } from 'openapi';
|
||||
|
||||
interface IAvailableAddonsProps {
|
||||
providers: IProvider[];
|
||||
providers: AddonTypeSchema[];
|
||||
loading: boolean;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,34 @@
|
||||
import { type VFC } from 'react';
|
||||
import type { AddonTypeSchema } from 'openapi';
|
||||
import { PageContent } from 'component/common/PageContent/PageContent';
|
||||
import { VFC } from 'react';
|
||||
import { PageHeader } from 'component/common/PageHeader/PageHeader';
|
||||
import { IntegrationCard } from '../IntegrationCard/IntegrationCard';
|
||||
import { styled } from '@mui/material';
|
||||
|
||||
interface IAvailableIntegrationsProps {}
|
||||
interface IAvailableIntegrationsProps {
|
||||
providers: AddonTypeSchema[];
|
||||
}
|
||||
|
||||
export const AvailableIntegrations: VFC<IAvailableIntegrationsProps> = () => {
|
||||
return <PageContent>Available integrations</PageContent>;
|
||||
const StyledGrid = styled('div')(({ theme }) => ({
|
||||
gridTemplateColumns: 'repeat(auto-fit, minmax(350px, 1fr))',
|
||||
gap: theme.spacing(2),
|
||||
display: 'grid',
|
||||
}));
|
||||
|
||||
export const AvailableIntegrations: VFC<IAvailableIntegrationsProps> = ({
|
||||
providers,
|
||||
}) => {
|
||||
return (
|
||||
<PageContent header={<PageHeader title="Available integrations" />}>
|
||||
<StyledGrid>
|
||||
{providers?.map(({ name, displayName, description }) => (
|
||||
<IntegrationCard
|
||||
key={name}
|
||||
title={displayName || name}
|
||||
description={description}
|
||||
/>
|
||||
))}
|
||||
</StyledGrid>
|
||||
</PageContent>
|
||||
);
|
||||
};
|
||||
|
@ -0,0 +1,30 @@
|
||||
import { VFC } from 'react';
|
||||
import { Box, styled, Typography } from '@mui/material';
|
||||
|
||||
interface IIntegrationCardProps {
|
||||
title: string;
|
||||
description?: string;
|
||||
isEnabled?: boolean;
|
||||
isDeprecated?: boolean;
|
||||
}
|
||||
|
||||
const StyledBox = styled(Box)(({ theme }) => ({
|
||||
padding: theme.spacing(2),
|
||||
borderRadius: `${theme.shape.borderRadiusMedium}px`,
|
||||
border: `1px solid ${theme.palette.divider}`,
|
||||
boxShadow: theme.shadows[1],
|
||||
}));
|
||||
|
||||
export const IntegrationCard: VFC<IIntegrationCardProps> = ({
|
||||
title,
|
||||
description,
|
||||
isDeprecated,
|
||||
isEnabled,
|
||||
}) => {
|
||||
return (
|
||||
<StyledBox>
|
||||
<Typography variant="h3">{title}</Typography>
|
||||
<Typography variant="body1">{description}</Typography>
|
||||
</StyledBox>
|
||||
);
|
||||
};
|
@ -18,7 +18,7 @@ export const IntegrationList = () => {
|
||||
/>
|
||||
<ConditionallyRender
|
||||
condition={integrationsRework}
|
||||
show={<AvailableIntegrations />}
|
||||
show={<AvailableIntegrations providers={providers} />}
|
||||
elseShow={
|
||||
<AvailableAddons loading={loading} providers={providers} />
|
||||
}
|
||||
|
@ -2,12 +2,7 @@ import useSWR, { mutate, SWRConfiguration } from 'swr';
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { formatApiPath } from 'utils/formatPath';
|
||||
import handleErrorResponses from '../httpErrorResponseHandler';
|
||||
import { IAddon, IAddonProvider } from 'interfaces/addons';
|
||||
|
||||
interface IAddonsResponse {
|
||||
addons: IAddon[];
|
||||
providers: IAddonProvider[];
|
||||
}
|
||||
import { AddonsSchema } from 'openapi';
|
||||
|
||||
const useAddons = (options: SWRConfiguration = {}) => {
|
||||
const fetcher = async () => {
|
||||
@ -20,7 +15,7 @@ const useAddons = (options: SWRConfiguration = {}) => {
|
||||
|
||||
const KEY = `api/admin/addons`;
|
||||
|
||||
const { data, error } = useSWR<IAddonsResponse>(KEY, fetcher, options);
|
||||
const { data, error } = useSWR<AddonsSchema>(KEY, fetcher, options);
|
||||
const [loading, setLoading] = useState(!error && !data);
|
||||
|
||||
const refetchAddons = useCallback(() => {
|
||||
|
@ -1,29 +1,3 @@
|
||||
import { ITagType } from './tags';
|
||||
|
||||
export interface IAddon {
|
||||
provider: string;
|
||||
parameters: Record<string, any>;
|
||||
id: number;
|
||||
events: string[];
|
||||
projects?: string[];
|
||||
environments?: string[];
|
||||
enabled: boolean;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface IAddonProvider {
|
||||
description: string;
|
||||
displayName: string;
|
||||
documentationUrl: string;
|
||||
events: string[];
|
||||
name: string;
|
||||
parameters: IAddonProviderParams[];
|
||||
tagTypes: ITagType[];
|
||||
installation?: IAddonInstallation;
|
||||
alerts?: IAddonAlert[];
|
||||
deprecated?: string;
|
||||
}
|
||||
|
||||
export interface IAddonInstallation {
|
||||
url: string;
|
||||
warning?: string;
|
||||
|
Loading…
Reference in New Issue
Block a user