Skip to content

Commit 8361cb9

Browse files
committed
Remove unused hub client
1 parent e716fd5 commit 8361cb9

File tree

9 files changed

+4
-27
lines changed

9 files changed

+4
-27
lines changed

src/common/AxiosContext.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import { createContext, useContext } from 'react';
22
import { AxiosClient } from './axiosclient';
33

44
export const AxiosContext = createContext<{
5-
hubClient: AxiosClient;
65
serviceClient: AxiosClient;
7-
}>({ hubClient: new AxiosClient({}), serviceClient: new AxiosClient({}) });
6+
}>({ serviceClient: new AxiosClient({}) });
87

98
export const useAxios = () => {
109
return useContext(AxiosContext);

src/common/axiosclient.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import urlJoin from 'url-join';
22
import { encodeUriComponents } from './utils';
33
import axios, { AxiosInstance } from 'axios';
44

5-
export const API_PREFIX = 'api';
6-
export const SPAWN_PREFIX = 'spawn';
75
export class AxiosClient {
86
constructor(options: AxiosClient.IOptions) {
97
this._baseUrl = options.baseUrl ?? '';
@@ -15,14 +13,13 @@ export class AxiosClient {
1513

1614
async request<T = any>(args: {
1715
method: 'get' | 'post' | 'put' | 'option' | 'delete';
18-
prefix?: 'api' | 'spawn';
1916
path: string;
2017
query?: string;
2118
data?: { [key: string]: any } | FormData;
2219
params?: { [key: string]: string };
2320
}): Promise<T> {
2421
const { method, path, params } = args;
25-
const prefix = args.prefix ?? '';
22+
const prefix = 'api';
2623
const data = args.data ?? {};
2724
let url = urlJoin(prefix, encodeUriComponents(path));
2825
if (args.query) {

src/environments/App.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ export interface IAppProps {
2020
export default function App(props: IAppProps) {
2121
const jhData = useJupyterhub();
2222

23-
const hubClient = useMemo(() => {
24-
const baseUrl = jhData.hubPrefix;
25-
const xsrfToken = jhData.xsrfToken;
26-
return new AxiosClient({ baseUrl, xsrfToken });
27-
}, [jhData]);
28-
2923
const serviceClient = useMemo(() => {
3024
const baseUrl = jhData.servicePrefix;
3125
const xsrfToken = jhData.xsrfToken;
@@ -34,7 +28,7 @@ export default function App(props: IAppProps) {
3428

3529
return (
3630
<ThemeProvider theme={customTheme}>
37-
<AxiosContext.Provider value={{ hubClient, serviceClient }}>
31+
<AxiosContext.Provider value={{ serviceClient }}>
3832
<ScopedCssBaseline>
3933
<Stack sx={{ padding: 1 }} spacing={1}>
4034
<NewEnvironmentDialog

src/environments/NewEnvironmentDialog.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
} from '@mui/material';
1616
import { Fragment, memo, useCallback, useMemo, useState } from 'react';
1717

18-
import { API_PREFIX } from '../common/axiosclient';
1918
import { useAxios } from '../common/AxiosContext';
2019
import { SmallTextField } from '../common/SmallTextField';
2120
import { ENV_PREFIX } from './types';
@@ -174,7 +173,6 @@ function _NewEnvironmentDialog(props: INewEnvironmentDialogProps) {
174173
data.password = data.password ?? '';
175174
const response = await axios.serviceClient.request({
176175
method: 'post',
177-
prefix: API_PREFIX,
178176
path: ENV_PREFIX,
179177
data
180178
});

src/environments/RemoveEnvironmentButton.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { memo, useCallback } from 'react';
55
import { useAxios } from '../common/AxiosContext';
66
import { ButtonWithConfirm } from '../common/ButtonWithConfirm';
77
import { ENV_PREFIX } from './types';
8-
import { API_PREFIX } from '../common/axiosclient';
98

109
interface IRemoveEnvironmentButton {
1110
name: string;
@@ -18,7 +17,6 @@ function _RemoveEnvironmentButton(props: IRemoveEnvironmentButton) {
1817
const removeEnv = useCallback(async () => {
1918
const response = await axios.serviceClient.request({
2019
method: 'delete',
21-
prefix: API_PREFIX,
2220
path: ENV_PREFIX,
2321
data: { name: props.image }
2422
});

src/servers/App.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ export interface IAppProps {
2222
export default function App(props: IAppProps) {
2323
const jhData = useJupyterhub();
2424

25-
const hubClient = useMemo(() => {
26-
const baseUrl = jhData.hubPrefix;
27-
const xsrfToken = jhData.xsrfToken;
28-
return new AxiosClient({ baseUrl, xsrfToken });
29-
}, [jhData]);
30-
3125
const serviceClient = useMemo(() => {
3226
const baseUrl = jhData.servicePrefix;
3327
const xsrfToken = jhData.xsrfToken;
@@ -36,7 +30,7 @@ export default function App(props: IAppProps) {
3630

3731
return (
3832
<ThemeProvider theme={customTheme}>
39-
<AxiosContext.Provider value={{ hubClient, serviceClient }}>
33+
<AxiosContext.Provider value={{ serviceClient }}>
4034
<ScopedCssBaseline>
4135
<Stack sx={{ padding: 1 }} spacing={1}>
4236
<NewServerDialog

src/servers/NewServerDialog.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ function _NewServerDialog(props: INewServerDialogProps) {
7676
setLoading(true);
7777
await axios.serviceClient.request({
7878
method: 'post',
79-
prefix: 'api',
8079
path: SERVER_PREFIX,
8180
data
8281
});

src/servers/OpenServerButton.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ function _OpenServerButton(props: IOpenServerButton) {
2626
try {
2727
await axios.serviceClient.request({
2828
method: 'post',
29-
prefix: 'api',
3029
path: SERVER_PREFIX,
3130
data
3231
});

src/servers/RemoveServerButton.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ function _RemoveServerButton(props: IRemoveServerButton) {
1919
await axios.serviceClient.request({
2020
method: 'delete',
2121
path: SERVER_PREFIX,
22-
prefix: 'api',
2322
data: {
2423
userName: jhData.user,
2524
serverName: props.server

0 commit comments

Comments
 (0)