Skip to content

Commit

Permalink
added support for notes
Browse files Browse the repository at this point in the history
  • Loading branch information
FePrHPI committed May 21, 2024
1 parent ae4289d commit dd04041
Show file tree
Hide file tree
Showing 19 changed files with 101 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Squello-Core.package/SPBCard.class/class/newFrom.with..st
Original file line number Diff line number Diff line change
Expand Up @@ -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.
6 changes: 6 additions & 0 deletions Squello-Core.package/SPBCard.class/instance/buildCard..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
accessing
buildCard: aJsonObject

(aJsonObject at: 'content_url')
ifNotNil: [:aString| self buildContent: aString]
ifNil: [self buildNote: aJsonObject].
7 changes: 7 additions & 0 deletions Squello-Core.package/SPBCard.class/instance/buildNote..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
accessing
buildNote: aJsonObject

self
isNote: true;
title: (aJsonObject at: 'note');
description: ''.
4 changes: 4 additions & 0 deletions Squello-Core.package/SPBCard.class/instance/isNote..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
isNote: aBoolean

isNote := aBoolean.
5 changes: 5 additions & 0 deletions Squello-Core.package/SPBCard.class/instance/isNote.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
accessing
isNote

isNote ifNil: [self isNote: false].
^ isNote.
6 changes: 5 additions & 1 deletion Squello-Core.package/SPBCard.class/methodProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion Squello-Core.package/SPBCard.class/properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"upperHalfIndicator",
"titleModel",
"assigneeModel",
"labelModels" ],
"labelModels",
"isNote" ],
"name" : "SPBCard",
"pools" : [
],
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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" } }
Original file line number Diff line number Diff line change
@@ -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].
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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.].
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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" } }
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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'.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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').
Original file line number Diff line number Diff line change
Expand Up @@ -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" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
as yet unclassified
updateNote: aNumber withPostData: aDictionary

aDictionary at: 'id' put: aNumber.
self messages add: aDictionary.
Original file line number Diff line number Diff line change
Expand Up @@ -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" } }

0 comments on commit dd04041

Please sign in to comment.