Skip to content

Commit

Permalink
Add support for URL interpolation when setting up panels
Browse files Browse the repository at this point in the history
  • Loading branch information
szschaler authored Jan 5, 2024
1 parent 3cfbe06 commit 2ce3611
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions platform/src/ActivityManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,40 @@ class ActivityManager {
return null;
}

/**
* Interpolate someString using information from session storage.
*
* @param {*} someString the string to be changed
*/
interpolate(someString) {
let result = someString;

// console.log (`Asked to interpolate ${someString}.`);

for (let i = 0; i < sessionStorage.length; i++) {
let currentKey = sessionStorage.key(i);

// console.log(`Interpolating for key ${currentKey}.`);

if (currentKey !== "isAuthenticated") {
// TODO: This *assumes* this can only be a panel ID, but that may change over time,
// so this code may need to be improved to only allow access to panel IDs explicitly
result = result.replace("${ID-" + currentKey + "}", sessionStorage.getItem(currentKey));
}
}

// console.log(`Result of interpolation: ${result}.`);
return result;
}

/* resolve panel refs recursively because of CompositePanels */
resolveRef(panelList) {
for ( let apanel of panelList ){

if (apanel.file != null) {
apanel.url = new URL( apanel.file, this.activitiesUrl).href;
let file = this.fetchFile(apanel.file);
if (apanel.file != null) {
let panelURLString = this.interpolate(apanel.file);
apanel.url = new URL(panelURLString, this.activitiesUrl).href;
let file = this.fetchFile(panelURLString);
apanel.file = file.content;
apanel.sha = file.sha;
};
Expand Down Expand Up @@ -523,4 +548,4 @@ class ActivityManager {



export {ActivityManager};
export {ActivityManager};

0 comments on commit 2ce3611

Please sign in to comment.