From dd0404146269c72757b47f0336698de65ee8b3c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Prei=C3=9Fner?= Date: Tue, 21 May 2024 12:13:25 +0200 Subject: [PATCH] added support for notes --- .../SPBCard.class/class/newFrom.with..st | 2 +- .../SPBCard.class/instance/buildCard..st | 6 ++++++ .../SPBCard.class/instance/buildNote..st | 7 +++++++ .../SPBCard.class/instance/isNote..st | 4 ++++ .../SPBCard.class/instance/isNote.st | 5 +++++ .../SPBCard.class/methodProperties.json | 6 +++++- .../SPBCard.class/properties.json | 3 ++- .../instance/updateNote.withPostData..st | 13 +++++++++++++ .../SPBGithubAPI.class/methodProperties.json | 3 ++- .../instance/createCardsFromColumn..st | 9 ++------- .../instance/updateCard..st | 9 +++++++-- .../methodProperties.json | 4 ++-- .../instance/testBuildIssueFromJson.st | 10 ++++++++++ .../instance/testBuildNoteFromJson.st | 10 ++++++++++ .../SPBCardTests.class/methodProperties.json | 2 ++ .../instance/testUpdateNote.st | 15 +++++++++++++++ .../methodProperties.json | 1 + .../instance/updateNote.withPostData..st | 5 +++++ .../SPBMockGithubAPI.class/methodProperties.json | 3 ++- 19 files changed, 101 insertions(+), 16 deletions(-) create mode 100644 Squello-Core.package/SPBCard.class/instance/buildCard..st create mode 100644 Squello-Core.package/SPBCard.class/instance/buildNote..st create mode 100644 Squello-Core.package/SPBCard.class/instance/isNote..st create mode 100644 Squello-Core.package/SPBCard.class/instance/isNote.st create mode 100644 Squello-Core.package/SPBGithubAPI.class/instance/updateNote.withPostData..st create mode 100644 Squello-Tests.package/SPBCardTests.class/instance/testBuildIssueFromJson.st create mode 100644 Squello-Tests.package/SPBCardTests.class/instance/testBuildNoteFromJson.st create mode 100644 Squello-Tests.package/SPBGithubBoardProviderTests.class/instance/testUpdateNote.st create mode 100644 Squello-Tests.package/SPBMockGithubAPI.class/instance/updateNote.withPostData..st diff --git a/Squello-Core.package/SPBCard.class/class/newFrom.with..st b/Squello-Core.package/SPBCard.class/class/newFrom.with..st index 8a037c9e..2bcbe943 100644 --- a/Squello-Core.package/SPBCard.class/class/newFrom.with..st +++ b/Squello-Core.package/SPBCard.class/class/newFrom.with..st @@ -6,7 +6,7 @@ newFrom: aJsonObject with: anSPBColumn boardProvider: anSPBColumn boardProvider; changeProvider: anSPBColumn changeProvider; setupMouseEvents; - buildContent: (aJsonObject at: 'content_url'); + buildCard: aJsonObject; buildUI; openInWorld; yourself. \ No newline at end of file diff --git a/Squello-Core.package/SPBCard.class/instance/buildCard..st b/Squello-Core.package/SPBCard.class/instance/buildCard..st new file mode 100644 index 00000000..b6d70eb9 --- /dev/null +++ b/Squello-Core.package/SPBCard.class/instance/buildCard..st @@ -0,0 +1,6 @@ +accessing +buildCard: aJsonObject + + (aJsonObject at: 'content_url') + ifNotNil: [:aString| self buildContent: aString] + ifNil: [self buildNote: aJsonObject]. \ No newline at end of file diff --git a/Squello-Core.package/SPBCard.class/instance/buildNote..st b/Squello-Core.package/SPBCard.class/instance/buildNote..st new file mode 100644 index 00000000..058368b8 --- /dev/null +++ b/Squello-Core.package/SPBCard.class/instance/buildNote..st @@ -0,0 +1,7 @@ +accessing +buildNote: aJsonObject + + self + isNote: true; + title: (aJsonObject at: 'note'); + description: ''. \ No newline at end of file diff --git a/Squello-Core.package/SPBCard.class/instance/isNote..st b/Squello-Core.package/SPBCard.class/instance/isNote..st new file mode 100644 index 00000000..36917903 --- /dev/null +++ b/Squello-Core.package/SPBCard.class/instance/isNote..st @@ -0,0 +1,4 @@ +accessing +isNote: aBoolean + + isNote := aBoolean. \ No newline at end of file diff --git a/Squello-Core.package/SPBCard.class/instance/isNote.st b/Squello-Core.package/SPBCard.class/instance/isNote.st new file mode 100644 index 00000000..0a4cf63e --- /dev/null +++ b/Squello-Core.package/SPBCard.class/instance/isNote.st @@ -0,0 +1,5 @@ +accessing +isNote + + isNote ifNil: [self isNote: false]. + ^ isNote. \ No newline at end of file diff --git a/Squello-Core.package/SPBCard.class/methodProperties.json b/Squello-Core.package/SPBCard.class/methodProperties.json index c575a8ef..64e0f114 100644 --- a/Squello-Core.package/SPBCard.class/methodProperties.json +++ b/Squello-Core.package/SPBCard.class/methodProperties.json @@ -5,7 +5,7 @@ "buildNewFromRemote:into:" : "mcr 8/3/2022 14:56", "defaultCardExtent" : "lo 8/1/2022 12:18", "indicatorCardEdgeOffset" : "lo 8/1/2022 12:23", - "newFrom:with:" : "jh 8/3/2022 00:53" }, + "newFrom:with:" : "FP 5/20/2024 19:15" }, "instance" : { "=" : "lo 7/31/2022 18:14", "addAssignee:" : "lo 7/31/2022 16:22", @@ -22,9 +22,11 @@ "boardProvider" : "jh 7/29/2022 12:46", "boardProvider:" : "lo 7/31/2022 16:30", "buildAssigneeText" : "mcr 8/4/2022 01:38", + "buildCard:" : "FP 5/21/2024 11:49", "buildContent:" : "mcr 8/4/2022 01:39", "buildIndicatorDetection" : "tk 8/2/2022 23:23", "buildIndicatorDetectionHalf" : "lo 8/1/2022 11:37", + "buildNote:" : "FP 5/20/2024 20:02", "buildTitle" : "mcr 8/4/2022 01:41", "buildUI" : "jh 8/3/2022 00:19", "calculateLabelPositionFor:" : "mcr 8/4/2022 01:35", @@ -45,6 +47,8 @@ "inbetweenLabelOffset" : "lo 8/1/2022 11:18", "indicateDroppointWith:" : "mcr 8/4/2022 01:45", "initialize" : "mcr 8/4/2022 01:38", + "isNote" : "FP 5/20/2024 20:00", + "isNote:" : "FP 5/20/2024 19:53", "isRealCard" : "lo 7/31/2022 16:55", "issueId" : "LW 5/24/2022 21:51", "issueId:" : "LW 7/14/2022 10:48", diff --git a/Squello-Core.package/SPBCard.class/properties.json b/Squello-Core.package/SPBCard.class/properties.json index ba2c1d70..5e37ffb9 100644 --- a/Squello-Core.package/SPBCard.class/properties.json +++ b/Squello-Core.package/SPBCard.class/properties.json @@ -19,7 +19,8 @@ "upperHalfIndicator", "titleModel", "assigneeModel", - "labelModels" ], + "labelModels", + "isNote" ], "name" : "SPBCard", "pools" : [ ], diff --git a/Squello-Core.package/SPBGithubAPI.class/instance/updateNote.withPostData..st b/Squello-Core.package/SPBGithubAPI.class/instance/updateNote.withPostData..st new file mode 100644 index 00000000..8bd58595 --- /dev/null +++ b/Squello-Core.package/SPBGithubAPI.class/instance/updateNote.withPostData..st @@ -0,0 +1,13 @@ +api call patch request +updateNote: aNumber withPostData: aDictionary + + "aNumber -> CardID" + "aDictionary Parameter: + note -> string" + + | stream url | + url := 'https://api.github.com/projects/columns/cards/' , aNumber. + stream := WriteStream with: OrderedCollection new. + aDictionary jsonWriteOn: stream. + + self patchRequestToURL: url withData: stream. \ No newline at end of file diff --git a/Squello-Core.package/SPBGithubAPI.class/methodProperties.json b/Squello-Core.package/SPBGithubAPI.class/methodProperties.json index cd87d1a2..26829ae7 100644 --- a/Squello-Core.package/SPBGithubAPI.class/methodProperties.json +++ b/Squello-Core.package/SPBGithubAPI.class/methodProperties.json @@ -34,4 +34,5 @@ "querySingleCard:" : "mcr 8/3/2022 14:18", "queryUser:repo:" : "mcr 8/2/2022 21:06", "updateColumn:withData:" : "lo 7/13/2022 20:28", - "updateIssue:withData:user:repo:" : "lo 7/13/2022 20:29" } } + "updateIssue:withData:user:repo:" : "lo 7/13/2022 20:29", + "updateNote:withPostData:" : "FP 5/21/2024 11:24" } } diff --git a/Squello-Core.package/SPBGithubBoardProvider.class/instance/createCardsFromColumn..st b/Squello-Core.package/SPBGithubBoardProvider.class/instance/createCardsFromColumn..st index 759f02b5..a39a3ba3 100644 --- a/Squello-Core.package/SPBGithubBoardProvider.class/instance/createCardsFromColumn..st +++ b/Squello-Core.package/SPBGithubBoardProvider.class/instance/createCardsFromColumn..st @@ -1,13 +1,8 @@ cards createCardsFromColumn: anSPBColumn - | cardsJson onlyIssueCardsJson | + | cardsJson | cardsJson := (self api queryCards: anSPBColumn id) asOrderedCollection. - "at the moment we can just display issues and pull requests. - If a card is a note (than it has no content_url) it will be skipped" - onlyIssueCardsJson := cardsJson - reject: [:cardJson | (cardJson at: 'content_url') isNil]. - - onlyIssueCardsJson + cardsJson do: [:cardJson | SPBCard buildFromRemote: cardJson into: anSPBColumn]. \ No newline at end of file diff --git a/Squello-Core.package/SPBGithubBoardProvider.class/instance/updateCard..st b/Squello-Core.package/SPBGithubBoardProvider.class/instance/updateCard..st index 880e7f20..7c0373ab 100644 --- a/Squello-Core.package/SPBGithubBoardProvider.class/instance/updateCard..st +++ b/Squello-Core.package/SPBGithubBoardProvider.class/instance/updateCard..st @@ -2,5 +2,10 @@ cards updateCard: anSPBCard | payload | - payload := Dictionary newFrom: {'title' -> anSPBCard title . 'body' -> anSPBCard description}. - self api updateIssue: anSPBCard issueId withData: payload user: self user repo: self repo. \ No newline at end of file + anSPBCard isNote + ifTrue: [ + payload := Dictionary newFrom: {'note' -> anSPBCard title}. + self api updateNote: anSPBCard id withPostData: payload.] + ifFalse: [ + payload := Dictionary newFrom: {'title' -> anSPBCard title . 'body' -> anSPBCard description}. + self api updateIssue: anSPBCard issueId withData: payload user: self user repo: self repo.]. \ No newline at end of file diff --git a/Squello-Core.package/SPBGithubBoardProvider.class/methodProperties.json b/Squello-Core.package/SPBGithubBoardProvider.class/methodProperties.json index 0657ba1f..023916e7 100644 --- a/Squello-Core.package/SPBGithubBoardProvider.class/methodProperties.json +++ b/Squello-Core.package/SPBGithubBoardProvider.class/methodProperties.json @@ -8,7 +8,7 @@ "api:" : "tk 7/30/2022 22:20", "checkForError:" : "jh 7/31/2022 13:54", "checkIfUserExists:" : "NTK 7/30/2022 12:45", - "createCardsFromColumn:" : "mcr 8/3/2022 15:41", + "createCardsFromColumn:" : "FP 5/20/2024 20:01", "createColumn:" : "jh 7/31/2022 13:54", "createNewCard:into:" : "mcr 8/3/2022 13:59", "createSingleCard:into:" : "mcr 8/4/2022 02:10", @@ -33,7 +33,7 @@ "renameColumn:to:" : "tk 7/30/2022 22:22", "repo" : "mcr 5/22/2022 01:01", "repo:" : "mcr 5/22/2022 01:02", - "updateCard:" : "lo 7/13/2022 20:29", + "updateCard:" : "FP 5/21/2024 11:22", "user" : "mcr 5/22/2022 01:02", "user:" : "mcr 5/22/2022 01:02", "webhookId" : "NTK 7/30/2022 12:46" } } diff --git a/Squello-Tests.package/SPBCardTests.class/instance/testBuildIssueFromJson.st b/Squello-Tests.package/SPBCardTests.class/instance/testBuildIssueFromJson.st new file mode 100644 index 00000000..50d5399f --- /dev/null +++ b/Squello-Tests.package/SPBCardTests.class/instance/testBuildIssueFromJson.st @@ -0,0 +1,10 @@ +tests +testBuildIssueFromJson + + | issueJson | + issueJson := '{ + "content_url": "https://api.github.com/repos/test-organization/test-repo/issues/42"}' parseAsJson. + + card buildCard: issueJson. + self assert: card isNote not. + self assert: card issueId = 3 \ No newline at end of file diff --git a/Squello-Tests.package/SPBCardTests.class/instance/testBuildNoteFromJson.st b/Squello-Tests.package/SPBCardTests.class/instance/testBuildNoteFromJson.st new file mode 100644 index 00000000..ed021bc6 --- /dev/null +++ b/Squello-Tests.package/SPBCardTests.class/instance/testBuildNoteFromJson.st @@ -0,0 +1,10 @@ +tests +testBuildNoteFromJson + + | noteJson | + noteJson := '{ + "note": "this is a note"}' parseAsJson. + + card buildCard: noteJson. + self assert: card isNote. + self assert: card title = 'this is a note'. \ No newline at end of file diff --git a/Squello-Tests.package/SPBCardTests.class/methodProperties.json b/Squello-Tests.package/SPBCardTests.class/methodProperties.json index 6938f7ce..9ced3020 100644 --- a/Squello-Tests.package/SPBCardTests.class/methodProperties.json +++ b/Squello-Tests.package/SPBCardTests.class/methodProperties.json @@ -5,6 +5,8 @@ "setUp" : "lo 7/31/2022 17:47", "tearDown" : "lo 5/22/2022 15:36", "testBecomeActiveCard" : "mcr 8/1/2022 01:35", + "testBuildIssueFromJson" : "FP 5/21/2024 11:51", + "testBuildNoteFromJson" : "FP 5/21/2024 12:07", "testCurrentLane" : "tk 7/30/2022 23:24", "testDescription" : "lo 5/22/2022 16:34", "testDontUpdateDescription" : "lo 5/22/2022 16:35", diff --git a/Squello-Tests.package/SPBGithubBoardProviderTests.class/instance/testUpdateNote.st b/Squello-Tests.package/SPBGithubBoardProviderTests.class/instance/testUpdateNote.st new file mode 100644 index 00000000..af6dc70b --- /dev/null +++ b/Squello-Tests.package/SPBGithubBoardProviderTests.class/instance/testUpdateNote.st @@ -0,0 +1,15 @@ +tests +testUpdateNote + + | card data | + card := SPBCard new + id: 42; + title: 'Das ist eine Note'; + isNote: true. + + provider updateCard: card. + + data := provider api messages first. + + self assert: 'Das ist eine Note' equals: (data at: 'note'). + self assert: 42 equals: (data at: 'id'). \ No newline at end of file diff --git a/Squello-Tests.package/SPBGithubBoardProviderTests.class/methodProperties.json b/Squello-Tests.package/SPBGithubBoardProviderTests.class/methodProperties.json index 9b3c8de4..1637d47d 100644 --- a/Squello-Tests.package/SPBGithubBoardProviderTests.class/methodProperties.json +++ b/Squello-Tests.package/SPBGithubBoardProviderTests.class/methodProperties.json @@ -17,4 +17,5 @@ "testRenameColumn" : "tk 7/30/2022 23:26", "testRepo" : "mcr 5/31/2022 19:02", "testUpdateCard" : "lo 7/13/2022 20:31", + "testUpdateNote" : "FP 5/21/2024 11:32", "testUser" : "mcr 5/31/2022 19:03" } } diff --git a/Squello-Tests.package/SPBMockGithubAPI.class/instance/updateNote.withPostData..st b/Squello-Tests.package/SPBMockGithubAPI.class/instance/updateNote.withPostData..st new file mode 100644 index 00000000..04af7489 --- /dev/null +++ b/Squello-Tests.package/SPBMockGithubAPI.class/instance/updateNote.withPostData..st @@ -0,0 +1,5 @@ +as yet unclassified +updateNote: aNumber withPostData: aDictionary + + aDictionary at: 'id' put: aNumber. + self messages add: aDictionary. \ No newline at end of file diff --git a/Squello-Tests.package/SPBMockGithubAPI.class/methodProperties.json b/Squello-Tests.package/SPBMockGithubAPI.class/methodProperties.json index 10a5f8af..21d22e37 100644 --- a/Squello-Tests.package/SPBMockGithubAPI.class/methodProperties.json +++ b/Squello-Tests.package/SPBMockGithubAPI.class/methodProperties.json @@ -12,4 +12,5 @@ "moveCard:withPostData:" : "lo 7/13/2022 20:06", "queryProjectsForUser:repo:" : "FP 5/11/2024 15:00", "updateColumn:withData:" : "lo 7/13/2022 20:28", - "updateIssue:withData:user:repo:" : "lo 7/13/2022 20:34" } } + "updateIssue:withData:user:repo:" : "lo 7/13/2022 20:34", + "updateNote:withPostData:" : "FP 5/21/2024 11:34" } }