Skip to content

Commit 863ca0a

Browse files
committed
OPENIG-1493 Infer base path value from the Studio’s URL
1 parent 8e1e49c commit 863ca0a

File tree

7 files changed

+53
-21
lines changed

7 files changed

+53
-21
lines changed

openig-ui/src/main/js/org/forgerock/openig/ui/admin/models/RouteModel.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@ define([
1818
"jquery",
1919
"lodash",
2020
"backbone",
21-
"org/forgerock/openig/ui/common/util/Constants",
21+
"org/forgerock/openig/ui/admin/services/ServerUrls",
2222
"org/forgerock/openig/ui/admin/services/ServerInfoService"
2323
], (
2424
$,
2525
_,
2626
Backbone,
27-
Constants,
27+
serverUrls,
2828
server
2929
) => (
3030
/* Define Route structure + add defaults, constants, orders */
3131
class RouteModel extends Backbone.Model {
3232
constructor (options) {
3333
super(options);
34-
this.url = `${Constants.systemObjectsPath}/ui/record`;
34+
this.url = `${serverUrls.systemObjectsPath}/ui/record`;
3535
}
3636

3737
get idAttribute () { return "_id"; }

openig-ui/src/main/js/org/forgerock/openig/ui/admin/models/RoutesCollection.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@
1717
define([
1818
"jquery",
1919
"backbone",
20-
"org/forgerock/commons/ui/common/util/Constants",
20+
"org/forgerock/openig/ui/admin/services/ServerUrls",
2121
"org/forgerock/openig/ui/admin/models/RouteModel"
2222
], (
2323
$,
2424
Backbone,
25-
Constants,
25+
serverUrls,
2626
RouteModel
2727
) => {
2828
/* Get and keep Routes */
2929
class RoutesCollection extends Backbone.Collection {
3030
constructor () {
3131
super();
32-
this.url = `${Constants.systemObjectsPath}/ui/record`;
32+
this.url = `${serverUrls.systemObjectsPath}/ui/record`;
3333
this.model = RouteModel;
3434
this.routesCache = {};
3535
}

openig-ui/src/main/js/org/forgerock/openig/ui/admin/models/ServerRouteModel.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616

1717
define([
1818
"backbone",
19-
"org/forgerock/openig/ui/common/util/Constants"
19+
"org/forgerock/openig/ui/admin/services/ServerUrls"
2020
], (
2121
Backbone,
22-
Constants
22+
serverUrls
2323
) => (
2424
Backbone.Model.extend({
25-
url: `${Constants.systemObjectsPath}/_router/routes`,
25+
url: `${serverUrls.systemObjectsPath}/_router/routes`,
2626
idAttribute: "_id",
2727

2828
getMVCCRev () {

openig-ui/src/main/js/org/forgerock/openig/ui/admin/models/ServerRoutesCollection.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ define([
1818
"jquery",
1919
"lodash",
2020
"backbone",
21-
"org/forgerock/openig/ui/common/util/Constants",
21+
"org/forgerock/openig/ui/admin/services/ServerUrls",
2222
"org/forgerock/openig/ui/admin/models/ServerRouteModel"
2323
], (
2424
$,
2525
_,
2626
Backbone,
27-
Constants,
27+
serverUrls,
2828
ServerRouteModel
2929
) => {
3030
/* Collection of routes */
3131
const ServerRoutesCollection = Backbone.Collection.extend({
32-
url: `${Constants.systemObjectsPath}/_router/routes`,
32+
url: `${serverUrls.systemObjectsPath}/_router/routes`,
3333
model: ServerRouteModel,
3434
parse (response) {
3535
return response.result;

openig-ui/src/main/js/org/forgerock/openig/ui/admin/services/ServerInfoService.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616

1717
define([
1818
"jquery",
19-
"org/forgerock/commons/ui/common/util/Constants",
19+
"org/forgerock/openig/ui/admin/services/ServerUrls",
2020
"org/forgerock/commons/ui/common/main/AbstractDelegate"
2121
], (
2222
$,
23-
Constants,
23+
serverUrls,
2424
AbstractDelegate
2525
) => {
2626
class ServerInfoService {
2727
constructor () {
28-
this.infoDelegate = new AbstractDelegate(`${Constants.apiPath}/info`);
28+
this.infoDelegate = new AbstractDelegate(`${serverUrls.apiPath}/info`);
2929
}
3030

3131
getInfo () {
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* The contents of this file are subject to the terms of the Common Development and
3+
* Distribution License (the License). You may not use this file except in compliance with the
4+
* License.
5+
*
6+
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
7+
* specific language governing permission and limitations under the License.
8+
*
9+
* When distributing Covered Software, include this CDDL Header Notice in each file and include
10+
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
11+
* Header, with the fields enclosed by brackets [] replaced by your own identifying
12+
* information: "Portions copyright [year] [name of copyright owner]".
13+
*
14+
* Copyright 2016 ForgeRock AS.
15+
*/
16+
17+
define([
18+
"org/forgerock/commons/ui/common/util/URIUtils"
19+
], (
20+
URIUtils
21+
) => {
22+
class ServerUrls {
23+
constructor (pathname) {
24+
// Infer base path from URL
25+
const index = pathname.indexOf("/studio");
26+
this.context = pathname.substring(0, index);
27+
}
28+
29+
get apiPath () {
30+
return `${this.context}/api`;
31+
}
32+
33+
get systemObjectsPath () {
34+
return `${this.apiPath}/system/objects`;
35+
}
36+
}
37+
return new ServerUrls(URIUtils.getCurrentPathName());
38+
});

openig-ui/src/main/js/org/forgerock/openig/ui/common/util/Constants.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ define([
1818
"org/forgerock/commons/ui/common/util/Constants"
1919
], (commonConstants) => {
2020

21-
commonConstants.context = "openig";
22-
23-
commonConstants.apiPath = "/openig/api";
24-
25-
commonConstants.systemObjectsPath = `${commonConstants.apiPath}/system/objects`;
26-
2721
commonConstants.DOC_URL = "https://backstage.forgerock.com/#!/docs/openig/5.0/";
2822

2923
commonConstants.defaultFiltersOrder = {

0 commit comments

Comments
 (0)