Follow-up from "Pipeline security dashboard: Move EE specific code to EE folder"

The following discussion from !6538 (merged) should be addressed:

  • @godfat started a discussion: (+4 comments)

    We could apply the same any? + public_send trick here. I don't know if it's a good idea, but that's ok to me :P

    Also let's have these on the top and use them:

    - pipeline = local_assigns.fetch(:pipeline)
    - project = local_assigns.fetch(:project)

I really don't like the code here... but I could see that's what it was before, so I am fine keeping those for now. However I would hope we have something like this:

class ExposeCiPipeline
  attr_reader :pipeline, :project

  def initialize(new_pipeline, new_project)
    self.pipeline = new_pipeline
    self.project = new_project
  end

  def expose_security_dashboard?
    # ...
  end

  def sast_container_endpoint
    # ...
  end

  private

  attr_writer :pipeline, :project
end

So in the view, it should be very straightforward:

- expose = ExposeCiPipeline.new(pipeline, project)

#something { data: { endpoint: expose.sast_container_endpoint } }

We won't have to add so many random things to the model, too, which should really just focus on the data. Perhaps we could also just use presenter:

https://gitlab.com/gitlab-org/gitlab-ce/blob/master/app/presenters/README.md

We could do this in the next iteration though, of course.

We should introduce a new presenter here.

Assignee Loading
Time tracking Loading