-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Graphql, Web: Add remotes tab, list, add, and delete remotes #313
Merged
Merged
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
e8a4f14
list remotes
liuliu-dev 5f6d76b
lint fix
liuliu-dev ce498be
remotes list ui
liuliu-dev 1b90806
params
liuliu-dev 0cd26e5
infinite scroll, clean up
liuliu-dev 9013727
generate types
liuliu-dev 2e79a55
null
liuliu-dev 8c2a8a5
use branch list ui
liuliu-dev 4c6fd12
remove params column
liuliu-dev d8fd1b3
add remote
liuliu-dev 67175de
delete remote
liuliu-dev 0ce40ff
reorganize
liuliu-dev d567853
Merge pull request #314 from dolthub/liuliu/add-remote
liuliu-dev 40d89cb
pagination
liuliu-dev 74ce44a
add description
liuliu-dev 37c6e40
database type
liuliu-dev c09f194
link
liuliu-dev 75532ca
place holder
liuliu-dev f067008
return chained, queries
liuliu-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Field, ID, ObjectType } from "@nestjs/graphql"; | ||
import { __Type } from "graphql"; | ||
import { getNextOffset, ROW_LIMIT } from "../utils"; | ||
import { RawRow } from "../queryFactory/types"; | ||
import { DBArgsWithOffset, ListOffsetRes } from "../utils/commonTypes"; | ||
|
||
@ObjectType() | ||
export class Remote { | ||
@Field(_type => ID) | ||
_id: string; | ||
|
||
@Field() | ||
name: string; | ||
|
||
@Field() | ||
url: string; | ||
|
||
@Field(_type => [String], { nullable: true }) | ||
fetchSpecs?: string[]; | ||
} | ||
|
||
@ObjectType() | ||
export class RemoteList extends ListOffsetRes { | ||
@Field(_type => [Remote]) | ||
list: Remote[]; | ||
} | ||
|
||
export function fromDoltRemotesRow(databaseName: string, r: RawRow): Remote { | ||
return { | ||
_id: `databases/${databaseName}/remotes/${r.name}`, | ||
name: r.name, | ||
url: r.url, | ||
fetchSpecs: r.fetch_specs, | ||
}; | ||
} | ||
|
||
export function getRemoteListRes( | ||
remotes: RawRow[], | ||
args: DBArgsWithOffset, | ||
): RemoteList { | ||
return { | ||
list: remotes | ||
.slice(0, ROW_LIMIT) | ||
.map(l => fromDoltRemotesRow(args.databaseName, l)), | ||
nextOffset: getNextOffset(remotes.length, args.offset ?? 0), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { | ||
Args, | ||
ArgsType, | ||
Field, | ||
Mutation, | ||
Query, | ||
Resolver, | ||
} from "@nestjs/graphql"; | ||
import { ConnectionProvider } from "../connections/connection.provider"; | ||
import { DBArgs, DBArgsWithOffset, RemoteArgs } from "../utils/commonTypes"; | ||
import { getRemoteListRes, Remote, RemoteList } from "./remote.model"; | ||
|
||
@ArgsType() | ||
export class AddRemoteArgs extends DBArgs { | ||
@Field() | ||
remoteName: string; | ||
|
||
@Field() | ||
remoteUrl: string; | ||
} | ||
|
||
@Resolver(_of => Remote) | ||
export class RemoteResolver { | ||
constructor(private readonly conn: ConnectionProvider) {} | ||
|
||
@Query(_returns => RemoteList) | ||
async remotes(@Args() args: DBArgsWithOffset): Promise<RemoteList> { | ||
tbantle22 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const conn = this.conn.connection(); | ||
|
||
const res = await conn.getRemotes({ ...args, offset: args.offset ?? 0 }); | ||
return getRemoteListRes(res, args); | ||
} | ||
|
||
@Mutation(_returns => String) | ||
async addRemote(@Args() args: AddRemoteArgs): Promise<string> { | ||
const conn = this.conn.connection(); | ||
await conn.addRemote(args); | ||
return args.remoteName; | ||
} | ||
|
||
@Mutation(_returns => Boolean) | ||
async deleteRemote(@Args() args: RemoteArgs): Promise<boolean> { | ||
const conn = this.conn.connection(); | ||
await conn.callDeleteRemote(args); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ export const tabs = [ | |
"Commit Log", | ||
"Releases", | ||
"Pull Requests", | ||
"Remotes", | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
web/renderer/components/breadcrumbs/RemotesBreadcrumbs.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { DatabaseParams } from "@lib/params"; | ||
import Breadcrumbs from "."; | ||
import { remoteBreadcrumbDetails } from "./breadcrumbDetails"; | ||
|
||
type Props = { | ||
params: DatabaseParams; | ||
className?: string; | ||
}; | ||
|
||
export default function RemotesBreadcrumbs(props: Props) { | ||
return ( | ||
<Breadcrumbs | ||
{...props} | ||
aria-label="db-remotes-breadcrumbs" | ||
data-cy="db-remotes-breadcrumbs" | ||
breadcrumbs={remoteBreadcrumbDetails(props.params)} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need the
let
here? It can all just be chained together?