From 9e3cfe5b42dee8dc1e8bf2eb737d8330d4b0a4f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20D=C3=B6rbandt?= Date: Sat, 16 Nov 2024 17:44:24 +0100 Subject: [PATCH] Reorganize context menus and button row Closes #37. --- .../class/projectListMenu.for..st | 2 +- .../GSAssetMapper.class/methodProperties.json | 2 +- .../instance/actionManageRemotes.st | 3 + .../GSBrowser.class/instance/buildButtons..st | 1 - .../instance/buildFetchAllButton..st | 8 - .../instance/commitListMenu..st | 2 - .../instance/menu.forCommit.ref..st | 190 ++++++++++++------ .../GSBrowser.class/instance/menu.forRef..st | 32 +-- .../GSBrowser.class/instance/otherMenu..st | 2 + .../instance/projectListMenu..st | 36 ++-- .../GSBrowser.class/instance/refListMenu..st | 13 +- .../GSBrowser.class/methodProperties.json | 16 +- .../class/projectListMenu.for..st | 2 +- .../GSCodeMapper.class/methodProperties.json | 2 +- 14 files changed, 174 insertions(+), 137 deletions(-) create mode 100644 src/GitS-Core.package/GSBrowser.class/instance/actionManageRemotes.st delete mode 100644 src/GitS-Core.package/GSBrowser.class/instance/buildFetchAllButton..st diff --git a/src/GitS-Core.package/GSAssetMapper.class/class/projectListMenu.for..st b/src/GitS-Core.package/GSAssetMapper.class/class/projectListMenu.for..st index 66f97d059..0191017ab 100644 --- a/src/GitS-Core.package/GSAssetMapper.class/class/projectListMenu.for..st +++ b/src/GitS-Core.package/GSAssetMapper.class/class/projectListMenu.for..st @@ -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. \ No newline at end of file diff --git a/src/GitS-Core.package/GSAssetMapper.class/methodProperties.json b/src/GitS-Core.package/GSAssetMapper.class/methodProperties.json index fccc7b061..aa3ede49d 100644 --- a/src/GitS-Core.package/GSAssetMapper.class/methodProperties.json +++ b/src/GitS-Core.package/GSAssetMapper.class/methodProperties.json @@ -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" : { diff --git a/src/GitS-Core.package/GSBrowser.class/instance/actionManageRemotes.st b/src/GitS-Core.package/GSBrowser.class/instance/actionManageRemotes.st new file mode 100644 index 000000000..b3a475339 --- /dev/null +++ b/src/GitS-Core.package/GSBrowser.class/instance/actionManageRemotes.st @@ -0,0 +1,3 @@ +actions +actionManageRemotes + GSRemotesBrowser openOnWorkingCopy: self activeWorkingCopy. \ No newline at end of file diff --git a/src/GitS-Core.package/GSBrowser.class/instance/buildButtons..st b/src/GitS-Core.package/GSBrowser.class/instance/buildButtons..st index 4d71598b2..e5e843c0d 100644 --- a/src/GitS-Core.package/GSBrowser.class/instance/buildButtons..st +++ b/src/GitS-Core.package/GSBrowser.class/instance/buildButtons..st @@ -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 \ No newline at end of file diff --git a/src/GitS-Core.package/GSBrowser.class/instance/buildFetchAllButton..st b/src/GitS-Core.package/GSBrowser.class/instance/buildFetchAllButton..st deleted file mode 100644 index 32603486e..000000000 --- a/src/GitS-Core.package/GSBrowser.class/instance/buildFetchAllButton..st +++ /dev/null @@ -1,8 +0,0 @@ -toolbuilder -buildFetchAllButton: builder - ^ builder pluggableActionButtonSpec new - model: self; - action: #actionFetchAll; - label: 'Fetch all'; - help: 'Fetch from all remotes.'; - yourself \ No newline at end of file diff --git a/src/GitS-Core.package/GSBrowser.class/instance/commitListMenu..st b/src/GitS-Core.package/GSBrowser.class/instance/commitListMenu..st index 494828dd9..b0695949d 100644 --- a/src/GitS-Core.package/GSBrowser.class/instance/commitListMenu..st +++ b/src/GitS-Core.package/GSBrowser.class/instance/commitListMenu..st @@ -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 \ No newline at end of file diff --git a/src/GitS-Core.package/GSBrowser.class/instance/menu.forCommit.ref..st b/src/GitS-Core.package/GSBrowser.class/instance/menu.forCommit.ref..st index 9a122ecac..58338bed0 100644 --- a/src/GitS-Core.package/GSBrowser.class/instance/menu.forCommit.ref..st +++ b/src/GitS-Core.package/GSBrowser.class/instance/menu.forCommit.ref..st @@ -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: [''] ifFalse: ['']), 'Show git refs' + action: #toggleShowGitRefs]. + + subMenu]). + ^ aMenu \ No newline at end of file diff --git a/src/GitS-Core.package/GSBrowser.class/instance/menu.forRef..st b/src/GitS-Core.package/GSBrowser.class/instance/menu.forRef..st index 4e57186de..c47d63743 100644 --- a/src/GitS-Core.package/GSBrowser.class/instance/menu.forRef..st +++ b/src/GitS-Core.package/GSBrowser.class/instance/menu.forRef..st @@ -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] \ No newline at end of file + forCommit: (aString ifNotNil: [self unitOfWork objectReferenced: aString]) + ref: aString \ No newline at end of file diff --git a/src/GitS-Core.package/GSBrowser.class/instance/otherMenu..st b/src/GitS-Core.package/GSBrowser.class/instance/otherMenu..st index 20b891f17..d712d9f4b 100644 --- a/src/GitS-Core.package/GSBrowser.class/instance/otherMenu..st +++ b/src/GitS-Core.package/GSBrowser.class/instance/otherMenu..st @@ -11,6 +11,8 @@ otherMenu: aMenuSpec selector: #actionSetSelfUpdateBranch argumentList: {}; + addLine; + add: 'Force push' target: self selector: #actionForcePush diff --git a/src/GitS-Core.package/GSBrowser.class/instance/projectListMenu..st b/src/GitS-Core.package/GSBrowser.class/instance/projectListMenu..st index 051b1120e..a34e77990 100644 --- a/src/GitS-Core.package/GSBrowser.class/instance/projectListMenu..st +++ b/src/GitS-Core.package/GSBrowser.class/instance/projectListMenu..st @@ -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 \ No newline at end of file diff --git a/src/GitS-Core.package/GSBrowser.class/instance/refListMenu..st b/src/GitS-Core.package/GSBrowser.class/instance/refListMenu..st index 4a303be3c..1182cabcf 100644 --- a/src/GitS-Core.package/GSBrowser.class/instance/refListMenu..st +++ b/src/GitS-Core.package/GSBrowser.class/instance/refListMenu..st @@ -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: [''] ifFalse: ['']), 'Show git refs' - action: #toggleShowGitRefs. - - ^ aMenu \ No newline at end of file + ^ self menu: aMenu forRef: self activeRef \ No newline at end of file diff --git a/src/GitS-Core.package/GSBrowser.class/methodProperties.json b/src/GitS-Core.package/GSBrowser.class/methodProperties.json index 9b2db9633..e3d500264 100644 --- a/src/GitS-Core.package/GSBrowser.class/methodProperties.json +++ b/src/GitS-Core.package/GSBrowser.class/methodProperties.json @@ -29,6 +29,7 @@ "actionFixup:keepCurrentMessage:editMessage:" : "mad 4/5/2024 15:12", "actionForcePush" : "mad 5/18/2024 11:33", "actionForcePush:" : "mad 5/18/2024 11:32", + "actionManageRemotes" : "mad 11/16/2024 17:33", "actionMaterializeCherryPick:" : "mad 10/7/2024 17:35", "actionMaterializeCommit:" : "mad 4/5/2024 19:30", "actionMergeCommit:" : "mad 4/5/2024 19:31", @@ -71,11 +72,10 @@ "basicActiveRef:" : "mad 5/15/2024 21:40", "basicOpen" : "mad 10/25/2024 11:36", "buildBranchButton:" : "mad 9/14/2023 19:42", - "buildButtons:" : "mad 10/9/2024 16:01", + "buildButtons:" : "mad 11/16/2024 16:23", "buildCommitButton:" : "mad 9/1/2023 14:07", "buildCommitInfo:" : "mad 8/13/2024 17:55", "buildCommitList:" : "mad 10/9/2024 16:01", - "buildFetchAllButton:" : "mad 10/24/2023 17:16", "buildLayout:" : "mad 10/9/2024 16:01", "buildLowerLayout:" : "mad 9/14/2023 15:21", "buildMainLayout:" : "mad 10/9/2024 16:01", @@ -90,7 +90,7 @@ "buildWith:" : "mad 9/1/2023 14:44", "checkSetUpstreamForCreatedBranch:to:" : "mad 12/8/2023 19:33", "commitList" : "mad 5/15/2024 21:43", - "commitListMenu:" : "mad 4/10/2024 19:17", + "commitListMenu:" : "mad 11/16/2024 16:09", "commitListStartingCommits" : "mad 9/19/2023 12:32", "commitReferencedBy:to:" : "mad 4/5/2024 19:45", "currentBranchIfNilInformAnd:" : "mad 9/26/2023 16:56", @@ -102,8 +102,8 @@ "everythingChanged" : "mad 12/22/2023 17:59", "ifRepositoryDoesNotExist:" : "mad 11/30/2023 17:08", "menu:forCommit:" : "mad 4/5/2024 20:19", - "menu:forCommit:ref:" : "mad 8/13/2024 18:05", - "menu:forRef:" : "mad 4/10/2024 19:17", + "menu:forCommit:ref:" : "mad 11/16/2024 17:35", + "menu:forRef:" : "mad 11/16/2024 16:14", "mergeCommitIntoHead:" : "mad 9/21/2023 13:47", "mergeCommitIntoHead:displayName:" : "mad 10/9/2024 16:01", "mergeCommitIntoHead:mergeBase:message:windowTitle:alwaysOpenDialog:commitType:" : "mad 10/9/2024 16:01", @@ -124,12 +124,12 @@ "openDialogToShowChangeSets:windowTitle:" : "mad 10/9/2024 16:01", "openDialogToShowChangeSetsFromCommit:to:" : "mad 10/22/2023 00:56", "openDialogToShowChangeSetsFromImageTo:" : "mad 11/29/2023 16:48", - "otherMenu:" : "mad 11/4/2024 13:07", + "otherMenu:" : "mad 11/16/2024 16:24", "parentForPick:" : "mad 4/5/2024 14:44", - "projectListMenu:" : "mad 10/9/2024 16:01", + "projectListMenu:" : "mad 11/16/2024 17:36", "refChanged:" : "mad 5/15/2024 20:47", "refList" : "mad 5/15/2024 21:43", - "refListMenu:" : "mad 4/5/2024 18:55", + "refListMenu:" : "mad 11/16/2024 16:09", "refTypeName:" : "mad 11/29/2023 15:59", "refsChanged" : "mad 5/15/2024 20:47", "requestBranchNameFor:at:fromRef:" : "mad 4/5/2024 19:29", diff --git a/src/GitS-Core.package/GSCodeMapper.class/class/projectListMenu.for..st b/src/GitS-Core.package/GSCodeMapper.class/class/projectListMenu.for..st index 7ad57679a..40ee43f6d 100644 --- a/src/GitS-Core.package/GSCodeMapper.class/class/projectListMenu.for..st +++ b/src/GitS-Core.package/GSCodeMapper.class/class/projectListMenu.for..st @@ -2,7 +2,7 @@ menu projectListMenu: aMenu for: aWorkingCopy aWorkingCopy ifNil: [^ self]. aMenu - add: 'Manage packages' + add: 'Manage its packages' target: GSCodePackageBrowser selector: #openOnWorkingCopy: argument: aWorkingCopy. \ No newline at end of file diff --git a/src/GitS-Core.package/GSCodeMapper.class/methodProperties.json b/src/GitS-Core.package/GSCodeMapper.class/methodProperties.json index b9db03081..b6eadc0fe 100644 --- a/src/GitS-Core.package/GSCodeMapper.class/methodProperties.json +++ b/src/GitS-Core.package/GSCodeMapper.class/methodProperties.json @@ -9,7 +9,7 @@ "package:" : "mad 4/21/2023 23:40", "package:path:" : "mad 4/21/2023 23:41", "packageNameFromPackagePath:" : "mad 10/4/2024 16:28", - "projectListMenu:for:" : "mad 10/9/2024 16:01" }, + "projectListMenu:for:" : "mad 11/16/2024 16:21" }, "instance" : { "=" : "mad 9/26/2023 15:20", "addToSar:" : "mad 10/9/2024 16:01",