Skip to content

Commit a3e5f72

Browse files
authored
Merge pull request #21264 from guerler/remove_js_app_mako
Move js-client bootstrapping to FastAPI
2 parents 05bd453 + dd91149 commit a3e5f72

55 files changed

Lines changed: 457 additions & 1200 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/api/client/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { getAppRoot } from "@/onload/loadConfig";
66

77
function getBaseUrl() {
88
const isTest = process.env.NODE_ENV === "test";
9-
return isTest ? window.location.origin : getAppRoot(undefined, true);
9+
return isTest ? window.location.origin : getAppRoot().replace(/\/$/, "");
1010
}
1111

1212
function apiClientFactory() {

client/src/api/schema/schema.ts

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6477,6 +6477,23 @@ export interface paths {
64776477
patch?: never;
64786478
trace?: never;
64796479
};
6480+
"/context": {
6481+
parameters: {
6482+
query?: never;
6483+
header?: never;
6484+
path?: never;
6485+
cookie?: never;
6486+
};
6487+
/** Return bootstrapped client context */
6488+
get: operations["index_context_get"];
6489+
put?: never;
6490+
post?: never;
6491+
delete?: never;
6492+
options?: never;
6493+
head?: never;
6494+
patch?: never;
6495+
trace?: never;
6496+
};
64806497
"/ga4gh/drs/v1/objects/{object_id}": {
64816498
parameters: {
64826499
query?: never;
@@ -8213,6 +8230,19 @@ export interface components {
82138230
*/
82148231
name: string;
82158232
};
8233+
/** ContextResponse */
8234+
ContextResponse: {
8235+
/** Config */
8236+
config: {
8237+
[key: string]: unknown;
8238+
};
8239+
/** Session Csrf Token */
8240+
session_csrf_token?: string | null;
8241+
/** User */
8242+
user: {
8243+
[key: string]: unknown;
8244+
};
8245+
};
82168246
/**
82178247
* ConvertedDatasetsMap
82188248
* @description Map of `file extension` -> `converted dataset encoded id`
@@ -45240,6 +45270,47 @@ export interface operations {
4524045270
};
4524145271
};
4524245272
};
45273+
index_context_get: {
45274+
parameters: {
45275+
query?: never;
45276+
header?: {
45277+
/** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */
45278+
"run-as"?: string | null;
45279+
};
45280+
path?: never;
45281+
cookie?: never;
45282+
};
45283+
requestBody?: never;
45284+
responses: {
45285+
/** @description Successful Response */
45286+
200: {
45287+
headers: {
45288+
[name: string]: unknown;
45289+
};
45290+
content: {
45291+
"application/json": components["schemas"]["ContextResponse"];
45292+
};
45293+
};
45294+
/** @description Request Error */
45295+
"4XX": {
45296+
headers: {
45297+
[name: string]: unknown;
45298+
};
45299+
content: {
45300+
"application/json": components["schemas"]["MessageExceptionModel"];
45301+
};
45302+
};
45303+
/** @description Server Error */
45304+
"5XX": {
45305+
headers: {
45306+
[name: string]: unknown;
45307+
};
45308+
content: {
45309+
"application/json": components["schemas"]["MessageExceptionModel"];
45310+
};
45311+
};
45312+
};
45313+
};
4524345314
get_object_ga4gh_drs_v1_objects__object_id__get: {
4524445315
parameters: {
4524545316
query?: never;

client/src/onload/globalInits/initSentry.js renamed to client/src/app/addons/sentry.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ import Vue from "vue";
77
*
88
* @param {object} config Galaxy configuration object
99
*/
10-
export const initSentry = (galaxy, config) => {
10+
export async function initSentry(Galaxy, router) {
1111
console.log("initSentry");
12-
if (config.sentry) {
13-
const router = galaxy.router;
14-
const { sentry_dsn_public, email } = config.sentry;
15-
let release = galaxy.config.version_major;
16-
if (galaxy.config.version_minor) {
17-
release += `.${galaxy.config.version_minor}`;
12+
const config = Galaxy.config;
13+
if (config.sentry_dsn_public) {
14+
const sentry_dsn_public = config.sentry_dsn_public;
15+
const email = Galaxy.user.get("email");
16+
let release = Galaxy.config.version_major;
17+
if (Galaxy.config.version_minor) {
18+
release += `.${Galaxy.config.version_minor}`;
1819
}
1920
Sentry.init({
2021
Vue,
@@ -37,6 +38,6 @@ export const initSentry = (galaxy, config) => {
3738
});
3839
});
3940
}
40-
galaxy.Sentry = Sentry;
41+
Galaxy.Sentry = Sentry;
4142
}
42-
};
43+
}

client/src/onload/globalInits/onloadWebhooks.js renamed to client/src/app/addons/webhooks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { appendScriptStyle } from "@/utils/utils";
22
import { loadWebhooks } from "@/utils/webhooks";
33

4-
export async function onloadWebhooks(Galaxy) {
4+
export async function initWebhooks(Galaxy) {
55
if (Galaxy.config.enable_webhooks) {
66
const webhooks = await loadWebhooks("onload");
77
webhooks.forEach((webhook) => {

client/src/app/app.test.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,49 @@ import { suppressDebugConsole } from "@tests/vitest/helpers";
33
import { beforeEach, describe, expect, test } from "vitest";
44

55
import { getGalaxyInstance, setGalaxyInstance } from "@/app";
6+
import { GalaxyApp } from "@/app/galaxy";
67

78
export function setupTestGalaxy(galaxyOptions_ = null) {
89
galaxyOptions_ = galaxyOptions_ || galaxyOptions;
9-
setGalaxyInstance((GalaxyApp) => new GalaxyApp(galaxyOptions_));
10+
const app = new GalaxyApp(galaxyOptions_);
11+
setGalaxyInstance(app);
1012
}
1113

12-
// the app console debugs make sense but we just don't want to see them in test
13-
// output.
14+
// suppress console noise
1415
suppressDebugConsole();
1516

16-
describe("App base construction/initializiation defaults", () => {
17+
describe("App base construction/initialization defaults", () => {
1718
beforeEach(() => {
1819
setupTestGalaxy(galaxyOptions);
1920
});
2021

21-
test("App base construction/initializiation defaults", function () {
22+
test("App base construction/initialization defaults", () => {
2223
const app = getGalaxyInstance();
2324
expect(app.options && typeof app.options === "object").toBeTruthy();
2425
expect(app.config && typeof app.config === "object").toBeTruthy();
2526
expect(app.user && typeof app.config === "object").toBeTruthy();
2627
expect(app.localize).toBe(window._l);
2728
});
2829

29-
test("App base default options", function () {
30+
test("App base default options", () => {
3031
const app = getGalaxyInstance();
3132
expect(app.options !== undefined && typeof app.options === "object").toBeTruthy();
3233
expect(app.options.root).toBe("/");
3334
expect(app.options.patchExisting).toBe(true);
3435
});
3536

36-
// // We no longer want this behavior, but leaving the test to express that
37-
test("App base will patch in attributes from existing Galaxy objects", function () {
37+
// we no longer patch attributes from existing Galaxy objects, test expresses that
38+
test("App base will patch in attributes from existing Galaxy objects", () => {
3839
const existingApp = getGalaxyInstance();
3940
existingApp.foo = 123;
4041

41-
const newApp = setGalaxyInstance((GalaxyApp) => {
42-
return new GalaxyApp();
43-
});
42+
const newApp = new GalaxyApp();
43+
setGalaxyInstance(newApp);
4444

45-
expect(newApp.foo === 123).toBeTruthy();
45+
expect(newApp.foo).toBeUndefined();
4646
});
4747

48-
test("App base config", function () {
48+
test("App base config", () => {
4949
const app = getGalaxyInstance();
5050
expect(app.config && typeof app.config === "object").toBeTruthy();
5151
expect(app.config.allow_user_deletion).toBe(false);
@@ -54,9 +54,9 @@ describe("App base construction/initializiation defaults", () => {
5454
expect(app.config.ftp_upload_site).toBe(null);
5555
});
5656

57-
test("App base user", function () {
57+
test("App base user", () => {
5858
const app = getGalaxyInstance();
5959
expect(app.user !== undefined && typeof app.user === "object").toBeTruthy();
60-
expect(app.user.isAdmin() === false).toBeTruthy();
60+
expect(app.user.isAdmin()).toBe(false);
6161
});
6262
});

0 commit comments

Comments
 (0)