Skip to content

Commit

Permalink
Merge branch 'main' into peerdb-unified-image
Browse files Browse the repository at this point in the history
  • Loading branch information
heavycrystal authored Nov 30, 2023
2 parents d002407 + 505e524 commit 4963dcd
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 17 deletions.
3 changes: 3 additions & 0 deletions flow/cmd/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,15 @@ func (h *FlowRequestHandler) CreateCDCFlow(
if req.CreateCatalogEntry {
err := h.createCdcJobEntry(ctx, req, workflowID)
if err != nil {
log.Errorf("unable to create flow job entry: %v", err)
return nil, fmt.Errorf("unable to create flow job entry: %w", err)
}
}

var err error
err = h.updateFlowConfigInCatalog(cfg)
if err != nil {
log.Errorf("unable to update flow config in catalog: %v", err)
return nil, fmt.Errorf("unable to update flow config in catalog: %w", err)
}

Expand All @@ -184,6 +186,7 @@ func (h *FlowRequestHandler) CreateCDCFlow(
state, // workflow state
)
if err != nil {
log.Errorf("unable to start PeerFlow workflow: %v", err)
return nil, fmt.Errorf("unable to start PeerFlow workflow: %w", err)
}

Expand Down
4 changes: 2 additions & 2 deletions flow/cmd/peer_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (h *FlowRequestHandler) GetSchemas(

defer peerPool.Close()
rows, err := peerPool.Query(ctx, "SELECT schema_name"+
" FROM information_schema.schemata;")
" FROM information_schema.schemata WHERE schema_name !~ '^pg_' AND schema_name <> 'information_schema';")
if err != nil {
return &protos.PeerSchemasResponse{Schemas: nil}, err
}
Expand Down Expand Up @@ -106,7 +106,7 @@ func (h *FlowRequestHandler) GetAllTables(

defer peerPool.Close()
rows, err := peerPool.Query(ctx, "SELECT table_schema || '.' || table_name AS schema_table "+
"FROM information_schema.tables;")
"FROM information_schema.tables WHERE table_schema !~ '^pg_' AND table_schema <> 'information_schema'")
if err != nil {
return &protos.AllTablesResponse{Tables: nil}, err
}
Expand Down
57 changes: 45 additions & 12 deletions ui/app/peers/peersTable.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
'use client';
import { DropDialog } from '@/components/DropDialog';
import PeerButton from '@/components/PeerComponent';
import PeerTypeLabel from '@/components/PeerTypeComponent';
import { Peer } from '@/grpc_generated/peers';
import PeerTypeLabel, {
DBTypeToGoodText,
} from '@/components/PeerTypeComponent';
import { DBType, Peer } from '@/grpc_generated/peers';
import { Label } from '@/lib/Label';
import { SearchField } from '@/lib/SearchField';
import { Table, TableCell, TableRow } from '@/lib/Table';
import { useMemo, useState } from 'react';
import ReactSelect from 'react-select';

function PeerRow({ peer }: { peer: Peer }) {
return (
Expand All @@ -31,26 +34,56 @@ function PeerRow({ peer }: { peer: Peer }) {

function PeersTable({ title, peers }: { title: string; peers: Peer[] }) {
const [searchQuery, setSearchQuery] = useState<string>('');
const [filteredType, setFilteredType] = useState<DBType | undefined>(
undefined
);
const rows = useMemo(
() =>
peers.filter((peer) => {
return peer.name.toLowerCase().includes(searchQuery.toLowerCase());
}),
[peers, searchQuery]
peers
.filter((peer) => {
return peer.name.toLowerCase().includes(searchQuery.toLowerCase());
})
.filter((peer) => {
return filteredType == undefined || peer.type == filteredType;
}),
[peers, searchQuery, filteredType]
);
const allTypesOption: { value: DBType | undefined; label: string } = {
value: undefined,
label: 'All',
};
const availableTypes: { value: DBType | undefined; label: string }[] =
Array.from(
new Map( // Map filters out duplicates
peers.flatMap((peer) => [
[peer.type, { value: peer.type, label: DBTypeToGoodText(peer.type) }],
])
).values()
);
availableTypes.unshift(allTypesOption);

return (
<Table
title={<Label variant='headline'>{title}</Label>}
toolbar={{
left: <></>,
right: (
<SearchField
placeholder='Search by peer name'
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
setSearchQuery(e.target.value)
}
/>
<>
<ReactSelect
className='w-48'
options={availableTypes}
onChange={(val, _) => {
setFilteredType(val?.value);
}}
defaultValue={allTypesOption}
/>
<SearchField
placeholder='Search by peer name'
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
setSearchQuery(e.target.value)
}
/>
</>
),
}}
header={
Expand Down
4 changes: 2 additions & 2 deletions ui/components/PeerTypeComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Label } from '@/lib/Label';
import Image from 'next/image';
import { DBTypeToImageMapping } from './PeerComponent';

const DBTypeToGoodText = (ptype: DBType) => {
export const DBTypeToGoodText = (ptype: DBType) => {
switch (ptype) {
case DBType.POSTGRES:
return 'PostgreSQL';
Expand All @@ -13,7 +13,7 @@ const DBTypeToGoodText = (ptype: DBType) => {
case DBType.EVENTHUB:
return 'Event Hubs';
case DBType.EVENTHUB_GROUP:
return 'Event Hubs';
return 'Event Hubs (Group)';
case DBType.BIGQUERY:
return 'BigQuery';
case DBType.S3:
Expand Down
2 changes: 1 addition & 1 deletion ui/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "es6",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
Expand Down

0 comments on commit 4963dcd

Please sign in to comment.