diff --git a/server/api.postman_collection.json b/server/api.postman_collection.json index 25628c939c..ff6b9f5b90 100644 --- a/server/api.postman_collection.json +++ b/server/api.postman_collection.json @@ -1,6 +1,6 @@ { "info": { - "_postman_id": "cfc9d0fe-d0b2-45c0-ab1f-8795c542c31b", + "_postman_id": "42d60e2e-95bb-4336-8893-afed92d835c3", "name": "scrumlr.io", "description": "This is the documentation for the REST API server of the application [scrumlr.io](https://scrumlr.io). You get in touch with us and send an email to [info@scrumlr.io](https://info@scrumlr.io). The software is [MIT licensed](https://opensource.org/licenses/MIT) so do whatever you want with it. If you want to checkout the progress of our development and take a peek into our backlog you can checkout our [GitHub repository](https://github.com/inovex/scrumlr.io). By the way, this already the third iteration of our server and we're still working on the interface and on further improvements. Since the API is mainly intended for our web client we won't start with API versions at the moment so breaking changes may be incoming. Once it got stable we'll maybe start with that.\n\nIf you're using the postman collection in order to explore the different resources you should also checkout the variables of the collection. Anytime you'll create new resources (e.g. your login or a board) variables will be stored and used for subsequent calls on other resources.\n\nAccess to protected resources will be authorized if a bearer token is sent or it is included in the `jwt` Cookie, which will be automatically set upon login.\n\n## Getting started\n\nLet's try to explain the basic flow of how a new board can will be created and someone tries to join the board as a participant.\n\nFirst you can check whether you are already logged in by a `GET` request on `/user`. See the _User_ section for more information.\n\n1. A user signs into the application (see _Login_ section)\n2. The user creates a new board (`POST` on `/boards`, checkout _Boards_ section)\n3. Another logged in user tries to join the board (`POST` on `/boards/{id}/participants`, checkout _Participants_ section)\n 1. If the boards access policy is set to `PUBLIC` the participant will be added to the board and afterwards all resources will be available\n 2. If the board requires a passphrase and the access policy is set to `BY_PASSPHRASE` a client error will be reported until the user sends the correct passphrase within the payload of the request\n 3. If the boards access policy is set to `BY_INVITE` a session request will be created instead and the user will be redirected to the new resource. The board owner now needs to accept or reject the request until the user can continue\n\nThese are just the basic steps of how sessions can be created. You can also have a look into the section _Realtime_ to see how you can open websockets and listen to live updates on the data.", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", @@ -2643,6 +2643,11 @@ "\r", "pm.test(\"Check if column is correctly not visible\", () => {\r", " pm.expect(res.visible).to.eql(false);\r", + "})\r", + "\r", + "pm.test(\"Check if description is saved\", () => {\r", + " pm.expect(res.description).to.exist;\r", + " pm.expect(res.description).to.equal(\"The column description\");\r", "})" ], "type": "text/javascript", @@ -2655,7 +2660,7 @@ "header": [], "body": { "mode": "raw", - "raw": "{\r\n \"name\": \"My new column\",\r\n \"visible\": false,\r\n \"color\": \"backlog-blue\",\r\n \"index\": 1\r\n}", + "raw": "{\r\n \"name\": \"My new column\",\r\n \"description\": \"The column description\",\r\n \"visible\": false,\r\n \"color\": \"backlog-blue\",\r\n \"index\": 1\r\n}", "options": { "raw": { "language": "json" @@ -2726,7 +2731,7 @@ } ], "cookie": [], - "body": "{\n \"id\": \"fecb346a-9d9e-43ca-b873-8fcb09f2b0c3\",\n \"name\": \"My new column\",\n \"color\": \"lean-lilac\",\n \"visible\": false,\n \"index\": 1\n}" + "body": "{\n \"id\": \"fecb346a-9d9e-43ca-b873-8fcb09f2b0c3\",\n \"name\": \"My new column\",\n \"description\": \"The column description\",\n \"color\": \"lean-lilac\",\n \"visible\": false,\n \"index\": 1\n}" } ] }, @@ -2807,7 +2812,7 @@ } ], "cookie": [], - "body": "[\n {\n \"id\": \"526d5efb-281d-4f4f-b308-6537e6727381\",\n \"name\": \"Lean coffee\",\n \"color\": \"backlog-blue\",\n \"visible\": true,\n \"index\": 0\n },\n {\n \"id\": \"fecb346a-9d9e-43ca-b873-8fcb09f2b0c3\",\n \"name\": \"My new column\",\n \"color\": \"lean-lilac\",\n \"visible\": false,\n \"index\": 1\n },\n {\n \"id\": \"70cb04ee-b46e-4176-940c-cdf06cadef07\",\n \"name\": \"Actions\",\n \"color\": \"planning-pink\",\n \"visible\": false,\n \"index\": 2\n }\n]" + "body": "[\n {\n \"id\": \"526d5efb-281d-4f4f-b308-6537e6727381\",\n \"name\": \"Lean coffee\",\n \"description\": \"The column description\",\n \"color\": \"backlog-blue\",\n \"visible\": true,\n \"index\": 0\n },\n {\n \"id\": \"fecb346a-9d9e-43ca-b873-8fcb09f2b0c3\",\n \"name\": \"My new column\",\n \"description\": \"\",\n \"color\": \"lean-lilac\",\n \"visible\": false,\n \"index\": 1\n },\n {\n \"id\": \"70cb04ee-b46e-4176-940c-cdf06cadef07\",\n \"name\": \"Actions\",\n \"description\": \"\",\n \"color\": \"planning-pink\",\n \"visible\": false,\n \"index\": 2\n }\n]" } ] }, @@ -2827,6 +2832,7 @@ "pm.test(\"Check column\", () => {", " pm.expect(res.id).to.equal(pm.collectionVariables.get(\"column_id\"));", " pm.expect(res.name).to.equal(\"My new column\");", + " pm.expect(res.description).to.equal(\"The column description\");", " pm.expect(res.visible).to.eql(false);", " pm.expect(res.index).to.equal(1);", "})" @@ -2891,7 +2897,7 @@ } ], "cookie": [], - "body": "{\n \"id\": \"fecb346a-9d9e-43ca-b873-8fcb09f2b0c3\",\n \"name\": \"My new column\",\n \"color\": \"lean-lilac\",\n \"visible\": false,\n \"index\": 1\n}" + "body": "{\n \"id\": \"fecb346a-9d9e-43ca-b873-8fcb09f2b0c3\",\n \"name\": \"My new column\",\n \"description\": \"The column description\",\n \"color\": \"lean-lilac\",\n \"visible\": false,\n \"index\": 1\n}" } ] }, @@ -2910,6 +2916,7 @@ "", "pm.test(\"Check updated values\", () => {", " pm.expect(res.name).to.equal(\"Updated column name\");", + " pm.expect(res.description).to.equal(\"The updated column description\");", " pm.expect(res.color).to.equal(\"online-orange\");", " pm.expect(res.visible).to.equal(true);", " pm.expect(res.index).to.equal(0);", @@ -2925,7 +2932,7 @@ "header": [], "body": { "mode": "raw", - "raw": "{\r\n \"name\": \"Updated column name\",\r\n \"color\": \"online-orange\",\r\n \"visible\": true,\r\n \"index\": 0\r\n}", + "raw": "{\r\n \"name\": \"Updated column name\",\r\n \"description\": \"The updated column description\",\r\n \"color\": \"online-orange\",\r\n \"visible\": true,\r\n \"index\": 0\r\n}", "options": { "raw": { "language": "json" @@ -2993,7 +3000,7 @@ } ], "cookie": [], - "body": "{\n \"id\": \"fecb346a-9d9e-43ca-b873-8fcb09f2b0c3\",\n \"name\": \"Updated column name\",\n \"color\": \"online-orange\",\n \"visible\": true,\n \"index\": 0\n}" + "body": "{\n \"id\": \"fecb346a-9d9e-43ca-b873-8fcb09f2b0c3\",\n \"description\": \"The updated column description\",\n \"name\": \"Updated column name\",\n \"color\": \"online-orange\",\n \"visible\": true,\n \"index\": 0\n}" } ] }, diff --git a/server/src/common/dto/columns.go b/server/src/common/dto/columns.go index 1ca0ed102b..10c1ed8531 100644 --- a/server/src/common/dto/columns.go +++ b/server/src/common/dto/columns.go @@ -1,8 +1,9 @@ package dto import ( - "github.com/google/uuid" "net/http" + + "github.com/google/uuid" "scrumlr.io/server/database" "scrumlr.io/server/database/types" ) @@ -16,6 +17,9 @@ type Column struct { // The column name. Name string `json:"name"` + // The column description. + Description string `json:"description"` + // The column color. Color types.Color `json:"color"` @@ -29,6 +33,7 @@ type Column struct { func (c *Column) From(column database.Column) *Column { c.ID = column.ID c.Name = column.Name + c.Description = column.Description c.Color = column.Color c.Visible = column.Visible c.Index = column.Index @@ -57,6 +62,9 @@ type ColumnRequest struct { // The column name to set. Name string `json:"name"` + // The column description to set. + Description string `json:"description"` + // The column color to set. Color types.Color `json:"color"` @@ -78,6 +86,9 @@ type ColumnUpdateRequest struct { // The column name to set. Name string `json:"name"` + // The column description to set. + Description string `json:"description"` + // The column color to set. Color types.Color `json:"color"` diff --git a/server/src/database/columns.go b/server/src/database/columns.go index b0c486fc17..d8b93accbb 100644 --- a/server/src/database/columns.go +++ b/server/src/database/columns.go @@ -18,6 +18,7 @@ type Column struct { ID uuid.UUID Board uuid.UUID Name string + Description string Color types.Color Visible bool Index int @@ -28,6 +29,7 @@ type ColumnInsert struct { bun.BaseModel `bun:"table:columns"` Board uuid.UUID Name string + Description string Color types.Color Visible *bool Index *int @@ -39,6 +41,7 @@ type ColumnUpdate struct { ID uuid.UUID Board uuid.UUID Name string + Description string Color types.Color Visible bool Index int diff --git a/server/src/database/columns_test.go b/server/src/database/columns_test.go index 72461b2bad..00e23dc7ac 100644 --- a/server/src/database/columns_test.go +++ b/server/src/database/columns_test.go @@ -1,10 +1,11 @@ package database import ( + "testing" + "github.com/google/uuid" "github.com/stretchr/testify/assert" "scrumlr.io/server/database/types" - "testing" ) var boardForColumnsTest uuid.UUID @@ -34,6 +35,7 @@ func TestRunnerForColumns(t *testing.T) { t.Run("Create=3", testCreateColumnWithExceptionallyHighIndex) t.Run("Create=4", testCreateColumnWithEmptyName) t.Run("Create=5", testCreateColumnWithEmptyColor) + t.Run("Create=6", testCreateColumnWithDescription) t.Run("Delete=0", testCreateColumnOnSecondIndex) t.Run("Delete=1", testDeleteColumnOnSecondIndex) @@ -49,6 +51,7 @@ func TestRunnerForColumns(t *testing.T) { t.Run("Update=4", testMoveLastColumnOnFirstIndex) t.Run("Update=5", testMoveFirstColumnOnSecondIndex) t.Run("Update=6", testMoveSecondColumnOnFirstIndex) + t.Run("Update=7", testUpdateDescription) } func testGetColumn(t *testing.T) { @@ -179,6 +182,22 @@ func testCreateColumnWithEmptyColor(t *testing.T) { assert.NotNil(t, err) } +func testCreateColumnWithDescription(t *testing.T) { + aDescription := "A description" + column, err := testDb.CreateColumn(ColumnInsert{ + Board: boardForColumnsTest, + Name: "Column", + Color: types.ColorBacklogBlue, + Description: aDescription, + }) + assert.Nil(t, err) + assert.NotNil(t, column) + assert.Equal(t, aDescription, column.Description) + + // clean up to not crash other tests + _ = testDb.DeleteColumn(boardForColumnsTest, column.ID, uuid.New()) +} + func testDeleteColumnOnSecondIndex(t *testing.T) { err := testDb.DeleteColumn(boardForColumnsTest, columnInsertedFifth.ID, columnTestUser.ID) assert.Nil(t, err) @@ -337,3 +356,17 @@ func verifyOrder(t *testing.T, ids ...uuid.UUID) { assert.Equal(t, index, value.Index) } } + +func testUpdateDescription(t *testing.T) { + column, err := testDb.UpdateColumn(ColumnUpdate{ + ID: firstColumn.ID, + Board: boardForColumnsTest, + Name: "FirstColumn", + Description: "Updated Column Description", + Color: types.ColorBacklogBlue, + Visible: true, + Index: 0, + }) + assert.Nil(t, err) + assert.Equal(t, "Updated Column Description", column.Description) +} diff --git a/server/src/database/migrations/sql/19_add_column_description.down.sql b/server/src/database/migrations/sql/19_add_column_description.down.sql new file mode 100644 index 0000000000..74a88bec0a --- /dev/null +++ b/server/src/database/migrations/sql/19_add_column_description.down.sql @@ -0,0 +1 @@ +ALTER TABLE IF EXISTS columns DROP COLUMN IF EXISTS "description"; \ No newline at end of file diff --git a/server/src/database/migrations/sql/19_add_column_description.up.sql b/server/src/database/migrations/sql/19_add_column_description.up.sql new file mode 100644 index 0000000000..7ac7b3a5ec --- /dev/null +++ b/server/src/database/migrations/sql/19_add_column_description.up.sql @@ -0,0 +1 @@ +ALTER TABLE IF EXISTS columns ADD COLUMN "description" VARCHAR(128) DEFAULT ''; \ No newline at end of file diff --git a/server/src/services/boards/columns.go b/server/src/services/boards/columns.go index 6401b6cefd..8f01eafbd7 100644 --- a/server/src/services/boards/columns.go +++ b/server/src/services/boards/columns.go @@ -16,7 +16,7 @@ import ( ) func (s *BoardService) CreateColumn(_ context.Context, body dto.ColumnRequest) (*dto.Column, error) { - column, err := s.database.CreateColumn(database.ColumnInsert{Board: body.Board, Name: body.Name, Color: body.Color, Visible: body.Visible, Index: body.Index}) + column, err := s.database.CreateColumn(database.ColumnInsert{Board: body.Board, Name: body.Name, Description: body.Description, Color: body.Color, Visible: body.Visible, Index: body.Index}) if err != nil { logger.Get().Errorw("unable to create column", "err", err) return nil, err @@ -36,7 +36,7 @@ func (s *BoardService) DeleteColumn(_ context.Context, board, column, user uuid. } func (s *BoardService) UpdateColumn(_ context.Context, body dto.ColumnUpdateRequest) (*dto.Column, error) { - column, err := s.database.UpdateColumn(database.ColumnUpdate{ID: body.ID, Board: body.Board, Name: body.Name, Color: body.Color, Visible: body.Visible, Index: body.Index}) + column, err := s.database.UpdateColumn(database.ColumnUpdate{ID: body.ID, Board: body.Board, Name: body.Name, Description: body.Description, Color: body.Color, Visible: body.Visible, Index: body.Index}) if err != nil { logger.Get().Errorw("unable to update column", "err", err) return nil, err