Skip to content

Commit 4a94459

Browse files
authored
Merge pull request #77 from uselagoon/local-dev-api-routes
feat: support for api defined routes
2 parents f233025 + c703ba7 commit 4a94459

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1905
-5
lines changed

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CI_BUILD_TAG ?= lagoon-ui
22
CORE_REPO=https://github.com/uselagoon/lagoon.git
33
# CORE_REPO = ../lagoon
4-
CORE_TREEISH=main
4+
CORE_TREEISH=api-defined-routes
55

66
# for the `stable` targets, images with these tags will be used
77
LAGOON_CORE_IMAGE_REPO=testlagoon
@@ -30,7 +30,15 @@ start-ui:
3030
&& export CALLBACK_URL=$(CALLBACK_URL) \
3131
&& export AUTH_KEYCLOAK_ISSUER=$(AUTH_KEYCLOAK_ISSUER) \
3232
&& export AUTH_KEYCLOAK_SECRET=$(AUTH_KEYCLOAK_SECRET) \
33-
&& docker compose -p $(CI_BUILD_TAG) --compatibility up -d ui
33+
&& docker compose -p $(CI_BUILD_TAG) --compatibility up -d ui --build
34+
35+
.PHONY: start-ui-k3d
36+
start-ui-k3d:
37+
$(MAKE) start-ui \
38+
GRAPHQL_API=https://lagoon-api.$$(kubectl -n ingress-nginx get services ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}').nip.io/graphql \
39+
KEYCLOAK_FRONTEND_URL=https://lagoon-keycloak.$$(kubectl -n ingress-nginx get services ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}').nip.io/auth \
40+
AUTH_KEYCLOAK_SECRET=$$(kubectl -n lagoon-core get secrets lagoon-core-keycloak -o json | jq -r '.data["KEYCLOAK_LAGOON_UI_OIDC_CLIENT_SECRET"] | @base64d')
41+
docker network connect k3d lagoon-ui_ui_1
3442

3543
.PHONY: checkout-core
3644
checkout-core:

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ x-environment: &default-environment
1616
AUTH_KEYCLOAK_ISSUER: "${AUTH_KEYCLOAK_ISSUER:-http://0.0.0.0:8088/auth/realms/lagoon}"
1717
LAGOON_UI_TOURS_ENABLED: enabled
1818
NODE_TLS_REJECT_UNAUTHORIZED: 0
19+
DISABLE_SUBSCRIPTIONS: 'true'
1920

2021
services:
2122
ui:

