-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 2058-env-variables-in-share-link
- Loading branch information
Showing
11 changed files
with
435 additions
and
27 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,6 +166,7 @@ | |
"ipython", | ||
"javascript", | ||
"jpeg", | ||
"jsonrpc", | ||
"jszip", | ||
"jumbotron", | ||
"jupyter", | ||
|
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,85 @@ | ||
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; | ||
|
||
type HealthState = { status: string }; | ||
|
||
interface JsonRpcResult { | ||
id: number; | ||
jsonRpc: string; | ||
} | ||
|
||
interface GitStatusResult extends JsonRpcResult { | ||
result: { | ||
ahead: number; | ||
behind: number; | ||
branch: string; | ||
clean: boolean; | ||
commit: string; | ||
status: string; | ||
}; | ||
} | ||
|
||
interface SaveArgs { | ||
serverName: string; | ||
message?: string; | ||
} | ||
|
||
interface SaveResult extends JsonRpcResult { | ||
result: string; | ||
error?: { | ||
code: number; | ||
message: string; | ||
}; | ||
} | ||
|
||
export const sessionSidecarApi = createApi({ | ||
reducerPath: "sessionSidecarApi", | ||
baseQuery: fetchBaseQuery({ baseUrl: "/sessions/" }), | ||
tagTypes: [], | ||
keepUnusedDataFor: 0, | ||
endpoints: (builder) => ({ | ||
gitStatus: builder.query<GitStatusResult, string>({ | ||
query: (serverName: string) => { | ||
const body = { | ||
id: 0, | ||
jsonrpc: "2.0", | ||
method: "git/get_status", | ||
}; | ||
return { | ||
body, | ||
method: "POST", | ||
url: `${serverName}/sidecar/jsonrpc`, | ||
}; | ||
}, | ||
}), | ||
health: builder.query<HealthState, string>({ | ||
query: (serverName: string) => { | ||
return { | ||
url: `${serverName}/sidecar/health`, | ||
}; | ||
}, | ||
}), | ||
renkuSave: builder.mutation<SaveResult, SaveArgs>({ | ||
query: (args) => { | ||
const body = { | ||
id: 0, | ||
jsonrpc: "2.0", | ||
method: "renku/run", | ||
params: { | ||
command_name: "save", | ||
message: args.message, | ||
}, | ||
}; | ||
return { | ||
body, | ||
method: "POST", | ||
url: `${args.serverName}/sidecar/jsonrpc`, | ||
}; | ||
}, | ||
}), | ||
}), | ||
}); | ||
|
||
export const { useGitStatusQuery, useHealthQuery, useRenkuSaveMutation } = | ||
sessionSidecarApi; | ||
|
||
export type { GitStatusResult, HealthState }; |
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.