mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 18:27:36 +00:00
Remove awkward lag when integration is loading its apps
This commit is contained in:
@@ -8,17 +8,23 @@ import {
|
|||||||
import deleteIntegrationAuth from "../../pages/api/integrations/DeleteIntegrationAuth";
|
import deleteIntegrationAuth from "../../pages/api/integrations/DeleteIntegrationAuth";
|
||||||
|
|
||||||
interface CloudIntegrationOption {
|
interface CloudIntegrationOption {
|
||||||
|
isAvailable: Boolean;
|
||||||
name: string;
|
name: string;
|
||||||
type: string;
|
type: string;
|
||||||
clientId: string;
|
clientId: string;
|
||||||
docsLink: string;
|
docsLink: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface IntegrationAuth {
|
||||||
|
id: string;
|
||||||
|
integration: string;
|
||||||
|
}
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
cloudIntegrationOption: CloudIntegrationOption;
|
cloudIntegrationOption: CloudIntegrationOption;
|
||||||
setSelectedIntegrationOption: () => void;
|
setSelectedIntegrationOption: () => void;
|
||||||
integrationOptionPress: () => void;
|
integrationOptionPress: () => void;
|
||||||
integrationAuths: any;
|
integrationAuths: IntegrationAuth[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const CloudIntegration = ({
|
const CloudIntegration = ({
|
||||||
@@ -27,34 +33,36 @@ const CloudIntegration = ({
|
|||||||
integrationOptionPress,
|
integrationOptionPress,
|
||||||
integrationAuths
|
integrationAuths
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
|
console.log('cloudIntegrationOption', cloudIntegrationOption);
|
||||||
|
console.log('integrationAuths', integrationAuths);
|
||||||
return integrationAuths ? (
|
return integrationAuths ? (
|
||||||
<div
|
<div
|
||||||
className={`relative ${
|
className={`relative ${
|
||||||
["Heroku"].includes(cloudIntegrationOption.name)
|
cloudIntegrationOption.isAvailable
|
||||||
? "hover:bg-white/10 duration-200 cursor-pointer"
|
? "hover:bg-white/10 duration-200 cursor-pointer"
|
||||||
: "opacity-50"
|
: "opacity-50"
|
||||||
} flex flex-row bg-white/5 h-32 rounded-md p-4 items-center`}
|
} flex flex-row bg-white/5 h-32 rounded-md p-4 items-center`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (!["Heroku"].includes(cloudIntegrationOption.name)) return;
|
if (!cloudIntegrationOption.isAvailable) return;
|
||||||
setSelectedIntegrationOption(cloudIntegrationOption);
|
setSelectedIntegrationOption(cloudIntegrationOption);
|
||||||
integrationOptionPress({
|
integrationOptionPress({
|
||||||
integrationOption: cloudIntegrationOption
|
integrationOption: cloudIntegrationOption
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
key={cloudIntegrationOption.name}
|
key={cloudIntegrationOption.name}
|
||||||
>
|
>
|
||||||
<Image
|
<Image
|
||||||
src={`/images/integrations/${cloudIntegrationOption.name}.png`}
|
src={`/images/integrations/${cloudIntegrationOption.name}.png`}
|
||||||
height={70}
|
height={70}
|
||||||
width={70}
|
width={70}
|
||||||
alt="integration logo"
|
alt="integration logo"
|
||||||
/>
|
/>
|
||||||
{cloudIntegrationOption.name.split(" ").length > 2 ? (
|
{cloudIntegrationOption.name.split(" ").length > 2 ? (
|
||||||
<div className="font-semibold text-gray-300 group-hover:text-gray-200 duration-200 text-3xl ml-4 max-w-xs">
|
<div className="font-semibold text-gray-300 group-hover:text-gray-200 duration-200 text-3xl ml-4 max-w-xs">
|
||||||
<div>{cloudIntegrationOption.name.split(" ")[0]}</div>
|
<div>{cloudIntegrationOption.name.split(" ")[0]}</div>
|
||||||
<div className="text-base">
|
<div className="text-base">
|
||||||
{cloudIntegrationOption.name.split(" ")[1]}{" "}
|
{cloudIntegrationOption.name.split(" ")[1]}{" "}
|
||||||
{cloudIntegrationOption.name.split(" ")[2]}
|
{cloudIntegrationOption.name.split(" ")[2]}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
@@ -62,25 +70,25 @@ const CloudIntegration = ({
|
|||||||
{cloudIntegrationOption.name}
|
{cloudIntegrationOption.name}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{["Heroku"].includes(cloudIntegrationOption.name) &&
|
{cloudIntegrationOption.isAvailable &&
|
||||||
integrationAuths
|
integrationAuths
|
||||||
.map((authorization) => authorization.integration)
|
.map((authorization) => authorization.integration)
|
||||||
.includes(cloudIntegrationOption.name.toLowerCase()) && (
|
.includes(cloudIntegrationOption.name.toLowerCase()) && (
|
||||||
<div className="absolute group z-50 top-0 right-0 flex flex-row">
|
<div className="absolute group z-50 top-0 right-0 flex flex-row">
|
||||||
<div
|
<div
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
deleteIntegrationAuth({
|
deleteIntegrationAuth({
|
||||||
integrationAuthId: integrationAuths
|
integrationAuthId: integrationAuths
|
||||||
.filter(
|
.filter(
|
||||||
(authorization) =>
|
(authorization) =>
|
||||||
authorization.integration ==
|
authorization.integration ==
|
||||||
cloudIntegrationOption.name.toLowerCase()
|
cloudIntegrationOption.name.toLowerCase()
|
||||||
)
|
)
|
||||||
.map((authorization) => authorization._id)[0],
|
.map((authorization) => authorization._id)[0],
|
||||||
});
|
});
|
||||||
router.reload();
|
router.reload();
|
||||||
}}
|
}}
|
||||||
className="cursor-pointer w-max bg-red py-0.5 px-2 rounded-b-md text-xs flex flex-row items-center opacity-0 group-hover:opacity-100 duration-200"
|
className="cursor-pointer w-max bg-red py-0.5 px-2 rounded-b-md text-xs flex flex-row items-center opacity-0 group-hover:opacity-100 duration-200"
|
||||||
>
|
>
|
||||||
<FontAwesomeIcon
|
<FontAwesomeIcon
|
||||||
icon={faX}
|
icon={faX}
|
||||||
@@ -97,7 +105,7 @@ const CloudIntegration = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{!["Heroku"].includes(cloudIntegrationOption.name) && (
|
{!cloudIntegrationOption.isAvailable && (
|
||||||
<div className="absolute group z-50 top-0 right-0 flex flex-row">
|
<div className="absolute group z-50 top-0 right-0 flex flex-row">
|
||||||
<div className="w-max bg-yellow py-0.5 px-2 rounded-bl-md rounded-tr-md text-xs flex flex-row items-center text-black opacity-90">
|
<div className="w-max bg-yellow py-0.5 px-2 rounded-bl-md rounded-tr-md text-xs flex flex-row items-center text-black opacity-90">
|
||||||
Coming Soon
|
Coming Soon
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import getIntegrationApps from "../../pages/api/integrations/GetIntegrationApps"
|
|||||||
import Button from "~/components/basic/buttons/Button";
|
import Button from "~/components/basic/buttons/Button";
|
||||||
import ListBox from "~/components/basic/Listbox";
|
import ListBox from "~/components/basic/Listbox";
|
||||||
|
|
||||||
|
// TODO: optimize laggy dropdown for app options
|
||||||
|
|
||||||
interface Integration {
|
interface Integration {
|
||||||
app?: string;
|
app?: string;
|
||||||
environment: string;
|
environment: string;
|
||||||
@@ -34,23 +36,21 @@ const Integration = ({
|
|||||||
const [fileState, setFileState] = useState([]);
|
const [fileState, setFileState] = useState([]);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [apps, setApps] = useState([]);
|
const [apps, setApps] = useState([]);
|
||||||
const [integrationApp, setIntegrationApp] = useState(
|
const [integrationApp, setIntegrationApp] = useState(null);
|
||||||
integration.app ? integration.app : apps[0]
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(async () => {
|
useEffect(async () => {
|
||||||
const tempHerokuApps = await getIntegrationApps({
|
const tempApps = await getIntegrationApps({
|
||||||
integrationAuthId: integration.integrationAuth,
|
integrationAuthId: integration.integrationAuth,
|
||||||
});
|
});
|
||||||
|
|
||||||
const tempHerokuAppNames = tempHerokuApps.map((app) => app.name);
|
const tempAppNames = tempApps.map((app) => app.name);
|
||||||
setApps(tempHerokuAppNames);
|
setApps(tempAppNames);
|
||||||
setIntegrationApp(
|
setIntegrationApp(
|
||||||
integration.app ? integration.app : tempHerokuAppNames[0]
|
integration.app ? integration.app : tempAppNames[0]
|
||||||
);
|
);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (integrationApp && apps.length > 0) ? (
|
||||||
<div className="flex flex-col max-w-5xl justify-center bg-white/5 p-6 rounded-md mx-6 mt-8">
|
<div className="flex flex-col max-w-5xl justify-center bg-white/5 p-6 rounded-md mx-6 mt-8">
|
||||||
<div className="relative px-4 flex flex-row items-center justify-between mb-4">
|
<div className="relative px-4 flex flex-row items-center justify-between mb-4">
|
||||||
<div className="flex flex-row">
|
<div className="flex flex-row">
|
||||||
@@ -63,6 +63,7 @@ const Integration = ({
|
|||||||
!integration.isActive && [
|
!integration.isActive && [
|
||||||
"Development",
|
"Development",
|
||||||
"Staging",
|
"Staging",
|
||||||
|
"Testing",
|
||||||
"Production",
|
"Production",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -135,7 +136,9 @@ const Integration = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
) : (
|
||||||
|
<div></div>
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Integration;
|
export default Integration;
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
"name": "Heroku",
|
"name": "Heroku",
|
||||||
"slug": "heroku",
|
"slug": "heroku",
|
||||||
"image": "Heroku",
|
"image": "Heroku",
|
||||||
|
"isAvailable": true,
|
||||||
"type": "oauth2",
|
"type": "oauth2",
|
||||||
"clientId": "bc132901-935a-4590-b010-f1857efc380d"
|
"clientId": "bc132901-935a-4590-b010-f1857efc380d"
|
||||||
},
|
},
|
||||||
@@ -10,6 +11,7 @@
|
|||||||
"name": "Netlify",
|
"name": "Netlify",
|
||||||
"slug": "netlify",
|
"slug": "netlify",
|
||||||
"image": "Netlify",
|
"image": "Netlify",
|
||||||
|
"isAvailable": false,
|
||||||
"type": "oauth2",
|
"type": "oauth2",
|
||||||
"clientId": ""
|
"clientId": ""
|
||||||
},
|
},
|
||||||
@@ -17,6 +19,7 @@
|
|||||||
"name": "Digital Ocean",
|
"name": "Digital Ocean",
|
||||||
"slug": "digital-ocean",
|
"slug": "digital-ocean",
|
||||||
"image": "Digital Ocean",
|
"image": "Digital Ocean",
|
||||||
|
"isAvailable": false,
|
||||||
"type": "",
|
"type": "",
|
||||||
"clientId": ""
|
"clientId": ""
|
||||||
},
|
},
|
||||||
@@ -24,6 +27,7 @@
|
|||||||
"name": "Google Cloud Platform",
|
"name": "Google Cloud Platform",
|
||||||
"slug": "gcp",
|
"slug": "gcp",
|
||||||
"image": "Google Cloud Platform",
|
"image": "Google Cloud Platform",
|
||||||
|
"isAvailable": false,
|
||||||
"type": "",
|
"type": "",
|
||||||
"clientId": ""
|
"clientId": ""
|
||||||
},
|
},
|
||||||
@@ -31,6 +35,7 @@
|
|||||||
"name": "Amazon Web Services",
|
"name": "Amazon Web Services",
|
||||||
"slug": "aws",
|
"slug": "aws",
|
||||||
"image": "Amazon Web Services",
|
"image": "Amazon Web Services",
|
||||||
|
"isAvailable": false,
|
||||||
"type": "",
|
"type": "",
|
||||||
"clientId": ""
|
"clientId": ""
|
||||||
},
|
},
|
||||||
@@ -38,6 +43,7 @@
|
|||||||
"name": "Microsoft Azure",
|
"name": "Microsoft Azure",
|
||||||
"slug": "azure",
|
"slug": "azure",
|
||||||
"image": "Microsoft Azure",
|
"image": "Microsoft Azure",
|
||||||
|
"isAvailable": false,
|
||||||
"type": "",
|
"type": "",
|
||||||
"clientId": ""
|
"clientId": ""
|
||||||
},
|
},
|
||||||
@@ -45,6 +51,7 @@
|
|||||||
"name": "Travis CI",
|
"name": "Travis CI",
|
||||||
"slug": "travisci",
|
"slug": "travisci",
|
||||||
"image": "Travis CI",
|
"image": "Travis CI",
|
||||||
|
"isAvailable": false,
|
||||||
"type": "",
|
"type": "",
|
||||||
"clientId": ""
|
"clientId": ""
|
||||||
},
|
},
|
||||||
@@ -52,6 +59,7 @@
|
|||||||
"name": "Circle CI",
|
"name": "Circle CI",
|
||||||
"slug": "circleci",
|
"slug": "circleci",
|
||||||
"image": "Circle CI",
|
"image": "Circle CI",
|
||||||
|
"isAvailable": false,
|
||||||
"type": "",
|
"type": "",
|
||||||
"clientId": ""
|
"clientId": ""
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user