Skip to content

Retrieve epic list user preference collapsed value

charlie ablett requested to merge 301018-cablett-collapsed-epic-board-list into master

What does this MR do?

Implements and exposes user preferences for epic board lists so we can retrieve whether or not a user has set an epic board list as collapsed.

  • Add a new database table
  • Moves some logic into a shared concern with List (the issue board model)
  • Moves some tests into a shared example and generalise them a bit
  • Exposes the collapsed preference via GraphQL under the epic board list as collapsed

To test:

  • Enable feature flag epic_boards
  • Create an epic board (see below)
  • Use the following GraphQL query:
{
  group(fullPath: "group") {
    epicBoards {
      nodes {
        name
        lists {
          nodes {
            title
            collapsed
          }
        }
      }
    }
  }
}

To create a new epic board:

Database migrations:

up

$ bundle exec rake db:migrate:up VERSION=20210217101901
== 20210217101901 CreateEpicListUserPreferences: migrating ====================
-- create_table(:boards_epic_list_user_preferences)
   -> 0.0133s
-- add_index(:boards_epic_list_user_preferences, [:user_id, :epic_list_id], {:unique=>true, :name=>"index_epic_board_list_preferences_on_user_and_list"})
   -> 0.0031s
== 20210217101901 CreateEpicListUserPreferences: migrated (0.0165s) ===========

$ bundle exec rake db:migrate:up VERSION=20210222085529
== 20210222085529 AddEpicBoardUserPreferenceUserFk: migrating =================
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:boards_epic_list_user_preferences)
   -> 0.0022s
-- execute("ALTER TABLE boards_epic_list_user_preferences\nADD CONSTRAINT fk_f5f2fe5c1f\nFOREIGN KEY (user_id)\nREFERENCES users (id)\nON DELETE CASCADE\nNOT VALID;\n")
   -> 0.0130s
-- execute("SET statement_timeout TO 0")
   -> 0.0003s
-- execute("ALTER TABLE boards_epic_list_user_preferences VALIDATE CONSTRAINT fk_f5f2fe5c1f;")
   -> 0.0072s
-- execute("RESET ALL")
   -> 0.0004s
== 20210222085529 AddEpicBoardUserPreferenceUserFk: migrated (0.0274s) ========

$ bundle exec rake db:migrate:up VERSION=20210222085551
== 20210222085551 AddEpicBoardUserPreferenceEpicListFk: migrating =============
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:boards_epic_list_user_preferences)
   -> 0.0019s
-- execute("ALTER TABLE boards_epic_list_user_preferences\nADD CONSTRAINT fk_95eac55851\nFOREIGN KEY (epic_list_id)\nREFERENCES boards_epic_lists (id)\nON DELETE CASCADE\nNOT VALID;\n")
   -> 0.0020s
-- execute("SET statement_timeout TO 0")
   -> 0.0003s
-- execute("ALTER TABLE boards_epic_list_user_preferences VALIDATE CONSTRAINT fk_95eac55851;")
   -> 0.0018s
-- execute("RESET ALL")
   -> 0.0004s
== 20210222085551 AddEpicBoardUserPreferenceEpicListFk: migrated (0.0102s) ====

down

$ bundle exec rake db:migrate:down VERSION=20210222085551
== 20210222085551 AddEpicBoardUserPreferenceEpicListFk: reverting =============
-- foreign_keys(:boards_epic_list_user_preferences)
   -> 0.0045s
-- remove_foreign_key(:boards_epic_list_user_preferences, :boards_epic_lists)
   -> 0.0061s
== 20210222085551 AddEpicBoardUserPreferenceEpicListFk: reverted (0.0147s) ====

$ bundle exec rake db:migrate:down VERSION=20210222085529
== 20210222085529 AddEpicBoardUserPreferenceUserFk: reverting =================
-- foreign_keys(:boards_epic_list_user_preferences)
   -> 0.0021s
-- remove_foreign_key(:boards_epic_list_user_preferences, :users)
   -> 0.0025s
== 20210222085529 AddEpicBoardUserPreferenceUserFk: reverted (0.0080s) ========

$ bundle exec rake db:migrate:down VERSION=20210217101901
== 20210217101901 CreateEpicListUserPreferences: reverting ====================
-- drop_table(:boards_epic_list_user_preferences)
   -> 0.0039s
== 20210217101901 CreateEpicListUserPreferences: reverted (0.0040s) ===========

Screenshots (strongly suggested)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Related to #301018 (closed)

Edited by charlie ablett

Merge request reports