Skip to content

Commit cf44cef

Browse files
committed
status menu item is now available
1 parent 84ea497 commit cf44cef

File tree

2 files changed

+30
-22
lines changed

2 files changed

+30
-22
lines changed

cls/SourceControl/Git/Extension.cls

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ XData Menu
1010
{
1111
<MenuBase>
1212
<Menu Name="%SourceMenu" Type="0">
13+
<MenuItem Name="Status" />
1314
<MenuItem Name="Settings" />
1415
<MenuItem Name="Init" />
1516
<MenuItem Name="GitWebUI" />
@@ -43,7 +44,7 @@ XData Menu
4344
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
4445
{
4546
#dim ec as %Status = $$$OK
46-
#dim menu as %Status = $piece(Name, ",", 1)
47+
#dim menu as %Status = $piece(Name, ",", 1)
4748
if menu '= "%SourceMenu", menu'="%SourceContext" {
4849
quit $$$OK
4950
}
@@ -86,37 +87,41 @@ Method LocalizeName(name As %String) As %String
8687
"Push":$$$Text("@Push@Push to remote branch"),
8788
"Fetch":$$$Text("@Fetch@Fetch from remote"),
8889
"Pull":$$$Text("@Pull@Pull changes from remote branch"),
90+
"Status": $$$Text("@Status@Status"),
8991
:name)
9092
}
9193

9294
Method OnSourceMenuItem(name As %String, ByRef Enabled As %String, ByRef DisplayName As %String, InternalName As %String) As %Status
9395
{
9496
if name = "Settings" {
97+
// what is `Enabled` set to here? 0?
9598
quit $$$OK
9699
}
97100
if ##class(Utils).NeedSettings() {
98101
set Enabled = -1
99102
quit $$$OK
100103
}
101-
set Enabled = 1
102104
if ##class(Utils).IsNamespaceInGit() {
103-
if name = "GitWebUI" {
104-
} elseif name = "Export" {
105-
} elseif name = "ExportForce" {
106-
} elseif name = "Import" {
107-
} elseif name = "ImportForce" {
108-
} elseif $listfind($listbuild("AddToSC","RemoveFromSC","Revert","Commit"),name) {
109-
quit ..OnSourceMenuContextItem(InternalName,name,.Enabled,.DisplayName)
110-
} elseif name = "NewBranch" {
111-
} elseif name = "SwitchBranch" {
112-
} elseif name = "Push" {
113-
} elseif name = "Fetch" {
114-
} elseif name = "Pull" {
115-
} elseif name = "" {
116-
// enable separators if namespace is in git
117-
} else {
118-
set Enabled = -1
119-
}
105+
if $listfind($listbuild("AddToSC", "RemoveFromSC", "Revert", "Commit"), name) {
106+
quit ..OnSourceMenuContextItem(InternalName,name,.Enabled,.DisplayName)
107+
}
108+
set Enabled = $CASE(name,
109+
// cases
110+
"Status": 1,
111+
"GitWebUI" : 1,
112+
"Export": 1,
113+
"ExportForce": 1,
114+
"Import": 1,
115+
"ImportForce": 1,
116+
"NewBranch": 1,
117+
"SwitchBranch": 1,
118+
"Push": 1,
119+
"Fetch": 1,
120+
"Pull": 1,
121+
"": 1,
122+
:-1 // default
123+
)
124+
120125
} elseif ##class(Utils).GitBinExists() {
121126
if name = "Init" {
122127
} else {
@@ -335,4 +340,3 @@ Method AddToSourceControl(InternalName As %String, Description As %String = "")
335340
}
336341

337342
}
338-

cls/SourceControl/Git/Utils.cls

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ $Find(..#ImportAfterGitMenuItems, ","_menuItemName_",") > 0
151151
ClassMethod UserAction(InternalName As %String, MenuName As %String, ByRef Target As %String, ByRef Action As %String, ByRef Reload As %Boolean) As %Status
152152
{
153153
#define Force 1
154-
#dim menuName as %String = $piece(MenuName,",")
154+
// MenuName = "<Name of menu>,<Name of menu item>"
155155
#dim menuItemName as %String = $piece(MenuName,",",2)
156156
#dim ec as %Status = $$$OK
157157

@@ -233,6 +233,11 @@ ClassMethod UserAction(InternalName As %String, MenuName As %String, ByRef Targe
233233
set ec = ..AddToSourceControl(InternalName)
234234
} elseif (menuItemName = "RemoveFromSC") {
235235
set ec = ..RemoveFromSourceControl(InternalName)
236+
} elseif (menuItemName = "Status") {
237+
do ..RunGitCommand("status", .errStream, .outStream)
238+
write !, !, "Git Status: "
239+
do outStream.OutputToDevice()
240+
do errStream.OutputToDevice()
236241
}
237242
quit ec
238243
}
@@ -1991,4 +1996,3 @@ ClassMethod SetDefaultMappings(mappingsNode As %String)
19911996
}
19921997

19931998
}
1994-

0 commit comments

Comments
 (0)