Skip to content

Commit

Permalink
Reorganize context menus and button row
Browse files Browse the repository at this point in the history
Closes #37.
  • Loading branch information
MariusDoe committed Nov 16, 2024
1 parent 2aa64db commit 9e3cfe5
Show file tree
Hide file tree
Showing 14 changed files with 174 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ menu
projectListMenu: aMenu for: aWorkingCopy
aWorkingCopy ifNil: [^ self].
aMenu
add: 'Manage assets'
add: 'Manage its assets'
target: GSAssetBrowser
selector: #openOnWorkingCopy:
argument: aWorkingCopy.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"encodingName:" : "mad 9/20/2023 19:01",
"isAbstract" : "mad 10/13/2024 20:52",
"kind" : "mad 9/29/2024 19:29",
"projectListMenu:for:" : "mad 10/9/2024 16:01",
"projectListMenu:for:" : "mad 11/16/2024 16:21",
"requestMapperClass" : "mad 9/29/2024 19:28",
"validEncodings" : "mad 9/20/2023 18:41" },
"instance" : {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
actions
actionManageRemotes
GSRemotesBrowser openOnWorkingCopy: self activeWorkingCopy.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ buildButtons: builder
self buildCommitButton: builder.
self buildPullButton: builder.
self buildPushButton: builder.
self buildFetchAllButton: builder.
self buildBranchButton: builder.
self buildOtherButton: builder.
} with: builder

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
menu
commitListMenu: aMenu
self activeCommit ifNotNil: [:commit |
aMenu addTitle: ('Commit {1}' format: {commit showOneLine printString})].
^ self menu: aMenu forCommit: self activeCommit
190 changes: 132 additions & 58 deletions src/GitS-Core.package/GSBrowser.class/instance/menu.forCommit.ref..st
Original file line number Diff line number Diff line change
@@ -1,68 +1,142 @@
menu
menu: aMenu forCommit: aCommit ref: aStringOrNil
| branch isRef refOrCommit |
aCommit ifNil: [^ aMenu].
isRef := aStringOrNil notNil.
refOrCommit := isRef ifTrue: [aStringOrNil] ifFalse: [aCommit].
aMenu
target: self;

