From 21d5e5b2b18e0f24b1bf1d628b795b8c35cef7cd Mon Sep 17 00:00:00 2001 From: CyrilFerlicot Date: Tue, 30 Oct 2018 10:30:55 +0100 Subject: [PATCH 1/2] When creating a PR we now have the possibility to open the PR on GitHub. Fixes #1044 --- .../instance/basicExecute.st | 23 +++++++++++-------- .../instance/send.st | 2 +- .../instance/inform.actionOnClick..st | 8 +++++++ .../properties.json | 3 +++ .../instance/inform.actionOnClick..st | 5 ++++ .../UIManager.extension/properties.json | 3 +++ 6 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 Iceberg-Plugin-GitHub.package/MorphicUIManager.extension/instance/inform.actionOnClick..st create mode 100644 Iceberg-Plugin-GitHub.package/MorphicUIManager.extension/properties.json create mode 100644 Iceberg-Plugin-GitHub.package/UIManager.extension/instance/inform.actionOnClick..st create mode 100644 Iceberg-Plugin-GitHub.package/UIManager.extension/properties.json diff --git a/Iceberg-Plugin-GitHub.package/IceGitHubNewPullRequestAction.class/instance/basicExecute.st b/Iceberg-Plugin-GitHub.package/IceGitHubNewPullRequestAction.class/instance/basicExecute.st index 79644b7882..c61d82b724 100644 --- a/Iceberg-Plugin-GitHub.package/IceGitHubNewPullRequestAction.class/instance/basicExecute.st +++ b/Iceberg-Plugin-GitHub.package/IceGitHubNewPullRequestAction.class/instance/basicExecute.st @@ -3,22 +3,25 @@ basicExecute credentials := IceGitHubAPI ensureCredentials. - remote ifNil: [ + remote ifNil: [ remote := self repository branch hasUpstream ifTrue: [ self repository branch upstream remote ] - ifFalse: [ self askRemote: self repository ]. + ifFalse: [ self askRemote: self repository ] ]. (self validateMakePullRequestOn: self repository) ifFalse: [ ^ #() ]. - + (IceGitHubCreatePullRequestModel - repository: self repository + repository: self repository credentials: self credentials headRemote: remote) - setModal: true; + setModal: true; onAccept: [ :pullRequest | - [ - pullRequest send. - UIManager default inform: 'Pull request created.' ] - on: IceGitHubError do: [ :e | self reportError: e ] ]; - openWithSpec \ No newline at end of file + [ | pullRequestDatas | + pullRequestDatas := pullRequest send. + UIManager default + inform: 'Pull request created. Click to view on Github.' + actionOnClick: [ self class environment at: #WebBrowser ifPresent: [ :webBrowser | webBrowser openOn: (pullRequestDatas at: 'html_url') ] ifAbsent: [ self inform: 'Feature not available in Pharo 6' ] ] ] + on: IceGitHubError + do: [ :e | self reportError: e ] ]; + openWithSpec \ No newline at end of file diff --git a/Iceberg-Plugin-GitHub.package/IceGitHubPullRequestDefinition.class/instance/send.st b/Iceberg-Plugin-GitHub.package/IceGitHubPullRequestDefinition.class/instance/send.st index 479e26c762..ed3cb8d10c 100644 --- a/Iceberg-Plugin-GitHub.package/IceGitHubPullRequestDefinition.class/instance/send.st +++ b/Iceberg-Plugin-GitHub.package/IceGitHubPullRequestDefinition.class/instance/send.st @@ -9,7 +9,7 @@ send 'body' -> self body. } asDictionary. - IceGitHubAPI new + ^ IceGitHubAPI new credentials: self credentials; addPullRequest: self baseRemote owner project: self baseRemote projectBasename diff --git a/Iceberg-Plugin-GitHub.package/MorphicUIManager.extension/instance/inform.actionOnClick..st b/Iceberg-Plugin-GitHub.package/MorphicUIManager.extension/instance/inform.actionOnClick..st new file mode 100644 index 0000000000..242f7222cc --- /dev/null +++ b/Iceberg-Plugin-GitHub.package/MorphicUIManager.extension/instance/inform.actionOnClick..st @@ -0,0 +1,8 @@ +*Iceberg-Plugin-GitHub +inform: aStringOrText actionOnClick: aBlock + "Display a message for the user to read and then dismiss. When clicked, execute an action." + + (ProvideAnswerNotification signal: aStringOrText) ifNotNil: [ :answer | ^ true ]. + (GrowlMorph openWithLabel: 'Information' translated contents: aStringOrText) + vanishDelay: 2 second; + actionBlock: aBlock \ No newline at end of file diff --git a/Iceberg-Plugin-GitHub.package/MorphicUIManager.extension/properties.json b/Iceberg-Plugin-GitHub.package/MorphicUIManager.extension/properties.json new file mode 100644 index 0000000000..79ec76899a --- /dev/null +++ b/Iceberg-Plugin-GitHub.package/MorphicUIManager.extension/properties.json @@ -0,0 +1,3 @@ +{ + "name" : "MorphicUIManager" +} \ No newline at end of file diff --git a/Iceberg-Plugin-GitHub.package/UIManager.extension/instance/inform.actionOnClick..st b/Iceberg-Plugin-GitHub.package/UIManager.extension/instance/inform.actionOnClick..st new file mode 100644 index 0000000000..5dda81e93c --- /dev/null +++ b/Iceberg-Plugin-GitHub.package/UIManager.extension/instance/inform.actionOnClick..st @@ -0,0 +1,5 @@ +*Iceberg-Plugin-GitHub +inform: aString actionOnClick: aBlock + "Only the MorphicUIManager should make the growl clickable." + + ^ self inform: aString \ No newline at end of file diff --git a/Iceberg-Plugin-GitHub.package/UIManager.extension/properties.json b/Iceberg-Plugin-GitHub.package/UIManager.extension/properties.json new file mode 100644 index 0000000000..f0804a6722 --- /dev/null +++ b/Iceberg-Plugin-GitHub.package/UIManager.extension/properties.json @@ -0,0 +1,3 @@ +{ + "name" : "UIManager" +} \ No newline at end of file From 25242c68aeaf882cf310dba3add8d37c71792406 Mon Sep 17 00:00:00 2001 From: CyrilFerlicot Date: Tue, 30 Oct 2018 12:01:33 +0100 Subject: [PATCH 2/2] Better error report. --- .../instance/basicExecute.st | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Iceberg-Plugin-GitHub.package/IceGitHubNewPullRequestAction.class/instance/basicExecute.st b/Iceberg-Plugin-GitHub.package/IceGitHubNewPullRequestAction.class/instance/basicExecute.st index c61d82b724..31ce9f43d5 100644 --- a/Iceberg-Plugin-GitHub.package/IceGitHubNewPullRequestAction.class/instance/basicExecute.st +++ b/Iceberg-Plugin-GitHub.package/IceGitHubNewPullRequestAction.class/instance/basicExecute.st @@ -17,11 +17,12 @@ basicExecute headRemote: remote) setModal: true; onAccept: [ :pullRequest | - [ | pullRequestDatas | + [ | pullRequestDatas url | pullRequestDatas := pullRequest send. + url := pullRequestDatas at: 'html_url'. UIManager default inform: 'Pull request created. Click to view on Github.' - actionOnClick: [ self class environment at: #WebBrowser ifPresent: [ :webBrowser | webBrowser openOn: (pullRequestDatas at: 'html_url') ] ifAbsent: [ self inform: 'Feature not available in Pharo 6' ] ] ] + actionOnClick: [ self class environment at: #WebBrowser ifPresent: [ :webBrowser | webBrowser openOn: url ] ifAbsent: [ self inform: ('Cannot open "{1}" because the project WebBrowser is not present by default in Pharo 6.' format: { url }) ] ] ] on: IceGitHubError do: [ :e | self reportError: e ] ]; openWithSpec \ No newline at end of file