Skip to content

Commit ce2b04e

Browse files
refactor: remove legacy client (#4020)
Remove the legacy API client from renku-ui. Co-authored-by: Lorenzo Cavazzi <43481553+lorenzo-cavazzi@users.noreply.github.com>
1 parent 9d9bd51 commit ce2b04e

49 files changed

Lines changed: 90 additions & 4281 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

client/src/App.jsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,8 @@ export default function App(props) {
120120
return <Unavailable params={props.params} />;
121121
}
122122

123-
const { coreApiVersionedUrlConfig, socket } = props;
124123
const appContext = {
125-
client: props.client,
126-
coreApiVersionedUrlConfig,
127-
location: props.location,
128-
model: props.model,
129124
params: props.params,
130-
webSocket: socket,
131125
};
132126

133127
return (

client/src/api-client/errors.ts

Lines changed: 1 addition & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -16,89 +16,11 @@
1616
* limitations under the License.
1717
*/
1818

19-
class APIError extends Error {
20-
case: string | undefined;
21-
response: Response | undefined;
22-
error: unknown;
23-
errorData: unknown;
24-
25-
constructor(arg: string | undefined = undefined) {
26-
super(arg || "Renku API error");
27-
}
28-
}
29-
30-
const API_ERRORS = {
19+
export const API_ERRORS = {
3120
unauthorizedError: "UNAUTHORIZED",
3221
forbiddenError: "FORBIDDEN",
3322
notFoundError: "NOT_FOUND",
3423
internalServerError: "SERVER_ERROR",
3524
networkError: "NETWORK_PROBLEM",
3625
authExpired: "AUTH_EXPIRED",
3726
};
38-
39-
function throwAuthError(response: Response) {
40-
const error = new APIError();
41-
error.case = API_ERRORS.authExpired;
42-
error.response = response;
43-
return Promise.reject(error);
44-
}
45-
46-
function throwErrorWithData(response: Response, data: unknown) {
47-
let error;
48-
switch (response.status) {
49-
case 401:
50-
error = new APIError();
51-
error.case = API_ERRORS.unauthorizedError;
52-
break;
53-
case 403:
54-
error = new APIError();
55-
error.case = API_ERRORS.forbiddenError;
56-
break;
57-
case 404:
58-
error = new APIError();
59-
error.case = API_ERRORS.notFoundError;
60-
break;
61-
case 500:
62-
error = new APIError();
63-
error.case = API_ERRORS.internalServerError;
64-
break;
65-
default:
66-
error = new APIError();
67-
}
68-
error.response = response;
69-
error.errorData = data;
70-
return Promise.reject(error);
71-
}
72-
73-
function throwAPIErrors(response: Response) {
74-
const contentType = response.headers.get("Content-Type");
75-
// TODO The default should be to check for type application/json
76-
// but I want to make a more minimal change to the code right now.
77-
if (contentType === "text/html")
78-
return response.text().then((d) => throwErrorWithData(response, d));
79-
80-
return response.json().then((d) => throwErrorWithData(response, d));
81-
}
82-
83-
function alertAPIErrors(error: APIError) {
84-
switch (error.case) {
85-
case API_ERRORS.forbiddenError:
86-
throw Error(
87-
"You don't have the necessary permission to view this information or perform this action."
88-
);
89-
case API_ERRORS.notFoundError:
90-
throw Error("We could not find the requested resource on the server.");
91-
case API_ERRORS.internalServerError:
92-
throw Error(
93-
"There is a problem with the server - please try again later."
94-
);
95-
case API_ERRORS.networkError:
96-
throw Error(
97-
"There seems to be problem with your network connection. Please check and try again."
98-
);
99-
default:
100-
// No alert on default exception
101-
}
102-
}
103-
104-
export { APIError, API_ERRORS, alertAPIErrors, throwAPIErrors, throwAuthError };

client/src/api-client/index.js

Lines changed: 0 additions & 258 deletions
This file was deleted.

0 commit comments

Comments
 (0)