Skip to content

Commit

Permalink
Implement query bar UI (#140)
Browse files Browse the repository at this point in the history
Signed-off-by: Nik Nasr <[email protected]>
  • Loading branch information
nikrooz authored Jan 15, 2025
1 parent 1e85c6d commit 15076e8
Show file tree
Hide file tree
Showing 58 changed files with 2,216 additions and 279 deletions.
3 changes: 2 additions & 1 deletion apps/web-ui/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Path,
Scripts,
ScrollRestoration,
useHref,
useNavigate,
} from 'react-router';
import styles from './tailwind.css?url';
Expand Down Expand Up @@ -90,7 +91,7 @@ export function Layout({ children }: { children: React.ReactNode }) {
<Links />
</head>
<body className="h-full font-sans">
<RouterProvider navigate={navigate}>
<RouterProvider navigate={navigate} useHref={useHref}>
<LayoutProvider>{children}</LayoutProvider>
</RouterProvider>
<ScrollRestoration />
Expand Down
1 change: 1 addition & 0 deletions apps/web-ui/app/routes/invocations.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { invocations } from '@restate/features/invocations-route';

export default invocations.Component;
export const clientLoader = invocations.clientLoader;
4 changes: 4 additions & 0 deletions apps/web-ui/app/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@
font-family: 'Inter var', 'Helvetica', system-ui, sans-serif;
}
}

