Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

status menu item is now available #285

Merged
merged 2 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
48 changes: 29 additions & 19 deletions cls/SourceControl/Git/Extension.cls
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ XData Menu
{
<MenuBase>
<Menu Name="%SourceMenu" Type="0">
<MenuItem Name="Status" />
<MenuItem Name="Settings" />
<MenuItem Name="Init" />
<MenuItem Name="GitWebUI" />
Expand Down Expand Up @@ -42,6 +43,12 @@ 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)
if menu '= "%SourceMenu", menu'="%SourceContext" {
isc-rsaptars marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -86,37 +93,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" {
set Enabled = 1
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 {
Expand Down Expand Up @@ -335,4 +346,3 @@ Method AddToSourceControl(InternalName As %String, Description As %String = "")
}

}

8 changes: 6 additions & 2 deletions cls/SourceControl/Git/Utils.cls
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<Name of menu>,<Name of menu item>"
#dim menuItemName as %String = $piece(MenuName,",",2)
#dim ec as %Status = $$$OK

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -1991,4 +1996,3 @@ ClassMethod SetDefaultMappings(mappingsNode As %String)
}

}

Loading