add: 'Create a branch at it'
selector: (isRef ifTrue: [#actionCreateBranchAtRef:] ifFalse: [#actionCreateBranchAtCommit:])
argument: refOrCommit;

add: 'Create a branch at it and switch to it'
selector: (isRef
ifTrue: [#actionCreateBranchAtRefAndSwitchToIt:]
ifFalse: [#actionCreateBranchAtCommitAndSwitchToIt:])
argument: refOrCommit;

add: 'Create an external branch at it'
selector: (isRef ifTrue: [#actionCreateGitBranchAtRef:] ifFalse: [#actionCreateGitBranchAtCommit:])
argument: refOrCommit;
balloonTextForLastItem: 'The created branch will be visible from external git tools, like the git command line';

addLine;

add: 'Switch to it (detach HEAD)'
selector: #actionSwitchToCommit:
argument: aCommit;
menu: aMenu forCommit: aCommit ref: refString
| isRef isRefMenu isBranch refOrCommit refTypeName refShortName currentBranch currentBranchShortName |
isRef := refString notNil.
isRefMenu := isRef or: [aCommit isNil].
isBranch := isRef and: [self activeWorkingCopy isSqueakBranchRef: refString].
refOrCommit := isRef ifTrue: [refString] ifFalse: [aCommit].
refTypeName := self refTypeName: refString.
refShortName := isRef ifTrue: [(GitReference shortName: refString) printString] ifFalse: [nil].
currentBranch := self activeWorkingCopy currentSymbolicHeadTarget.
currentBranchShortName := currentBranch ifNotNil: [(GitReference shortName: currentBranch) printString].

aMenu target: self.

refOrCommit ifNotNil: [
aMenu addTitle: ('{1} {2}' format: {
refTypeName capitalized.
isRef
ifTrue: [refShortName]
ifFalse: [aCommit showOneLine printStringLimitedTo: 30]})].

isRef ifTrue: [
aMenu
add: ('Switch to {1}' format: {isBranch ifTrue: ['it'] ifFalse: ['a new branch at it']})
selector: (isBranch ifTrue: [#actionSwitchToBranch:] ifFalse: [#actionCreateBranchAtRefAndSwitchToIt:])
argument: refString;

add: 'Delete it'
selector: #actionDeleteRef:
argument: refString].

aCommit ifNotNil: [
aMenu
add: 'Create a branch at it'
selector: (isRef ifTrue: [#actionCreateBranchAtRef:] ifFalse: [#actionCreateBranchAtCommit:])
argument: refOrCommit.

add: 'Restore it'
selector: #actionMaterializeCommit:
argument: aCommit;
isRef ifFalse: [
aMenu
add: 'Create a branch at it and switch'
selector: #actionCreateBranchAtCommitAndSwitchToIt:
argument: aCommit].

add: 'Merge it'
selector: (isRef ifTrue: [#actionMergeRef:] ifFalse: [#actionMergeCommit:])
argument: refOrCommit.

branch := self activeWorkingCopy currentSymbolicHeadTarget.
branch ifNotNil: [
| branchShortName resetLabel |
branchShortName := (GitReference shortName: branch) printString.
resetLabel := 'Reset branch {1} to it' format: {branchShortName}.
aMenu
add: resetLabel
selector: #actionResetToCommit:
argument: aCommit;
addLine;

add: resetLabel, ' and restore it'
selector: #actionResetToCommitAndRestoreIt:
add: 'Load it'
selector: #actionMaterializeCommit:
argument: aCommit;

add: ('Rebase branch {1} onto it' format: {branchShortName})
selector: #actionRebaseOntoCommit:
argument: aCommit].
add: ('Merge it into {1}' format: {currentBranch ifNotNil: ['branch {1}' format: {currentBranchShortName}] ifNil: ['HEAD']})
selector: (isRef ifTrue: [#actionMergeRef:] ifFalse: [#actionMergeCommit:])
argument: refOrCommit;

add: 'Compare it to'
subMenu: (MenuMorph new in: [:subMenu |
subMenu
target: self;

add: 'its parent commit'
selector: #actionCompareCommitToParent:
argument: aCommit;

add: 'the image'
selector: #actionCompareCommitToImage:
argument: aCommit;

yourself])].

isRefMenu ifTrue: [
aMenu
add: 'Remotes'
subMenu: (MenuMorph new in: [:subMenu |
subMenu
target: self;

add: 'Manage'
action: #actionManageRemotes;

add: 'Fetch all'
action: #actionFetchAll;

yourself])].

aMenu
addLine;

add: 'Compare it to its parent commit'
selector: #actionCompareCommitToParent:
argument: aCommit;

add: 'Compare it to the image'
selector: #actionCompareCommitToImage:
argument: aCommit.

add: 'Advanced'
subMenu: (MenuMorph new in: [:subMenu |
subMenu target: self.
aCommit ifNotNil: [
subMenu
add: 'Create an external branch at it'
selector: (isRef ifTrue: [#actionCreateGitBranchAtRef:] ifFalse: [#actionCreateGitBranchAtCommit:])
argument: refOrCommit;
balloonTextForLastItem: 'The created branch will be visible from external git tools, like the git command line';

add: ('Switch to {1} (detach HEAD)' format: {isRef ifTrue: ['its latest commit'] ifFalse: ['it']})
selector: #actionSwitchToCommit:
argument: aCommit.

currentBranch ifNotNil: [
| resetLabel |
resetLabel := 'Reset branch {1} to it' format: {currentBranchShortName}.
subMenu
addLine;

add: resetLabel
selector: #actionResetToCommit:
argument: aCommit;

add: resetLabel, ' and load'
selector: #actionResetToCommitAndRestoreIt:
argument: aCommit;

add: ('Rebase branch {1} onto it' format: {currentBranchShortName})
selector: #actionRebaseOntoCommit:
argument: aCommit]].

isBranch ifTrue: [
subMenu
addLine;

add: 'Set its remote branch'
selector: #actionSetUpstreamOfBranch:
argument: refString;

add: 'Unset its remote branch'
selector: #actionUnsetUpstreamOfBranch:
argument: refString].

isRefMenu ifTrue: [
subMenu
addLine;

add: 'Refresh refs'
action: #actionRefreshRefList;

add: (self showGitRefs ifTrue: ['<yes>'] ifFalse: ['<no>']), 'Show git refs'
action: #toggleShowGitRefs].

subMenu]).

^ aMenu
32 changes: 3 additions & 29 deletions src/GitS-Core.package/GSBrowser.class/instance/menu.forRef..st
Original file line number Diff line number Diff line change
@@ -1,32 +1,6 @@
menu
menu: aMenu forRef: aString
| isBranch refTypeName |
aMenu target: self.
isBranch := self activeWorkingCopy isSqueakBranchRef: aString.
refTypeName := self refTypeName: aString.
aMenu addTitle: ('{1} {2}' format: {refTypeName capitalized. (GitReference shortName: self activeRef) printString}).
isBranch ifTrue: [
aMenu
add: 'Switch to it'
selector: #actionSwitchToBranch:
argument: aString].
aMenu
add: 'Delete it'
selector: #actionDeleteRef:
argument: aString;
addLine.
self
^ self
menu: aMenu
forCommit: (self unitOfWork objectReferenced: aString)
ref: aString.
isBranch ifTrue: [
aMenu
addLine;

add: 'Set its remote branch'
selector: #actionSetUpstreamOfBranch:
argument: aString;

add: 'Unset its remote branch'
selector: #actionUnsetUpstreamOfBranch:
argument: aString]
forCommit: (aString ifNotNil: [self unitOfWork objectReferenced: aString])
ref: aString
2 changes: 2 additions & 0 deletions src/GitS-Core.package/GSBrowser.class/instance/otherMenu..st
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ otherMenu: aMenuSpec
selector: #actionSetSelfUpdateBranch
argumentList: {};

addLine;

add: 'Force push'
target: self
selector: #actionForcePush
Expand Down
36 changes: 21 additions & 15 deletions src/GitS-Core.package/GSBrowser.class/instance/projectListMenu..st
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
menu
projectListMenu: aMenu
self activeWorkingCopy ifNotNil: [
aMenu target: self.
self activeWorkingCopy ifNotNil: [:workingCopy |
aMenu
target: self;
add: 'Rename this project' action: #actionRenameActiveProject;
add: 'Choose new repository location' action: #actionChooseNewRepositoryLocationForActiveProject;
add: 'Remove this project' action: #actionRemoveActiveProject;
add: 'Manage remotes'
target: GSRemotesBrowser
selector: #openOnWorkingCopy:
argument: self activeWorkingCopy;
add: 'Export this project to a .sar' action: #actionExportActiveProjectToSar].
self addMappersProjectListMenu: aMenu.
aMenu items ifNotEmpty: [aMenu addLine].
title: ('Project {1}' format: {workingCopy name printString});
add: 'Organize it'
subMenu: (MenuMorph new in: [:subMenu |
subMenu
target: self;
add: 'Rename it' action: #actionRenameActiveProject;
add: 'Remove it' action: #actionRemoveActiveProject;
add: 'Choose new repository location' action: #actionChooseNewRepositoryLocationForActiveProject;
yourself]).
self addMappersProjectListMenu: aMenu.
aMenu add: 'Export it to a .sar' action: #actionExportActiveProjectToSar].
aMenu
target: self;
add: 'New project' action: #actionNewProject;
add: 'Clone project' action: #actionCloneProject.
addLine;
add: 'New project'
subMenu: (MenuMorph new in: [:subMenu |
subMenu
target: self;
add: 'Clone' action: #actionCloneProject;
add: 'From disk' action: #actionNewProject;
yourself]).
^ aMenu
13 changes: 1 addition & 12 deletions src/GitS-Core.package/GSBrowser.class/instance/refListMenu..st
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
menu
refListMenu: aMenu
self activeRef ifNotNil: [self menu: aMenu forRef: self activeRef].
aMenu
target: self;
addLine;

add: 'Refresh refs'
action: #actionRefreshRefList;

add: (self showGitRefs ifTrue: ['<yes>'] ifFalse: ['<no>']), 'Show git refs'
action: #toggleShowGitRefs.

^ aMenu
^ self menu: aMenu forRef: self activeRef
Loading

0 comments on commit 9e3cfe5

Please sign in to comment.