Skip to content

Introduce fork_namespace entity and serializer

Illya Klymov requested to merge xanf-introduce-fork-serializer into master

What does this MR do?

This MR introduces fork_namespace entity and serializer which will be consumed by fork controller to provide required data in JSON format to new fork page (related issue: #212456 (closed))

Main integration MR: !35592 (merged)

Desired output format from controller:

{ "namespaces": [{
  "id": 22,
  "name": "Gitlab Org",
  "description": "Ad et ipsam earum id aut nobis.",
  "visibility": "public",
  "full_name": "Gitlab Org",
  "created_at": "2020-06-22T03:32:05.664Z",
  "updated_at": "2020-06-22T03:32:05.664Z",
  "avatar_url": null,
  "fork_path": "/twitter/typeahead-js/-/forks?namespace_key=22",
  "forked_project_path": null,
  "permission": "Owner",
  "relative_path": "/gitlab-org",
  "markdown_description": "<p data-sourcepos=\"1:1-1:31\" dir=\"auto\">Ad et ipsam earum id aut nobis.</p>",
  "can_create_project": true,
  "marked_for_deletion": false
}]}

Important fields:

  • fork_path - path to fork project to namespaces
  • forked_project_path - path to existing fork in namespace

This serializer will be consumed in fork controller in following way:

    respond_to do |format|
      # ... skipped ...
      format.json do
        namespaces = fork_service.valid_fork_targets - [current_user.namespace, project.namespace]
        render json: {
          namespaces: ForkNamespaceSerializer.new.represent(namespaces, project: project, current_user: current_user)
        }
      end
    end

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Edited by Ethan Urie

Merge request reports