From 3d27f77cd3765638c18589a28116e4e79a272c6c Mon Sep 17 00:00:00 2001 From: svilen Date: Wed, 28 Jan 2026 16:47:11 +0200 Subject: [PATCH] Add repositoryId to graph configuration save payload and clipboard URL resolve repo id for graph config Temp commit containing some logging needed to debug an issue related with visgraph not rendered if the current repo is different than the one in the link add logging for debugging purposes Add repositoryId handling to graph state restoration remove logging --- .../controllers/graphs-config.controller.js | 4 ++-- .../graphs-visualizations.controller.js | 15 ++++++++++----- .../src/js/angular/models/graphs/graphs-config.js | 6 ++++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/packages/legacy-workbench/src/js/angular/graphexplore/controllers/graphs-config.controller.js b/packages/legacy-workbench/src/js/angular/graphexplore/controllers/graphs-config.controller.js index 9ea7321282..5d8d39a524 100644 --- a/packages/legacy-workbench/src/js/angular/graphexplore/controllers/graphs-config.controller.js +++ b/packages/legacy-workbench/src/js/angular/graphexplore/controllers/graphs-config.controller.js @@ -277,9 +277,9 @@ function GraphConfigCtrl( } $scope.queryEditorIsDirty = false; if ($scope.isUpdate) { - $scope.updateGraphConfig($scope.newConfig.toSavePayload()); + $scope.updateGraphConfig($scope.newConfig.toSavePayload($repositories.getActiveRepository())); } else { - $scope.createGraphConfig($scope.newConfig.toSavePayload()); + $scope.createGraphConfig($scope.newConfig.toSavePayload($repositories.getActiveRepository())); } }); }; diff --git a/packages/legacy-workbench/src/js/angular/graphexplore/controllers/graphs-visualizations.controller.js b/packages/legacy-workbench/src/js/angular/graphexplore/controllers/graphs-visualizations.controller.js index 1f9e53e895..5639c997a9 100644 --- a/packages/legacy-workbench/src/js/angular/graphexplore/controllers/graphs-visualizations.controller.js +++ b/packages/legacy-workbench/src/js/angular/graphexplore/controllers/graphs-visualizations.controller.js @@ -2859,6 +2859,7 @@ function GraphsVisualizationsCtrl( name: $scope.lastSavedGraphName, data: data, shared: $scope.shared, + repositoryId: repositoryContextService.getSelectedRepository().id, }; if (graphToSave.id) { @@ -2968,8 +2969,11 @@ function GraphsVisualizationsCtrl( // Preserve existing query params and only set/override `saved` const currentSearch = $location.search(); - const newSearch = {...currentSearch, saved: graphToLoad.id}; - $location.search('saved', graphToLoad.id); + const newSearch = { + ...currentSearch, + saved: graphToLoad.id, + [REPOSITORY_ID_PARAM]: repositoryContextService.getSelectedRepository().id, + }; graph.restoreState(JSON.parse(graphToLoad.data)); if (!noHistory) { pushHistory(newSearch, {savedGraph: graphToLoad}); @@ -2977,9 +2981,10 @@ function GraphsVisualizationsCtrl( }; $scope.copyToClipboardSavedGraph = function(savedGraph) { - // TODO: Not sure we must add the repositoryId param here. - const url = [location.protocol, '//', location.host, location.pathname, '?saved=', savedGraph.id].join(''); - $scope.copyToClipboard(url); + const url = new URL(window.location.href); + url.searchParams.set('saved', savedGraph.id); + url.searchParams.set(REPOSITORY_ID_PARAM, repositoryContextService.getSelectedRepository().id); + $scope.copyToClipboard(url.toString()); }; function deleteSavedGraphHttp(savedGraph) { diff --git a/packages/legacy-workbench/src/js/angular/models/graphs/graphs-config.js b/packages/legacy-workbench/src/js/angular/models/graphs/graphs-config.js index b6c629982c..c50cfee423 100644 --- a/packages/legacy-workbench/src/js/angular/models/graphs/graphs-config.js +++ b/packages/legacy-workbench/src/js/angular/models/graphs/graphs-config.js @@ -140,9 +140,10 @@ export class GraphsConfig { /** * Converts this model to a payload JSON object needed for a save config operation. + * @param {string} repositoryId The repository identifier to which this config belongs. * @return {{owner: (string|undefined), shared: (boolean|undefined), startIRI: (string|undefined), resourceQuery: (string|undefined), startGraphQuery: (string|undefined), expandQuery: (string|undefined), description: (string|undefined), startIRILabel: (string|undefined), startQueryIncludeInferred: (boolean|undefined), resourcePropertiesQuery: (string|undefined), predicateLabelQuery: (string|undefined), startMode: (string|undefined), hint: (string|undefined), name: (string|undefined), id: (string|undefined), startQuerySameAs: (boolean|undefined)}} */ - toSavePayload() { + toSavePayload(repositoryId) { return { id: this.id, name: this.name, @@ -159,7 +160,8 @@ export class GraphsConfig { resourcePropertiesQuery: this.resourcePropertiesQuery, shared: this.shared, description: this.description, - hint: this.hint + hint: this.hint, + repositoryId: repositoryId, }; }