Skip to content

Commit

Permalink
Merge branch 'master' into 2058-env-variables-in-share-link
Browse files Browse the repository at this point in the history
  • Loading branch information
andre-code authored Oct 12, 2022
2 parents 217f096 + 364aa5d commit 3469fb1
Show file tree
Hide file tree
Showing 11 changed files with 435 additions and 27 deletions.
1 change: 1 addition & 0 deletions client/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
"ipython",
"javascript",
"jpeg",
"jsonrpc",
"jszip",
"jumbotron",
"jupyter",
Expand Down
85 changes: 85 additions & 0 deletions client/src/features/session/sidecarApi.ts
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 };
2 changes: 0 additions & 2 deletions client/src/model/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
import immutableUpdate from "immutability-helper";
import { createStore } from "../utils/helpers/EnhancedState";
// import { Component } from 'react';
// // Todo: Resolve dependency from our custom store
// import { createStore } from '../utils/helpers/EnhancedState';


const PropertyName = {
Expand Down
3 changes: 3 additions & 0 deletions client/src/notebooks/Notebooks.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import { DEFAULT_ENV_VARIABLES } from "../model/RenkuModels";
*/

function mapSessionStateToProps(state, ownProps) {
const metadata = state.stateModel.project.metadata;
const notebooks = state.stateModel.notebooks.notebooks;
const available = !!notebooks.all[ownProps.target];
const notebook = {
Expand All @@ -62,6 +63,7 @@ function mapSessionStateToProps(state, ownProps) {
logs: state.stateModel.notebooks.logs
};
return {
accessLevel: metadata.accessLevel,
handlers: ownProps.handlers,
target: ownProps.target,
filters: state.stateModel.notebooks.filters,
Expand Down Expand Up @@ -127,6 +129,7 @@ class ShowSession extends Component {
return <NotebooksDisabled logged={this.userLogged} />;
return (
<ShowSessionMapped
isLogged={this.userLogged}
target={this.target}
handlers={this.handlers}
store={this.model.reduxStore}
Expand Down
Loading

0 comments on commit 3469fb1

Please sign in to comment.