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 { ConfigureAddonsButton } from './ConfigureAddonButton/ConfigureAddonsButton';
|
||||||
import { IntegrationIcon } from '../IntegrationIcon/IntegrationIcon';
|
import { IntegrationIcon } from '../IntegrationIcon/IntegrationIcon';
|
||||||
import { IntegrationNameCell } from '../IntegrationNameCell/IntegrationNameCell';
|
import { IntegrationNameCell } from '../IntegrationNameCell/IntegrationNameCell';
|
||||||
import { IAddonInstallation } from 'interfaces/addons';
|
import type { AddonTypeSchema } from 'openapi';
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IAvailableAddonsProps {
|
interface IAvailableAddonsProps {
|
||||||
providers: IProvider[];
|
providers: AddonTypeSchema[];
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,34 @@
|
|||||||
|
import { type VFC } from 'react';
|
||||||
|
import type { AddonTypeSchema } from 'openapi';
|
||||||
import { PageContent } from 'component/common/PageContent/PageContent';
|
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> = () => {
|
const StyledGrid = styled('div')(({ theme }) => ({
|
||||||
return <PageContent>Available integrations</PageContent>;
|
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
|
<ConditionallyRender
|
||||||
condition={integrationsRework}
|
condition={integrationsRework}
|
||||||
show={<AvailableIntegrations />}
|
show={<AvailableIntegrations providers={providers} />}
|
||||||
elseShow={
|
elseShow={
|
||||||
<AvailableAddons loading={loading} providers={providers} />
|
<AvailableAddons loading={loading} providers={providers} />
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,7 @@ import useSWR, { mutate, SWRConfiguration } from 'swr';
|
|||||||
import { useState, useEffect, useCallback } from 'react';
|
import { useState, useEffect, useCallback } from 'react';
|
||||||
import { formatApiPath } from 'utils/formatPath';
|
import { formatApiPath } from 'utils/formatPath';
|
||||||
import handleErrorResponses from '../httpErrorResponseHandler';
|
import handleErrorResponses from '../httpErrorResponseHandler';
|
||||||
import { IAddon, IAddonProvider } from 'interfaces/addons';
|
import { AddonsSchema } from 'openapi';
|
||||||
|
|
||||||
interface IAddonsResponse {
|
|
||||||
addons: IAddon[];
|
|
||||||
providers: IAddonProvider[];
|
|
||||||
}
|
|
||||||
|
|
||||||
const useAddons = (options: SWRConfiguration = {}) => {
|
const useAddons = (options: SWRConfiguration = {}) => {
|
||||||
const fetcher = async () => {
|
const fetcher = async () => {
|
||||||
@ -20,7 +15,7 @@ const useAddons = (options: SWRConfiguration = {}) => {
|
|||||||
|
|
||||||
const KEY = `api/admin/addons`;
|
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 [loading, setLoading] = useState(!error && !data);
|
||||||
|
|
||||||
const refetchAddons = useCallback(() => {
|
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 {
|
export interface IAddonInstallation {
|
||||||
url: string;
|
url: string;
|
||||||
warning?: string;
|
warning?: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user