Skip to content

Commit c7da0f1

Browse files
authored
Merge pull request #285 from intersystems/add-status-menu
status menu item is now available
2 parents 3f092a7 + e8dbf1a commit c7da0f1

File tree

3 files changed

+36
-21
lines changed

3 files changed

+36
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111
- Web UI includes a "Push Branch" button for local branches that are ahead of upstream
12+
- Added "Status" menu item to editor menu (#285)
1213

1314
### Fixed
1415
- Fixed empty mappings when SourceControl.Git.Settings is instantiated (#250)

cls/SourceControl/Git/Extension.cls

Lines changed: 29 additions & 19 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" />
@@ -42,6 +43,12 @@ XData Menu
4243

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
{
46+
// If namespace change event
47+
if Type = 1, Name = 5 {
48+
// reroute to Status menu option
49+
set Name = "%SourceMenu,Status"
50+
}
51+
4552
#dim ec as %Status = $$$OK
4653
#dim menu as %Status = $piece(Name, ",", 1)
4754
if menu '= "%SourceMenu", menu'="%SourceContext" {
@@ -86,37 +93,41 @@ Method LocalizeName(name As %String) As %String
8693
"Push":$$$Text("@Push@Push to remote branch"),
8794
"Fetch":$$$Text("@Fetch@Fetch from remote"),
8895
"Pull":$$$Text("@Pull@Pull changes from remote branch"),
96+
"Status": $$$Text("@Status@Status"),
8997
:name)
9098
}
9199

92100
Method OnSourceMenuItem(name As %String, ByRef Enabled As %String, ByRef DisplayName As %String, InternalName As %String) As %Status
93101
{
94102
if name = "Settings" {
103+
set Enabled = 1
95104
quit $$$OK
96105
}
97106
if ##class(Utils).NeedSettings() {
98107
set Enabled = -1
99108
quit $$$OK
100109
}
101-
set Enabled = 1
102110
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-
}
111+
if $listfind($listbuild("AddToSC", "RemoveFromSC", "Revert", "Commit"), name) {
112+
quit ..OnSourceMenuContextItem(InternalName,name,.Enabled,.DisplayName)
113+
}
114+
set Enabled = $CASE(name,
115+
// cases
116+
"Status": 1,
117+
"GitWebUI" : 1,
118+
"Export": 1,
119+
"ExportForce": 1,
120+
"Import": 1,
121+
"ImportForce": 1,
122+
"NewBranch": 1,
123+
"SwitchBranch": 1,
124+
"Push": 1,
125+
"Fetch": 1,
126+
"Pull": 1,
127+
"": 1,
128+
:-1 // default
129+
)
130+
120131
} elseif ##class(Utils).GitBinExists() {
121132
if name = "Init" {
122133
} else {
@@ -335,4 +346,3 @@ Method AddToSourceControl(InternalName As %String, Description As %String = "")
335346
}
336347

337348
}
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)