Module: API::Helpers::RelatedResourcesHelpers
- Includes:
- GrapePathHelpers::NamedRouteMatcher
- Included in:
- Entities::ContainerRegistry::Repository, Entities::Issue, Entities::Ml::Mlflow::ModelVersion, Entities::Ml::Mlflow::RunInfo, Entities::Package, Entities::Project, Entities::ProjectExportStatus, Version, VsCode::Settings::Entities::VsCodeSettingReference, FeatureFlagsHelper, Gitlab::Composer::VersionIndex, GitlabRoutingHelper, GroupsController, JiraConnect::AppDataSerializer, Ml::ModelVersionPresenter, Packages::Composer::PackagesPresenter, Packages::Conan::PackagePresenter, Packages::Helm::IndexPresenter, Packages::Npm::GenerateMetadataService, Packages::Nuget::OdataPackageEntryService, Packages::Nuget::PresenterHelpers, Packages::Nuget::ServiceIndexPresenter, Packages::Nuget::V2::ServiceIndexPresenter, Packages::Pypi::SimplePresenterBase, PackagesHelper, ProjectsController, TestCaseEntity, Types::Terraform::StateVersionType, WikiHelper
- Defined in:
- lib/api/helpers/related_resources_helpers.rb
Instance Method Summary collapse
- #expose_path(path) ⇒ Object
- #expose_url(path) ⇒ Object
- #issues_available?(project, options) ⇒ Boolean
- #mrs_available?(project, options) ⇒ Boolean
- #project_feature_string_access_level(project, feature) ⇒ Object
Instance Method Details
#expose_path(path) ⇒ Object
20 21 22 |
# File 'lib/api/helpers/related_resources_helpers.rb', line 20 def expose_path(path) Gitlab::Utils.append_path(Gitlab.config.gitlab.relative_url_root, path) end |
#expose_url(path) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/api/helpers/related_resources_helpers.rb', line 24 def expose_url(path) = Gitlab::Application.routes. protocol, host, port, script_name = .values_at(:protocol, :host, :port, :script_name) # Using a blank component at the beginning of the join we ensure # that the resulted path will start with '/'. If the resulted path # does not start with '/', URI::Generic#new will fail path_with_script_name = File.join('', [script_name, path].select(&:present?)) URI::Generic.new(protocol, nil, host, port, nil, path_with_script_name, nil, nil, nil, URI::RFC3986_PARSER, true).to_s end |
#issues_available?(project, options) ⇒ Boolean
8 9 10 |
# File 'lib/api/helpers/related_resources_helpers.rb', line 8 def issues_available?(project, ) available?(:issues, project, [:current_user]) end |
#mrs_available?(project, options) ⇒ Boolean
16 17 18 |
# File 'lib/api/helpers/related_resources_helpers.rb', line 16 def mrs_available?(project, ) available?(:merge_requests, project, [:current_user]) end |
#project_feature_string_access_level(project, feature) ⇒ Object
12 13 14 |
# File 'lib/api/helpers/related_resources_helpers.rb', line 12 def project_feature_string_access_level(project, feature) project.project_feature&.string_access_level(feature) end |