Skip to content

Commit

Permalink
Merge pull request #1282 from Infisical/patch-railway
Browse files Browse the repository at this point in the history
Fix client-side railway integration issue
  • Loading branch information
dangtony98 authored Jan 6, 2024
2 parents ec2cc51 + edd9c66 commit 485ddc5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
2 changes: 2 additions & 0 deletions frontend/src/hooks/api/integrationAuth/queries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ const fetchIntegrationAuthRailwayEnvironments = async ({
integrationAuthId: string;
appId: string;
}) => {
if (appId === "none") return [];
const {
data: { environments }
} = await apiRequest.get<{ environments: Environment[] }>(
Expand All @@ -318,6 +319,7 @@ const fetchIntegrationAuthRailwayServices = async ({
integrationAuthId: string;
appId: string;
}) => {
if (appId === "none") return [];
const {
data: { services }
} = await apiRequest.get<{ services: Service[] }>(
Expand Down
37 changes: 25 additions & 12 deletions frontend/src/pages/integrations/railway/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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) => (
Expand All @@ -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
Expand Down

0 comments on commit 485ddc5

Please sign in to comment.