*[data-testid='underlay'] {
pointer-events: none;
}
2 changes: 1 addition & 1 deletion libs/data-access/admin-api/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './lib/api/client';
export * from './lib/api/hooks';
export type * from './lib/api/type';
export * from './lib/api/type';
export * from './lib/AdminBaseUrlProvider';
45 changes: 42 additions & 3 deletions libs/data-access/admin-api/src/lib/api/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { paths, components } from './index'; // generated by openapi-typescript
import { useMutation, useQuery } from '@tanstack/react-query';
import { useMutation, useQueries, useQuery } from '@tanstack/react-query';
import {
adminApi,
MutationOptions,
Expand All @@ -15,6 +15,7 @@ import type {
ServiceName,
Deployment,
FilterItem,
Service,
} from './type';

type HookQueryOptions<
Expand Down Expand Up @@ -104,12 +105,18 @@ export function useListDeployments(
options?: HookQueryOptions<'/deployments', 'get'>
) {
const baseUrl = useAdminBaseUrl();
const queryOptions = adminApi('query', '/deployments', 'get', { baseUrl });

return useQuery({
...adminApi('query', '/deployments', 'get', { baseUrl }),
const results = useQuery({
...queryOptions,
...options,
select: listDeploymentsSelector,
});

return {
...results,
queryKey: queryOptions.queryKey,
};
}

export function useHealth(options?: HookQueryOptions<'/health', 'get'>) {
Expand Down Expand Up @@ -169,6 +176,38 @@ export function useServiceDetails(
return { ...results, queryKey: queryOptions.queryKey };
}

export function useListServices(
services: string[] = [],
options?: HookQueryOptions<'/services/{service}', 'get'>
) {
const baseUrl = useAdminBaseUrl();

const results = useQueries({
queries: services.map((service) => ({
...adminApi('query', '/services/{service}', 'get', {
baseUrl,
parameters: { path: { service } },
}),
staleTime: 0,
...options,
})),
combine: (results) => {
return {
data: results.reduce((result, service) => {
if (service.data) {
result.set(service.data?.name, service.data);
}
return result;
}, new Map<string, Service>()),
isPending: results.some((result) => result.isPending),
promise: Promise.all(results.map(({ promise }) => promise)),
};
},
});

return results;
}

export function useDeploymentDetails(
deployment: string,
options?: HookQueryOptions<'/deployments/{deployment}', 'get'>
Expand Down
22 changes: 14 additions & 8 deletions libs/data-access/admin-api/src/lib/api/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -849,14 +849,20 @@ export interface components {
/** @enum {string} */
type: 'NUMBER';
/** @enum {string} */
operation: 'EQUALS' | 'NOT_EQUALS' | 'GREATER_THAN' | 'LESS_THAN';
operation:
| 'EQUALS'
| 'NOT_EQUALS'
| 'GREATER_THAN'
| 'LESS_THAN'
| 'GREATER_THAN_OR_EQUAL'
| 'LESS_THAN_OR_EQUAL';
value?: number;
};
FilterStringItem: {
/** @enum {string} */
type: 'STRING';
/** @enum {string} */
operation: 'EQUALS' | 'NOT_EQUALS' | 'CONTAINS';
operation: 'EQUALS' | 'NOT_EQUALS' | 'CONTAINS' | 'NOT_CONTAINS';
value?: string;
};
FilterStringListItem: {
Expand Down Expand Up @@ -1130,7 +1136,8 @@ export interface components {
/** Format: date-time */
next_retry_at?: string;
id: string;
invoked_by: string;
/** @enum {string} */
invoked_by: 'ingress' | 'service';
/** @enum {string} */
status:
| 'succeeded'
Expand All @@ -1145,8 +1152,7 @@ export interface components {
| 'ready';
target: string;
target_handler_name: string;
/** @enum {string} */
target_service_key?: 'ingress' | 'service';
target_service_key?: string;
target_service_name: string;
/** @enum {string} */
target_service_ty: 'service' | 'virtual_object' | 'workflow';
Expand Down Expand Up @@ -1190,7 +1196,8 @@ export interface components {
/** Format: date-time */
next_retry_at?: string;
id: string;
invoked_by: string;
/** @enum {string} */
invoked_by: 'ingress' | 'service';
/** @enum {string} */
status:
| 'pending'
Expand All @@ -1202,8 +1209,7 @@ export interface components {
| 'completed';
target: string;
target_handler_name: string;
/** @enum {string} */
target_service_key?: 'ingress' | 'service';
target_service_key?: string;
target_service_name: string;
/** @enum {string} */
target_service_ty: 'service' | 'virtual_object' | 'workflow';
Expand Down
23 changes: 15 additions & 8 deletions libs/data-access/admin-api/src/lib/api/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -2792,7 +2792,14 @@
},
"operation": {
"type": "string",
"enum": ["EQUALS", "NOT_EQUALS", "GREATER_THAN", "LESS_THAN"]
"enum": [
"EQUALS",
"NOT_EQUALS",
"GREATER_THAN",
"LESS_THAN",
"GREATER_THAN_OR_EQUAL",
"LESS_THAN_OR_EQUAL"
]
},
"value": {
"type": "number"
Expand All @@ -2809,7 +2816,7 @@
},
"operation": {
"type": "string",
"enum": ["EQUALS", "NOT_EQUALS", "CONTAINS"]
"enum": ["EQUALS", "NOT_EQUALS", "CONTAINS", "NOT_CONTAINS"]
},
"value": {
"type": "string"
Expand Down Expand Up @@ -3693,7 +3700,8 @@
"type": "string"
},
"invoked_by": {
"type": "string"
"type": "string",
"enum": ["ingress", "service"]
},
"status": {
"type": "string",
Expand All @@ -3717,8 +3725,7 @@
"type": "string"
},
"target_service_key": {
"type": "string",
"enum": ["ingress", "service"]
"type": "string"
},
"target_service_name": {
"type": "string"
Expand Down Expand Up @@ -3835,7 +3842,8 @@
"type": "string"
},
"invoked_by": {
"type": "string"
"type": "string",
"enum": ["ingress", "service"]
},
"status": {
"type": "string",
Expand All @@ -3856,8 +3864,7 @@
"type": "string"
},
"target_service_key": {
"type": "string",
"enum": ["ingress", "service"]
"type": "string"
},
"target_service_name": {
"type": "string"
Expand Down
23 changes: 15 additions & 8 deletions libs/data-access/admin-api/src/lib/api/query.json
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,14 @@
},
"operation": {
"type": "string",
"enum": ["EQUALS", "NOT_EQUALS", "GREATER_THAN", "LESS_THAN"]
"enum": [
"EQUALS",
"NOT_EQUALS",
"GREATER_THAN",
"LESS_THAN",
"GREATER_THAN_OR_EQUAL",
"LESS_THAN_OR_EQUAL"
]
},
"value": {
"type": "number"
Expand All @@ -862,7 +869,7 @@
},
"operation": {
"type": "string",
"enum": ["EQUALS", "NOT_EQUALS", "CONTAINS"]
"enum": ["EQUALS", "NOT_EQUALS", "CONTAINS", "NOT_CONTAINS"]
},
"value": {
"type": "string"
Expand Down Expand Up @@ -1617,7 +1624,8 @@
"type": "string"
},
"invoked_by": {
"type": "string"
"type": "string",
"enum": ["ingress", "service"]
},
"status": {
"type": "string",
Expand All @@ -1641,8 +1649,7 @@
"type": "string"
},
"target_service_key": {
"type": "string",
"enum": ["ingress", "service"]
"type": "string"
},
"target_service_name": {
"type": "string"
Expand Down Expand Up @@ -1759,7 +1766,8 @@
"type": "string"
},
"invoked_by": {
"type": "string"
"type": "string",
"enum": ["ingress", "service"]
},
"status": {
"type": "string",
Expand All @@ -1780,8 +1788,7 @@
"type": "string"
},
"target_service_key": {
"type": "string",
"enum": ["ingress", "service"]
"type": "string"
},
"target_service_name": {
"type": "string"
Expand Down
24 changes: 24 additions & 0 deletions libs/data-access/admin-api/src/lib/api/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,27 @@ export type FilterNumberItem = components['schemas']['FilterNumberItem'];
export type FilterStringListItem =
components['schemas']['FilterStringListItem'];
export type FilterStringItem = components['schemas']['FilterStringItem'];

export type HTTPDeployment = Exclude<Deployment, { arn: string }>;
export type LambdaDeployment = Exclude<Deployment, { uri: string }>;
export type DeploymentType = 'uri' | 'arn';
export function isHttpDeployment(
deployment: Deployment
): deployment is HTTPDeployment {
return 'uri' in deployment;
}
export function isLambdaDeployment(
deployment: Deployment
): deployment is LambdaDeployment {
return 'arn' in deployment;
}
export function getEndpoint(deployment?: Deployment) {
if (!deployment) {
return undefined;
}
if (isHttpDeployment(deployment)) {
return deployment.uri;
} else {
return deployment.arn;
}
}
Loading

0 comments on commit 15076e8

Please sign in to comment.