From cf44cef9b90d1ee11a05cddfa13fb2b6c7d59e3a Mon Sep 17 00:00:00 2001 From: Rutvik Saptarshi Date: Mon, 18 Sep 2023 14:01:46 -0400 Subject: [PATCH 1/2] status menu item is now available --- cls/SourceControl/Git/Extension.cls | 44 ++++++++++++++++------------- cls/SourceControl/Git/Utils.cls | 8 ++++-- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/cls/SourceControl/Git/Extension.cls b/cls/SourceControl/Git/Extension.cls index 51073a9e..f1395363 100644 --- a/cls/SourceControl/Git/Extension.cls +++ b/cls/SourceControl/Git/Extension.cls @@ -10,6 +10,7 @@ XData Menu { + @@ -43,7 +44,7 @@ XData Menu Method UserAction(Type As %Integer, Name As %String, InternalName As %String, SelectedText As %String, ByRef Action As %String, ByRef Target As %String, ByRef Msg As %String, ByRef Reload As %Boolean) As %Status { #dim ec as %Status = $$$OK - #dim menu as %Status = $piece(Name, ",", 1) + #dim menu as %Status = $piece(Name, ",", 1) if menu '= "%SourceMenu", menu'="%SourceContext" { quit $$$OK } @@ -86,37 +87,41 @@ Method LocalizeName(name As %String) As %String "Push":$$$Text("@Push@Push to remote branch"), "Fetch":$$$Text("@Fetch@Fetch from remote"), "Pull":$$$Text("@Pull@Pull changes from remote branch"), + "Status": $$$Text("@Status@Status"), :name) } Method OnSourceMenuItem(name As %String, ByRef Enabled As %String, ByRef DisplayName As %String, InternalName As %String) As %Status { if name = "Settings" { + // what is `Enabled` set to here? 0? quit $$$OK } if ##class(Utils).NeedSettings() { set Enabled = -1 quit $$$OK } - set Enabled = 1 if ##class(Utils).IsNamespaceInGit() { - if name = "GitWebUI" { - } elseif name = "Export" { - } elseif name = "ExportForce" { - } elseif name = "Import" { - } elseif name = "ImportForce" { - } elseif $listfind($listbuild("AddToSC","RemoveFromSC","Revert","Commit"),name) { - quit ..OnSourceMenuContextItem(InternalName,name,.Enabled,.DisplayName) - } elseif name = "NewBranch" { - } elseif name = "SwitchBranch" { - } elseif name = "Push" { - } elseif name = "Fetch" { - } elseif name = "Pull" { - } elseif name = "" { - // enable separators if namespace is in git - } else { - set Enabled = -1 - } + if $listfind($listbuild("AddToSC", "RemoveFromSC", "Revert", "Commit"), name) { + quit ..OnSourceMenuContextItem(InternalName,name,.Enabled,.DisplayName) + } + set Enabled = $CASE(name, + // cases + "Status": 1, + "GitWebUI" : 1, + "Export": 1, + "ExportForce": 1, + "Import": 1, + "ImportForce": 1, + "NewBranch": 1, + "SwitchBranch": 1, + "Push": 1, + "Fetch": 1, + "Pull": 1, + "": 1, + :-1 // default + ) + } elseif ##class(Utils).GitBinExists() { if name = "Init" { } else { @@ -335,4 +340,3 @@ Method AddToSourceControl(InternalName As %String, Description As %String = "") } } - diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index 885091b9..70d2e0f8 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -151,7 +151,7 @@ $Find(..#ImportAfterGitMenuItems, ","_menuItemName_",") > 0 ClassMethod UserAction(InternalName As %String, MenuName As %String, ByRef Target As %String, ByRef Action As %String, ByRef Reload As %Boolean) As %Status { #define Force 1 - #dim menuName as %String = $piece(MenuName,",") + // MenuName = "," #dim menuItemName as %String = $piece(MenuName,",",2) #dim ec as %Status = $$$OK @@ -233,6 +233,11 @@ ClassMethod UserAction(InternalName As %String, MenuName As %String, ByRef Targe set ec = ..AddToSourceControl(InternalName) } elseif (menuItemName = "RemoveFromSC") { set ec = ..RemoveFromSourceControl(InternalName) + } elseif (menuItemName = "Status") { + do ..RunGitCommand("status", .errStream, .outStream) + write !, !, "Git Status: " + do outStream.OutputToDevice() + do errStream.OutputToDevice() } quit ec } @@ -1991,4 +1996,3 @@ ClassMethod SetDefaultMappings(mappingsNode As %String) } } - From e8dbf1a7df437cac390c752bfd18b0789b3eb12d Mon Sep 17 00:00:00 2001 From: Rutvik Saptarshi Date: Mon, 18 Sep 2023 14:59:52 -0400 Subject: [PATCH 2/2] updated changelog, added namespace change event reroute, explicit default for Enabled --- CHANGELOG.md | 1 + cls/SourceControl/Git/Extension.cls | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e0327c4..77a50416 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Web UI includes a "Push Branch" button for local branches that are ahead of upstream +- Added "Status" menu item to editor menu (#285) ### Fixed - Fixed empty mappings when SourceControl.Git.Settings is instantiated (#250) diff --git a/cls/SourceControl/Git/Extension.cls b/cls/SourceControl/Git/Extension.cls index f1395363..7b6515e0 100644 --- a/cls/SourceControl/Git/Extension.cls +++ b/cls/SourceControl/Git/Extension.cls @@ -43,8 +43,14 @@ XData Menu Method UserAction(Type As %Integer, Name As %String, InternalName As %String, SelectedText As %String, ByRef Action As %String, ByRef Target As %String, ByRef Msg As %String, ByRef Reload As %Boolean) As %Status { + // If namespace change event + if Type = 1, Name = 5 { + // reroute to Status menu option + set Name = "%SourceMenu,Status" + } + #dim ec as %Status = $$$OK - #dim menu as %Status = $piece(Name, ",", 1) + #dim menu as %Status = $piece(Name, ",", 1) if menu '= "%SourceMenu", menu'="%SourceContext" { quit $$$OK } @@ -94,7 +100,7 @@ Method LocalizeName(name As %String) As %String Method OnSourceMenuItem(name As %String, ByRef Enabled As %String, ByRef DisplayName As %String, InternalName As %String) As %Status { if name = "Settings" { - // what is `Enabled` set to here? 0? + set Enabled = 1 quit $$$OK } if ##class(Utils).NeedSettings() {