Skip to content

Commit

Permalink
remotes list ui
Browse files Browse the repository at this point in the history
  • Loading branch information
liuliu-dev committed Dec 3, 2024
1 parent 5f6d76b commit ce498be
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 26 deletions.
20 changes: 10 additions & 10 deletions web/renderer/components/breadcrumbs/RemotesBreadcrumbs.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DatabaseParams } from "@lib/params";
import { DatabaseParams } from "@lib/params";
import Breadcrumbs from ".";
import { remoteBreadcrumbDetails } from "./breadcrumbDetails";

Expand All @@ -8,12 +8,12 @@ type Props = {
};

export default function RemotesBreadcrumbs(props: Props) {
return (
<Breadcrumbs
{...props}
aria-label="db-remotes-breadcrumbs"
data-cy="db-remotes-breadcrumbs"
breadcrumbs={remoteBreadcrumbDetails(props.params)}
/>
);
}
return (
<Breadcrumbs
{...props}
aria-label="db-remotes-breadcrumbs"
data-cy="db-remotes-breadcrumbs"
breadcrumbs={remoteBreadcrumbDetails(props.params)}
/>
);
}
5 changes: 3 additions & 2 deletions web/renderer/components/breadcrumbs/breadcrumbDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ export function commitLogBreadcrumbDetails(
];
}

export function remoteBreadcrumbDetails(params: DatabaseParams): BreadcrumbDetails[] {
export function remoteBreadcrumbDetails(
params: DatabaseParams,
): BreadcrumbDetails[] {
return [
...databaseBreadcrumbs(params),
{
Expand All @@ -124,7 +126,6 @@ export function remoteBreadcrumbDetails(params: DatabaseParams): BreadcrumbDetai
];
}


export function tableBreadcrumbsDetails(
params: TableParams,
): BreadcrumbDetails[] {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,47 @@
import { QueryHandler } from "@dolthub/react-components";
import { RemoteFragment, useRemoteListQuery } from "@gen/graphql-types";
import { DatabaseParams } from "@lib/params";
import css from "./index.module.css";
import Row from "./Row";

type Props = {
params: DatabaseParams;
};

type InnerProps = {
remotes : RemoteFragment[];
remotes: RemoteFragment[];
};

function Inner({ remotes }: InnerProps) {
return (
<ul>
{remotes.map(remote => (
<li key={remote.name}>
<span>{remote.name}</span>
<span>{remote.url}</span>
<span>{remote.fetchSpecs}</span>
</li>
))}
</ul>
<div className={css.container}>
<div className={css.top}>
<h1>Remotes</h1>
</div>

{remotes.length ? (
<div className={css.tableParent}>
<table className={css.table}>
<thead>
<tr>
<th>Name</th>
<th>Url</th>
<th>Fetch Specs</th>
</tr>
</thead>
<tbody>
{remotes.map(r => (
<Row key={r._id} remote={r} />
))}
</tbody>
</table>
</div>
) : (
<p className={css.noRemotes} data-cy="remote-list-no-remotes">
No remotes found
</p>
)}
</div>
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { RemoteFragment } from "@gen/graphql-types";

type Props = {
remote: RemoteFragment;
};

export default function Row({ remote }: Props) {
return (
<tr>
<td>{remote.name}</td>
<td>{remote.url}</td>
<td>
{remote.fetchSpecs.map((fs, i) => (
<span key={fs}>
{fs}
{i < remote.fetchSpecs.length - 1 ? ", " : ""}
</span>
))}
</td>
</tr>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.container {
@apply mx-6;
}

.top {
@apply flex justify-between pt-6;
}

.tableParent {
@apply overflow-x-auto;
}

.table {
@apply my-8 min-w-[55rem] w-full;

tr {
@apply border-b-[6px] border-stone-50 relative;
}

th {
@apply font-semibold;
}

th,
td {
@apply pl-2 pr-4 py-2.5 text-left lg:pr-10;
}

td {
@apply bg-white text-stone-500;
}

th:first-child,
td:first-child {
@apply xl:pl-20;
}

th:last-child,
td:last-child {
@apply xl:pr-32;
}
}

.noRemotes {
@apply text-center text-lg m-6;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ export default function ForBranches({ params, newBranch }: Props): JSX.Element {
initialTabIndex={5}
params={params}
hideDefaultTable
smallHeaderBreadcrumbs={
<RemotesBreadcrumbs params={params} />
}
smallHeaderBreadcrumbs={<RemotesBreadcrumbs params={params} />}
routeRefChangeTo={urlParams => branches(urlParams)}
>
<NotDoltWrapper showNotDoltMsg feature={feature} bigMsg>
<RemotesPage params={params}/>
<RemotesPage params={params} />
</NotDoltWrapper>
</ForDefaultBranch>
);
Expand Down

0 comments on commit ce498be

Please sign in to comment.