mirror of
https://github.com/Unleash/unleash.git
synced 2025-03-23 00:16:25 +01:00
Fix: integrations form (#4655)
## About the changes Fix submitting integrations form
This commit is contained in:
parent
ba73d9a0d1
commit
f88e15c45c
@ -16,6 +16,12 @@ export const filterByConfig =
|
|||||||
return Boolean(flags[r.flag]);
|
return Boolean(flags[r.flag]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (r.notFlag) {
|
||||||
|
const flags = config.flags as unknown as Record<string, boolean>;
|
||||||
|
|
||||||
|
return !(flags[r.notFlag] === true);
|
||||||
|
}
|
||||||
|
|
||||||
if (r.configFlag) {
|
if (r.configFlag) {
|
||||||
// Check if the route's `configFlag` is enabled in IUiConfig.
|
// Check if the route's `configFlag` is enabled in IUiConfig.
|
||||||
return Boolean(config[r.configFlag]);
|
return Boolean(config[r.configFlag]);
|
||||||
|
@ -43,6 +43,7 @@ import { ConditionallyRender } from 'component/common/ConditionallyRender/Condit
|
|||||||
import { IntegrationDelete } from './IntegrationDelete/IntegrationDelete';
|
import { IntegrationDelete } from './IntegrationDelete/IntegrationDelete';
|
||||||
import { IntegrationStateSwitch } from './IntegrationStateSwitch/IntegrationStateSwitch';
|
import { IntegrationStateSwitch } from './IntegrationStateSwitch/IntegrationStateSwitch';
|
||||||
import { capitalizeFirst } from 'utils/capitalizeFirst';
|
import { capitalizeFirst } from 'utils/capitalizeFirst';
|
||||||
|
import { useUiFlag } from 'hooks/useUiFlag';
|
||||||
|
|
||||||
type IntegrationFormProps = {
|
type IntegrationFormProps = {
|
||||||
provider?: AddonTypeSchema;
|
provider?: AddonTypeSchema;
|
||||||
@ -75,6 +76,7 @@ export const IntegrationForm: VFC<IntegrationFormProps> = ({
|
|||||||
label: event,
|
label: event,
|
||||||
}));
|
}));
|
||||||
const { uiConfig } = useUiConfig();
|
const { uiConfig } = useUiConfig();
|
||||||
|
const integrationsRework = useUiFlag('integrationsRework');
|
||||||
const [formValues, setFormValues] = useState(initialValues);
|
const [formValues, setFormValues] = useState(initialValues);
|
||||||
const [errors, setErrors] = useState<{
|
const [errors, setErrors] = useState<{
|
||||||
containsErrors: boolean;
|
containsErrors: boolean;
|
||||||
@ -218,14 +220,14 @@ export const IntegrationForm: VFC<IntegrationFormProps> = ({
|
|||||||
try {
|
try {
|
||||||
if (editMode) {
|
if (editMode) {
|
||||||
await updateAddon(formValues as AddonSchema);
|
await updateAddon(formValues as AddonSchema);
|
||||||
navigate('/addons');
|
navigate(integrationsRework ? '/integrations' : '/addons');
|
||||||
setToastData({
|
setToastData({
|
||||||
type: 'success',
|
type: 'success',
|
||||||
title: 'Addon updated successfully',
|
title: 'Addon updated successfully',
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await createAddon(formValues as Omit<AddonSchema, 'id'>);
|
await createAddon(formValues as Omit<AddonSchema, 'id'>);
|
||||||
navigate('/addons');
|
navigate(integrationsRework ? '/integrations' : '/addons');
|
||||||
setToastData({
|
setToastData({
|
||||||
type: 'success',
|
type: 'success',
|
||||||
confetti: true,
|
confetti: true,
|
||||||
@ -271,6 +273,7 @@ export const IntegrationForm: VFC<IntegrationFormProps> = ({
|
|||||||
color="primary"
|
color="primary"
|
||||||
variant="contained"
|
variant="contained"
|
||||||
permission={editMode ? UPDATE_ADDON : CREATE_ADDON}
|
permission={editMode ? UPDATE_ADDON : CREATE_ADDON}
|
||||||
|
onClick={onSubmit}
|
||||||
>
|
>
|
||||||
{submitText}
|
{submitText}
|
||||||
</PermissionButton>
|
</PermissionButton>
|
||||||
@ -382,9 +385,7 @@ export const IntegrationForm: VFC<IntegrationFormProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
</StyledConfigurationSection>
|
</StyledConfigurationSection>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={Boolean(
|
condition={Boolean(integrationsRework && editMode)}
|
||||||
uiConfig?.flags?.integrationsRework && editMode
|
|
||||||
)}
|
|
||||||
show={() => (
|
show={() => (
|
||||||
<>
|
<>
|
||||||
<Divider />
|
<Divider />
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { type VFC } from 'react';
|
import { type VFC } from 'react';
|
||||||
import { Typography, styled } from '@mui/material';
|
import { Box, Typography, styled } from '@mui/material';
|
||||||
import type { AddonTypeSchema } from 'openapi';
|
import type { AddonTypeSchema } from 'openapi';
|
||||||
import useLoading from 'hooks/useLoading';
|
import useLoading from 'hooks/useLoading';
|
||||||
import { PageContent } from 'component/common/PageContent/PageContent';
|
import { PageContent } from 'component/common/PageContent/PageContent';
|
||||||
@ -58,23 +58,21 @@ export const AvailableIntegrations: VFC<IAvailableIntegrationsProps> = ({
|
|||||||
>
|
>
|
||||||
<StyledContainer>
|
<StyledContainer>
|
||||||
<StyledSection>
|
<StyledSection>
|
||||||
<div>
|
|
||||||
<Typography component="h3" variant="h2">
|
|
||||||
Title
|
|
||||||
</Typography>
|
|
||||||
<Typography variant="body2" color="text.secondary">
|
|
||||||
Description
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
<StyledCardsGrid>
|
<StyledCardsGrid>
|
||||||
{providers?.map(
|
{providers?.map(
|
||||||
({ name, displayName, description }) => (
|
({
|
||||||
|
name,
|
||||||
|
displayName,
|
||||||
|
description,
|
||||||
|
deprecated,
|
||||||
|
}) => (
|
||||||
<IntegrationCard
|
<IntegrationCard
|
||||||
key={name}
|
key={name}
|
||||||
icon={name}
|
icon={name}
|
||||||
title={displayName || name}
|
title={displayName || name}
|
||||||
description={description}
|
description={description}
|
||||||
link={`/integrations/create/${name}`}
|
link={`/integrations/create/${name}`}
|
||||||
|
deprecated={deprecated}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
@ -109,16 +107,17 @@ export const AvailableIntegrations: VFC<IAvailableIntegrationsProps> = ({
|
|||||||
icon="unleash"
|
icon="unleash"
|
||||||
title="Unleash Edge"
|
title="Unleash Edge"
|
||||||
description="Unleash Edge is built to help you scale Unleash. As a successor of Unleash Proxy it's even faster and more versitile."
|
description="Unleash Edge is built to help you scale Unleash. As a successor of Unleash Proxy it's even faster and more versitile."
|
||||||
link="/integrations/create/unleash-proxy"
|
link="/integrations/view/edge"
|
||||||
configureActionText="Learn more"
|
configureActionText="Learn more"
|
||||||
/>
|
/>
|
||||||
<IntegrationCard
|
<IntegrationCard
|
||||||
icon="unleash"
|
icon="unleash"
|
||||||
title="Unleash Proxy"
|
title="Unleash Proxy"
|
||||||
description="The Unleash Proxy is a lightweight, stateless proxy that sits between your Unleash client SDKs and the Unleash API."
|
description="The Unleash Proxy is a lightweight, stateless proxy that sits between your Unleash client SDKs and the Unleash API."
|
||||||
link="/integrations/create/unleash-proxy"
|
link="https://docs.getunleash.io/reference/unleash-proxy"
|
||||||
configureActionText="View documentation"
|
configureActionText="View documentation"
|
||||||
deprecated="Try Unleash Edge instead. It has all the features of Unleash Proxy and more."
|
deprecated="Try Unleash Edge instead. It has all the features of Unleash Proxy and more."
|
||||||
|
isExternal
|
||||||
/>
|
/>
|
||||||
</StyledCardsGrid>
|
</StyledCardsGrid>
|
||||||
</StyledSection>
|
</StyledSection>
|
||||||
@ -140,7 +139,7 @@ export const AvailableIntegrations: VFC<IAvailableIntegrationsProps> = ({
|
|||||||
</a>
|
</a>
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<Box sx={theme => ({ marginTop: theme.spacing(2) })}>
|
||||||
<Typography component="h4" variant="h4">
|
<Typography component="h4" variant="h4">
|
||||||
Server-side SDKs
|
Server-side SDKs
|
||||||
</Typography>
|
</Typography>
|
||||||
@ -148,7 +147,7 @@ export const AvailableIntegrations: VFC<IAvailableIntegrationsProps> = ({
|
|||||||
Server-side clients run on your server and
|
Server-side clients run on your server and
|
||||||
communicate directly with your Unleash instance.
|
communicate directly with your Unleash instance.
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</Box>
|
||||||
<StyledCardsGrid small>
|
<StyledCardsGrid small>
|
||||||
{serverSdks?.map(
|
{serverSdks?.map(
|
||||||
({
|
({
|
||||||
@ -169,7 +168,7 @@ export const AvailableIntegrations: VFC<IAvailableIntegrationsProps> = ({
|
|||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
</StyledCardsGrid>
|
</StyledCardsGrid>
|
||||||
<div>
|
<Box sx={theme => ({ marginTop: theme.spacing(2) })}>
|
||||||
<Typography component="h4" variant="h4">
|
<Typography component="h4" variant="h4">
|
||||||
Client-side SDKs
|
Client-side SDKs
|
||||||
</Typography>
|
</Typography>
|
||||||
@ -192,7 +191,7 @@ export const AvailableIntegrations: VFC<IAvailableIntegrationsProps> = ({
|
|||||||
</a>
|
</a>
|
||||||
, but not to the regular Unleash client API.
|
, but not to the regular Unleash client API.
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</Box>
|
||||||
<StyledCardsGrid small>
|
<StyledCardsGrid small>
|
||||||
{clientSdks?.map(
|
{clientSdks?.map(
|
||||||
({
|
({
|
||||||
|
@ -312,6 +312,7 @@ exports[`returns all baseRoutes 1`] = `
|
|||||||
"advanced": true,
|
"advanced": true,
|
||||||
"mobile": true,
|
"mobile": true,
|
||||||
},
|
},
|
||||||
|
"notFlag": "integrationsRework",
|
||||||
"path": "/addons",
|
"path": "/addons",
|
||||||
"title": "Addons",
|
"title": "Addons",
|
||||||
"type": "protected",
|
"type": "protected",
|
||||||
|
@ -327,6 +327,7 @@ export const routes: IRoute[] = [
|
|||||||
// TODO: use AddonRedirect after removing `integrationsRework` menu flag
|
// TODO: use AddonRedirect after removing `integrationsRework` menu flag
|
||||||
hidden: false,
|
hidden: false,
|
||||||
type: 'protected',
|
type: 'protected',
|
||||||
|
notFlag: 'integrationsRework',
|
||||||
menu: { mobile: true, advanced: true },
|
menu: { mobile: true, advanced: true },
|
||||||
// TODO: remove 'addons' from menu after removing `integrationsRework` menu flag
|
// TODO: remove 'addons' from menu after removing `integrationsRework` menu flag
|
||||||
},
|
},
|
||||||
@ -508,6 +509,7 @@ export const getCondensedRoutes = (routes: IRoute[]): INavigationMenuItem[] => {
|
|||||||
title: route.title,
|
title: route.title,
|
||||||
menu: route.menu,
|
menu: route.menu,
|
||||||
configFlag: route.configFlag,
|
configFlag: route.configFlag,
|
||||||
|
notFlag: route.notFlag,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -8,6 +8,7 @@ export interface IRoute {
|
|||||||
layout?: string;
|
layout?: string;
|
||||||
parent?: string;
|
parent?: string;
|
||||||
flag?: keyof UiFlags;
|
flag?: keyof UiFlags;
|
||||||
|
notFlag?: keyof UiFlags;
|
||||||
configFlag?: keyof IUiConfig;
|
configFlag?: keyof IUiConfig;
|
||||||
hidden?: boolean;
|
hidden?: boolean;
|
||||||
enterprise?: boolean;
|
enterprise?: boolean;
|
||||||
@ -21,6 +22,7 @@ export interface INavigationMenuItem {
|
|||||||
title: string;
|
title: string;
|
||||||
menu: IRouteMenu;
|
menu: IRouteMenu;
|
||||||
flag?: keyof UiFlags;
|
flag?: keyof UiFlags;
|
||||||
|
notFlag?: keyof UiFlags;
|
||||||
configFlag?: keyof IUiConfig;
|
configFlag?: keyof IUiConfig;
|
||||||
group?: string;
|
group?: string;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user