Merge pull request #1282 from Infisical/patch-railway

Fix client-side railway integration issue
This commit is contained in:
BlackMagiq
2024-01-06 16:14:16 +01:00
committed by GitHub
2 changed files with 27 additions and 12 deletions

View File

@@ -297,6 +297,7 @@ const fetchIntegrationAuthRailwayEnvironments = async ({
integrationAuthId: string;
appId: string;
}) => {
if (appId === "none") return [];
const {
data: { environments }
} = await apiRequest.get<{ environments: Environment[] }>(
@@ -318,6 +319,7 @@ const fetchIntegrationAuthRailwayServices = async ({
integrationAuthId: string;
appId: string;
}) => {
if (appId === "none") return [];
const {
data: { services }
} = await apiRequest.get<{ services: Service[] }>(

View File

@@ -76,10 +76,15 @@ export default function RailwayCreateIntegrationPage() {
}
}, [targetEnvironments]);
const filteredServices = targetServices?.concat({
name: "",
serviceId: ""
});
useEffect(() => {
if (targetServices) {
if (targetServices.length > 0) {
setTargetServiceId(targetServices[0].serviceId);
} else {
setTargetServiceId("none");
}
}
}, [targetServices]);
const handleButtonClick = async () => {
try {
@@ -125,7 +130,7 @@ export default function RailwayCreateIntegrationPage() {
selectedSourceEnvironment &&
integrationAuthApps &&
targetEnvironments &&
filteredServices ? (
targetServices ? (
<div className="flex h-full w-full items-center justify-center">
<Card className="max-w-md rounded-md p-8">
<CardTitle className="text-center">Railway Integration</CardTitle>
@@ -180,6 +185,7 @@ export default function RailwayCreateIntegrationPage() {
value={targetEnvironmentId}
onValueChange={(val) => setTargetEnvironmentId(val)}
className="w-full border border-mineshaft-500"
isDisabled={targetEnvironments.length === 0}
>
{targetEnvironments.length > 0 ? (
targetEnvironments.map((targetEnvironment) => (
@@ -202,15 +208,22 @@ export default function RailwayCreateIntegrationPage() {
value={targetServiceId}
onValueChange={(val) => setTargetServiceId(val)}
className="w-full border border-mineshaft-500"
isDisabled={targetServices.length === 0}
>
{filteredServices.map((targetService) => (
<SelectItem
value={targetService.serviceId as string}
key={`target-service-${targetService.serviceId as string}`}
>
{targetService.name}
{targetServices.length > 0 ? (
targetServices.map((targetService) => (
<SelectItem
value={targetService.serviceId as string}
key={`target-service-${targetService.serviceId as string}`}
>
{targetService.name}
</SelectItem>
))
) : (
<SelectItem value="none" key="target-service-none">
No services found
</SelectItem>
))}
)}
</Select>
</FormControl>
<Button