diff --git a/CHANGELOG.md b/CHANGELOG.md index 68985692..38d14ff0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - ## [2.5.0] - Unreleased ### Added - New UI for the basic mode Sync (#415) +- Allow changing namespaces and IPM package context from web UI (#280) ### Fixed - Instance wide settings are placed in proper global (#444) diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index 744c7f99..9b6405c7 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -2315,6 +2315,27 @@ ClassMethod Localize() } } +ClassMethod GetContexts() As %DynamicArray +{ + set contexts = [] + set namespaces = ..GetGitEnabledNamespaces() + set ptr = 0 + while $listnext(namespaces,ptr,value) { + do contexts.%Push(value) + } + + set query = "SELECT name from %Library.RoutineMgr_StudioOpenDialog('*.ZPM')" + set statement = ##class(%SQL.Statement).%New() + $$$ThrowOnError(statement.%Prepare(query, 0)) + set packagesResultSet = statement.%Execute() + throw:packagesResultSet.%SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(packagesResultSet.%SQLCODE,packagesResultSet.%Message) + while packagesResultSet.%Next() { + set package = packagesResultSet.Name + do contexts.%Push(package) + } + return contexts +} + ClassMethod ConfigureWeb() { set installNamespace = $Namespace @@ -2417,6 +2438,29 @@ ClassMethod UncommittedWithAction() As %Library.DynamicObject quit fileToOtherDevelopers } +/// Retrieve the list of Namespaces that have git enabled +ClassMethod GetGitEnabledNamespaces() As %String +{ + // Get all namespaces + set allNamespaces = "" + do ##class(%SYS.Namespace).ListAll(.allNamespaces) + + set enabledNamespaces = "" + set namespace = "" + for { + set namespace = $ORDER(allNamespaces(namespace)) + quit:namespace="" + try { + set sourceControlClass = ##class(%Studio.SourceControl.Interface).SourceControlClassGet(namespace) + } catch err { + set sourceControlClass = "" // user does not have access to this namespace + } + if (sourceControlClass = "SourceControl.Git.Extension") set enabledNamespaces = enabledNamespaces _ $listbuild(namespace) + } + + quit enabledNamespaces +} + ClassMethod BuildCEInstallationPackage(ByRef destination As %String) As %Status { #define sourcedir $System.Util.InstallDirectory()_"devuser/studio/templates/gitsourcecontrol/" @@ -2571,3 +2615,4 @@ ClassMethod BaselineExport(pCommitMessage = "", pPushToRemote = "") As %Status } } + diff --git a/cls/SourceControl/Git/WebUIDriver.cls b/cls/SourceControl/Git/WebUIDriver.cls index 8ee30946..5d8a2b17 100644 --- a/cls/SourceControl/Git/WebUIDriver.cls +++ b/cls/SourceControl/Git/WebUIDriver.cls @@ -27,7 +27,7 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out if $isobject($get(responseJSON)) { do responseJSON.%ToJSON(%data) } - } elseif $match(pathStart,"git-command|git|dirname|hostname|viewonly") { + } elseif $match(pathStart,"git-command|git|dirname|hostname|viewonly|contexts") { if (%request.Method = "GET") { set %data = ##class(%Stream.TmpCharacter).%New() // Things not handled from Python backend: @@ -76,6 +76,10 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out } elseif (pathStart = "dirname") { do %data.Write(##class(SourceControl.Git.Utils).TempFolder()) set handled = 1 + } elseif (pathStart = "contexts") { + set contexts = ##class(SourceControl.Git.Utils).GetContexts() + do contexts.%ToJSON(%data) + set handled = 1 } } elseif (%request.Method = "POST") { // Things not handled from Python backend: diff --git a/git-webui/release/share/git-webui/webui/css/git-webui.css b/git-webui/release/share/git-webui/webui/css/git-webui.css index aeb3a5b0..0a0043b7 100644 --- a/git-webui/release/share/git-webui/webui/css/git-webui.css +++ b/git-webui/release/share/git-webui/webui/css/git-webui.css @@ -180,10 +180,10 @@ body { border-top: 1px solid #1a1a1a; border-bottom: 1px solid #1a1a1a; color: #eeeeee; - padding-bottom: 6em; + padding-bottom: 100px; } #sidebar #sidebar-content > :first-child, -#sidebar #sidebar-content > :last-child { +#sidebar #sidebar-content > :nth-last-child(2) { border-top: 1px solid #5e5e5e; } #sidebar #sidebar-content h4:before { @@ -216,6 +216,17 @@ body { #sidebar #sidebar-content #sidebar-tags h4:before { content: url(../img/tag.svg); } +#sidebar #sidebar-content #sidebar-context h4:before { + content: url(../img/context.svg); +} +#sidebar #sidebar-content #sidebar-context { + position: absolute; + bottom: 50px; + width: 16.7em; + padding-bottom: 0.3rem; + margin-bottom: 0; + background-color: #333333; +} #sidebar #sidebar-content #sidebar-settings h4:before { content: url(../img/gear-fill.svg); } diff --git a/git-webui/release/share/git-webui/webui/js/git-webui.js b/git-webui/release/share/git-webui/webui/js/git-webui.js index e3a0ad90..9625c506 100644 --- a/git-webui/release/share/git-webui/webui/js/git-webui.js +++ b/git-webui/release/share/git-webui/webui/js/git-webui.js @@ -587,7 +587,99 @@ webui.SideBarView = function(mainView, noEventHandlers) { }) } - + self.changeContextGet = function() { + $.get("contexts", function(contextList) { + var contexts = JSON.parse(contextList); + self.changeContext(contexts); + }); + } + + self.changeContext = function(contexts) { + + function removePopup(popup) { + $(popup).children(".modal-fade").modal("hide"); + $(".modal-backdrop").remove(); + $("#changeContextModal").remove(); + } + + var popup = $( + '' + )[0]; + + $("body").append(popup); + var popupBody = $(".modal-body", popup)[0]; + webui.detachChildren(popupBody); + + $( + '
'+ + '
Select context for Git Source Control
' + + '' + + '
' + ).appendTo(popupBody); + + var selectDropdown = $(".custom-select", popupBody)[0]; + + contexts.forEach(function(context) { + $( + '' + ).appendTo(selectDropdown); + }) + + + var popupFooter = $(".modal-footer", popup)[0]; + webui.detachChildren(popupFooter); + + $( + '' + + '' + ).appendTo(popupFooter); + + $(popup).modal('show'); + + $('#changeContextModal').find('#cancelContextBtn', '.close').click(function() { + removePopup(popup); + }); + + $("#chooseContextBtn").on("click", function() { + self.updateContext($("#chosenContext").val()); + removePopup(popup); + }); + } + + self.getCurrentContext = function() { + var args = window.location.href.split("webuidriver.csp/")[1].split("/"); + var context = args[0]; + if (args[1] && (args[1].indexOf(".ZPM") != -1)) { + context = args[1]; + } + return context; + } + + self.updateContext = function(context) { + var urlParts = window.location.href.split("webuidriver.csp/"); + var args = urlParts[1].split("/"); + if (context.indexOf(".ZPM") != -1) { + args[1] = context; + } else { + args[0] = context; + args[1] = ""; + } + window.location = urlParts[0] + "webuidriver.csp/" + args.join("/"); + self.currentContext = context; + } + self.checkoutBranch = function(branchType, refName) { $("#confirm-branch-checkout").remove(); @@ -855,7 +947,7 @@ webui.SideBarView = function(mainView, noEventHandlers) { }; self.mainView = mainView; - + self.currentContext = self.getCurrentContext(); self.element = $( '