From c5e8ff66fb24a117100ab8ca55fbe4d0567ec7c3 Mon Sep 17 00:00:00 2001 From: Hangya Date: Sun, 10 Mar 2024 11:23:38 +0000 Subject: [PATCH] fix(migration): updated Trello color map to import all labels (#2178) Trello has [added 20 color variants](https://www.atlassian.com/blog/trello/20-new-trello-label-colors) that were not imported, added them. Also added a fallback to save labels even if the color is not mapped yet. Resolves https://community.vikunja.io/t/get-info-about-importation-trello/1968/16 Reviewed-on: https://kolaente.dev/vikunja/vikunja/pulls/2178 Reviewed-by: konrad Co-authored-by: Hangya Co-committed-by: Hangya --- pkg/modules/migration/trello/trello.go | 48 +++++++++++++++------ pkg/modules/migration/trello/trello_test.go | 18 ++++++++ 2 files changed, 52 insertions(+), 14 deletions(-) diff --git a/pkg/modules/migration/trello/trello.go b/pkg/modules/migration/trello/trello.go index 676201b90..3c44000fc 100644 --- a/pkg/modules/migration/trello/trello.go +++ b/pkg/modules/migration/trello/trello.go @@ -37,19 +37,39 @@ type Migration struct { var trelloColorMap map[string]string func init() { - trelloColorMap = make(map[string]string, 10) + trelloColorMap = make(map[string]string, 30) trelloColorMap = map[string]string{ - "green": "61bd4f", - "yellow": "f2d600", - "orange": "ff9f1a", - "red": "eb5a46", - "sky": "00c2e0", - "lime": "51e898", - "purple": "c377e0", - "blue": "0079bf", - "pink": "ff78cb", - "black": "344563", - "transparent": "", // Empty + "green": "4bce97", + "yellow": "f5cd47", + "orange": "fea362", + "red": "f87168", + "purple": "9f8fef", + "blue": "579dff", + "sky": "6cc3e0", + "lime": "94c748", + "pink": "e774bb", + "black": "8590a2", + "green_dark": "1f845a", + "yellow_dark": "946f00", + "orange_dark": "c25100", + "red_dark": "c9372c", + "purple_dark": "6e5dc6", + "blue_dark": "0c66e4", + "sky_dark": "227d9b", + "lime_dark": "5b7f24", + "pink_dark": "ae4787", + "black_dark": "626f86", + "green_light": "baf3db", + "yellow_light": "f8e6a0", + "orange_light": "fedec8", + "red_light": "ffd5d2", + "purple_light": "dfd8fd", + "blue_light": "cce0ff", + "sky_light": "c6edfb", + "lime_light": "d3f1a7", + "ping_light": "fdd0ec", + "black_light": "dcdfe4", + "transparent": "", // Empty } } @@ -268,8 +288,8 @@ func convertTrelloDataToVikunja(trelloData []*trello.Board, token string) (fullV for _, label := range card.Labels { color, exists := trelloColorMap[label.Color] if !exists { - log.Debugf("[Trello Migration] Color %s not mapped for trello card %s, not adding label", label.Color, card.ID) - continue + log.Debugf("[Trello Migration] Color %s not mapped for trello card %s, falling back to transparent", label.Color, card.ID) + color = trelloColorMap["transparent"] } task.Labels = append(task.Labels, &models.Label{ diff --git a/pkg/modules/migration/trello/trello_test.go b/pkg/modules/migration/trello/trello_test.go index 2b4c6af1e..cb1c59c10 100644 --- a/pkg/modules/migration/trello/trello_test.go +++ b/pkg/modules/migration/trello/trello_test.go @@ -137,6 +137,16 @@ func TestConvertTrelloToVikunja(t *testing.T) { Name: "Label 3", Color: "blue", }, + { + ID: "ide4", + Name: "Label 4", + Color: "green_dark", + }, + { + ID: "ide5", + Name: "Label 5", + Color: "doesnotexist", + }, }, }, { @@ -294,6 +304,14 @@ func TestConvertTrelloToVikunja(t *testing.T) { Title: "Label 3", HexColor: trelloColorMap["blue"], }, + { + Title: "Label 4", + HexColor: trelloColorMap["green_dark"], + }, + { + Title: "Label 5", + HexColor: trelloColorMap["transparent"], + }, }, }, },