src/app/(routegroups)/(projectroutes)/projects/[projectSlug]/(project-overview)/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export type ProjectEnvironment = {
1717
updated: string | null;
1818
routes: null | string;
1919
openshiftProjectName: string;
20+
kubernetesNamespaceName: string;
2021
openshift: { friendlyName: null | string; cloudRegion: null | string };
2122
project: {
2223
name: string;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use client';
2+
3+
import SectionWrapper from '@/components/SectionWrapper/SectionWrapper';
4+
import { FactsTableColumns, InsightsTableColumns } from '@/components/pages/insights/DataTableColumns';
5+
import { DataTable } from '@uselagoon/ui-library';
6+
7+
export default function Loading() {
8+
return (
9+
<SectionWrapper>
10+
<h3 className="scroll-m-20 text-2xl font-semibold tracking-tight">Facts</h3>
11+
<DataTable loading columns={[]} data={[]} />
12+
13+
<h3 className="scroll-m-20 text-2xl font-semibold tracking-tight my-4">Facts</h3>
14+
15+
<DataTable loading columns={InsightsTableColumns(0)} data={[]} />
16+
</SectionWrapper>
17+
);
18+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import { PreloadQuery } from '@/lib/apolloClient';
2+
import { QueryRef } from '@apollo/client';
3+
import { ProjectEnvironment } from '../../(project-overview)/page';
4+
import environmentWithRoutes from '@/lib/query/environmentWithRoutes';
5+
import EnvironmentRoutesPage from '@/components/pages/environmentRoutes/EnvironmentRoutesPage';
6+
7+
type Props = {
8+
params: Promise<{ environmentSlug: string }>;
9+
};
10+
11+
type Environment = {
12+
id: number;
13+
name: string;
14+
kubernetesNamespaceName: string;
15+
environmentType: string;
16+
apiRoutes: EnvironmentRoute[];
17+
project: Project;
18+
};
19+
20+
export type EnvironmentRoute = {
21+
id: number;
22+
domain: string;
23+
type: string;
24+
primary: boolean;
25+
environment: Environment;
26+
service: string;
27+
created: string;
28+
updated: string;
29+
source: string;
30+
};
31+
32+
type Project = {
33+
id: number;
34+
name: string;
35+
environments: ProjectEnvironment[];
36+
productionEnvironment?: string;
37+
standbyProductionEnvironment?: string;
38+
};
39+
40+
export interface EnvironmentRoutesData {
41+
environmentRoutes: Environment;
42+
}
43+
44+
export async function generateMetadata(props: Props) {
45+
const params = await props.params;
46+
return {
47+
title: `${params.environmentSlug} | Environment Routes`,
48+
};
49+
}
50+
51+
export default async function Routes(props: {
52+
params: Promise<{ environmentSlug: string; projectSlug: string }>;
53+
}) {
54+
const params = await props.params;
55+
56+
const { projectSlug, environmentSlug} = params;
57+
58+
return (
59+
<PreloadQuery
60+
query={environmentWithRoutes}
61+
variables={{
62+
openshiftProjectName: environmentSlug
63+
}}
64+
>
65+
{queryRef => (
66+
<EnvironmentRoutesPage
67+
projectName={projectSlug}
68+
queryRef={queryRef as QueryRef<EnvironmentRoutesData>}
69+
/>
70+
)}
71+
</PreloadQuery>
72+
);
73+
}

src/app/(routegroups)/(projectroutes)/projects/[projectSlug]/deploy-targets/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type ProjectWithDeployTargets = {
2222
productionRoutes: null | string;
2323
standbyRoutes: null | string;
2424
developmentEnvironmentsLimit: number;
25+
featureApiRoutes: boolean;
2526
deployTargetConfigs: {
2627
id: number;
2728
branches: string;

src/app/(routegroups)/(projectroutes)/projects/[projectSlug]/project-details/page.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,26 @@ type ProjectWithDetails = {
2525
environments: {
2626
environmentType: 'production' | 'development';
2727
}[];
28+
autogeneratedRouteConfig?: AutogeneratedRouteConfig;
2829
};
2930

31+
type AutogeneratedRouteConfig = {
32+
updated: string;
33+
enabled: boolean;
34+
allowPullRequests: boolean;
35+
prefixes: string[];
36+
tlsAcme: boolean;
37+
insecure: string;
38+
pathRoutes: AutogeneratedPathRoute[];
39+
disableRequestVerification: boolean;
40+
}
41+
42+
type AutogeneratedPathRoute = {
43+
toService: string;
44+
fromService: string;
45+
path: string;
46+
}
47+
3048
export type ProjectDetailsData = {
3149
project: ProjectWithDetails;
3250
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use client';
2+
3+
import SectionWrapper from '@/components/SectionWrapper/SectionWrapper';
4+
import { FactsTableColumns, InsightsTableColumns } from '@/components/pages/insights/DataTableColumns';
5+
import { DataTable } from '@uselagoon/ui-library';
6+
7+
export default function Loading() {
8+
return (
9+
<SectionWrapper>
10+
<h3 className="scroll-m-20 text-2xl font-semibold tracking-tight">Facts</h3>
11+
<DataTable loading columns={[]} data={[]} />
12+
13+
<h3 className="scroll-m-20 text-2xl font-semibold tracking-tight my-4">Facts</h3>
14+
15+
<DataTable loading columns={InsightsTableColumns(0)} data={[]} />
16+
</SectionWrapper>
17+
);
18+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { PreloadQuery } from '@/lib/apolloClient';
2+
import { QueryRef } from '@apollo/client';
3+
import RoutesPage from "@/components/pages/routes/RoutesPage";
4+
import projectWithRoutes from "@/lib/query/projectWithRoutes";
5+
import { ProjectEnvironment } from '../(project-overview)/page';
6+
7+
type Props = {
8+
params: Promise<{ projectSlug: string }>;
9+
};
10+
11+
type Environment = {
12+
id: number;
13+
name: string;
14+
kubernetesNamespaceName: string;
15+
environmentType: string;
16+
};
17+
18+
export type Route = {
19+
id: number;
20+
domain: string;
21+
type: string;
22+
primary: boolean;
23+
environment: Environment;
24+
service: string;
25+
created: string;
26+
updated: string;
27+
source: string;
28+
};
29+
30+
type Project = {
31+
id: number;
32+
name: string;
33+
environments: ProjectEnvironment[];
34+
productionEnvironment?: string;
35+
standbyProductionEnvironment?: string;
36+
apiRoutes: Route[];
37+
};
38+
39+
export interface RoutesData {
40+
projectRoutes: Project;
41+
}
42+
43+
export async function generateMetadata(props: Props) {
44+
const params = await props.params;
45+
return {
46+
title: `${params.projectSlug} | Project Routes`,
47+
};
48+
}
49+
50+
export default async function Routes(props: {
51+
params: Promise<{ projectSlug: string }>;
52+
}) {
53+
const params = await props.params;
54+
55+
const { projectSlug } = params;
56+
57+
return (
58+
<PreloadQuery
59+
query={projectWithRoutes}
60+
variables={{
61+
name: projectSlug,
62+
}}
63+
>
64+
{queryRef => (
65+
<RoutesPage
66+
projectName={projectSlug}
67+
queryRef={queryRef as QueryRef<RoutesData>}
68+
/>
69+
)}
70+
</PreloadQuery>
71+
);
72+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { FC } from 'react';
2+
3+
import AttachRouteSheet from './AttachRouteSheet';
4+
import { ProjectEnvironment } from '@/app/(routegroups)/(projectroutes)/projects/[projectSlug]/(project-overview)/page';
5+
6+
type Props = {
7+
variant?: 'default' | 'small';
8+
projectName?: string;
9+
domainName?: string;
10+
environments: ProjectEnvironment[];
11+
refetch?: () => void;
12+
iconOnly?: boolean;
13+
prodEnvironment?: string;
14+
standbyEnvironment?: string;
15+
};
16+
17+
export const AttachRoute: FC<Props> = props => {
18+
19+
return (
20+
<>
21+
<div className="flex gap-2 items-center">
22+
<AttachRouteSheet
23+
projectName={props.projectName}
24+
domainName={props.domainName}
25+
environments={props.environments}
26+
iconOnly={props.iconOnly}
27+
prodEnvironment={props.prodEnvironment}
28+
standbyEnvironment={props.standbyEnvironment}
29+
/>
30+
</div>
31+
</>
32+
);
33+
};

0 commit comments

Comments
 (0)