Commit 83b2da49 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'ce-to-ee-2018-07-24' into 'master'

CE upstream - 2018-07-24 15:22 UTC

Closes #6028

See merge request gitlab-org/gitlab-ee!6644
parents ca7a5bf6 4a74b247
......@@ -582,9 +582,8 @@ danger-review:
- retry gem install danger --no-ri --no-rdoc
cache: {}
only:
refs:
- branches@gitlab-org/gitlab-ce
- branches@gitlab-org/gitlab-ee
variables:
- $DANGER_GITLAB_API_TOKEN
except:
refs:
- master
......
......@@ -4,3 +4,4 @@ danger.import_dangerfile(path: 'danger/changelog')
danger.import_dangerfile(path: 'danger/specs')
danger.import_dangerfile(path: 'danger/gemfile')
danger.import_dangerfile(path: 'danger/database')
danger.import_dangerfile(path: 'danger/frozen_string')
......@@ -243,7 +243,7 @@ gem 'ruby-fogbugz', '~> 0.2.1'
gem 'kubeclient', '~> 3.1.0'
# Sanitize user input
gem 'sanitize', '~> 4.6.5'
gem 'sanitize', '~> 4.6'
gem 'babosa', '~> 1.0.2'
# Sanitizes SVG input
......
......@@ -543,7 +543,7 @@ GEM
net-ntp (2.1.3)
net-ssh (5.0.1)
netrc (0.11.0)
nokogiri (1.8.3)
nokogiri (1.8.4)
mini_portile2 (~> 2.3.0)
nokogumbo (1.5.0)
nokogiri
......@@ -837,7 +837,7 @@ GEM
et-orbi (~> 1.0)
rugged (0.27.2)
safe_yaml (1.0.4)
sanitize (4.6.5)
sanitize (4.6.6)
crass (~> 1.0.2)
nokogiri (>= 1.4.4)
nokogumbo (~> 1.4)
......@@ -1194,7 +1194,7 @@ DEPENDENCIES
ruby_parser (~> 3.8)
rufus-scheduler (~> 3.4)
rugged (~> 0.27)
sanitize (~> 4.6.5)
sanitize (~> 4.6)
sass-rails (~> 5.0.6)
scss_lint (~> 0.56.0)
seed-fu (~> 2.3.7)
......
......@@ -1205,7 +1205,7 @@ DEPENDENCIES
ruby_parser (~> 3.8)
rufus-scheduler (~> 3.4)
rugged (~> 0.27)
sanitize (~> 4.6.5)
sanitize (~> 4.6)
sass-rails (~> 5.0.6)
scss_lint (~> 0.56.0)
seed-fu (~> 2.3.7)
......
......@@ -562,6 +562,26 @@ export const addSelectOnFocusBehaviour = (selector = '.js-select-on-focus') => {
});
};
/**
* Method to round of values with decimal places
* with provided precision.
*
* Taken from https://stackoverflow.com/a/7343013/414749
*
* Eg; roundOffFloat(3.141592, 3) = 3.142
*
* Refer to spec/javascripts/lib/utils/common_utils_spec.js for
* more supported examples.
*
* @param {Float} number
* @param {Number} precision
*/
export const roundOffFloat = (number, precision = 0) => {
// eslint-disable-next-line no-restricted-properties
const multiplier = Math.pow(10, precision);
return Math.round(number * multiplier) / multiplier;
};
window.gl = window.gl || {};
window.gl.utils = {
...(window.gl.utils || {}),
......
......@@ -15,7 +15,7 @@ document.addEventListener('DOMContentLoaded', () => {
const notesDataset = document.getElementById('js-vue-notes').dataset;
const parsedUserData = JSON.parse(notesDataset.currentUserData);
const noteableData = JSON.parse(notesDataset.noteableData);
const { markdownVersion } = notesDataset;
const markdownVersion = parseInt(notesDataset.markdownVersion, 10);
let currentUserData = {};
noteableData.noteableType = notesDataset.noteableType;
......
<script>
import { roundOffFloat } from '~/lib/utils/common_utils';
import tooltip from '~/vue_shared/directives/tooltip';
export default {
......@@ -70,7 +71,7 @@ export default {
},
methods: {
getPercent(count) {
return Math.ceil((count / this.totalCount) * 100);
return roundOffFloat((count / this.totalCount) * 100, 1);
},
barStyle(percent) {
return `width: ${percent}%;`;
......
......@@ -10,7 +10,7 @@
.status-neutral,
.status-red, {
height: 100%;
min-width: 30px;
min-width: 40px;
padding: 0 5px;
font-size: $tooltip-font-size;
font-weight: normal;
......
# frozen_string_literal: true
class AnalyticsBuildEntity < Grape::Entity
include RequestAwareEntity
include EntityDateHelper
......
# frozen_string_literal: true
class AnalyticsBuildSerializer < BaseSerializer
entity AnalyticsBuildEntity
end
# frozen_string_literal: true
class AnalyticsCommitEntity < CommitEntity
include EntityDateHelper
......
# frozen_string_literal: true
class AnalyticsCommitSerializer < BaseSerializer
entity AnalyticsCommitEntity
end
# frozen_string_literal: true
class AnalyticsGenericSerializer < BaseSerializer
def represent(resource, opts = {})
resource.symbolize_keys!
......
# frozen_string_literal: true
class AnalyticsIssueEntity < Grape::Entity
include RequestAwareEntity
include EntityDateHelper
......
# frozen_string_literal: true
class AnalyticsIssueSerializer < AnalyticsGenericSerializer
entity AnalyticsIssueEntity
end
# frozen_string_literal: true
class AnalyticsMergeRequestEntity < AnalyticsIssueEntity
expose :state
......
# frozen_string_literal: true
class AnalyticsMergeRequestSerializer < AnalyticsGenericSerializer
entity AnalyticsMergeRequestEntity
end
# frozen_string_literal: true
class AnalyticsStageEntity < Grape::Entity
include EntityDateHelper
......
# frozen_string_literal: true
class AnalyticsStageSerializer < BaseSerializer
entity AnalyticsStageEntity
end
# frozen_string_literal: true
class AnalyticsSummaryEntity < Grape::Entity
expose :value, safe: true
expose :title
......
# frozen_string_literal: true
class AnalyticsSummarySerializer < BaseSerializer
entity AnalyticsSummaryEntity
end
# frozen_string_literal: true
class AwardEmojiEntity < Grape::Entity
expose :name
expose :user, using: API::Entities::UserSafe
......
# frozen_string_literal: true
class BaseSerializer
attr_reader :params
......
# frozen_string_literal: true
class BlobEntity < Grape::Entity
include RequestAwareEntity
......
# frozen_string_literal: true
class BuildActionEntity < Grape::Entity
include RequestAwareEntity
......
# frozen_string_literal: true
class BuildArtifactEntity < Grape::Entity
include RequestAwareEntity
......
# frozen_string_literal: true
class BuildDetailsEntity < JobEntity
expose :coverage, :erased_at, :duration
expose :tag_list, as: :tags
......
# frozen_string_literal: true
class BuildMetadataEntity < Grape::Entity
expose :timeout_human_readable
expose :timeout_source do |metadata|
......
# frozen_string_literal: true
class BuildSerializer < BaseSerializer
entity JobEntity
......
# frozen_string_literal: true
class ClusterApplicationEntity < Grape::Entity
expose :name
expose :status_name, as: :status
......
# frozen_string_literal: true
class ClusterEntity < Grape::Entity
include RequestAwareEntity
......
# frozen_string_literal: true
class ClusterSerializer < BaseSerializer
entity ClusterEntity
......
# frozen_string_literal: true
class CohortActivityMonthEntity < Grape::Entity
include ActionView::Helpers::NumberHelper
......
# frozen_string_literal: true
class CohortEntity < Grape::Entity
include ActionView::Helpers::NumberHelper
......
# frozen_string_literal: true
class CohortsEntity < Grape::Entity
expose :months_included
expose :cohorts, using: CohortEntity
......
# frozen_string_literal: true
class CohortsSerializer < AnalyticsGenericSerializer
entity CohortsEntity
end
# frozen_string_literal: true
class CommitEntity < API::Entities::Commit
include RequestAwareEntity
......
# frozen_string_literal: true
module WithPagination
attr_accessor :paginator
......
# frozen_string_literal: true
class ContainerRepositoriesSerializer < BaseSerializer
entity ContainerRepositoryEntity
end
# frozen_string_literal: true
class ContainerRepositoryEntity < Grape::Entity
include RequestAwareEntity
......
# frozen_string_literal: true
class ContainerTagEntity < Grape::Entity
include RequestAwareEntity
......
# frozen_string_literal: true
class ContainerTagsSerializer < BaseSerializer
entity ContainerTagEntity
......
# frozen_string_literal: true
class DeployKeyEntity < Grape::Entity
expose :id
expose :user_id
......
# frozen_string_literal: true
class DeployKeySerializer < BaseSerializer
entity DeployKeyEntity
end
# frozen_string_literal: true
class DeployKeysProjectEntity < Grape::Entity
expose :can_push
expose :project, using: ProjectEntity
......
# frozen_string_literal: true
class DeploymentEntity < Grape::Entity
include RequestAwareEntity
......
# frozen_string_literal: true
class DeploymentSerializer < BaseSerializer
entity DeploymentEntity
......
# frozen_string_literal: true
class DiffFileEntity < Grape::Entity
include RequestAwareEntity
include BlobHelper
......
# frozen_string_literal: true
class DiffsEntity < Grape::Entity
include DiffHelper
include RequestAwareEntity
......
# frozen_string_literal: true
class DiffsSerializer < BaseSerializer
entity DiffsEntity
end
# frozen_string_literal: true
class DiscussionEntity < Grape::Entity
include RequestAwareEntity
include NotesHelper
......
# frozen_string_literal: true
class DiscussionSerializer < BaseSerializer
entity DiscussionEntity
end
# frozen_string_literal: true
module EntityDateHelper
include ActionView::Helpers::DateHelper
include ActionView::Helpers::TagHelper
......@@ -50,15 +52,20 @@ module EntityDateHelper
elsif entity.due_date
is_upcoming = (entity.due_date - Date.today).to_i > 0
time_ago = time_ago_in_words(entity.due_date)
content = time_ago.gsub(/\d+/) { |match| "<strong>#{match}</strong>" }
content.slice!("about ")
content << " " + (is_upcoming ? _("remaining") : _("ago"))
content.html_safe
# https://gitlab.com/gitlab-org/gitlab-ce/issues/49440
#
# Need to improve the i18n here and do a full translation
# of the string instead of piecewise translations.
content = time_ago
.gsub(/\d+/) { |match| "<strong>#{match}</strong>" }
.remove("about ")
remaining_or_ago = is_upcoming ? _("remaining") : _("ago")
"#{content} #{remaining_or_ago}".html_safe
elsif entity.start_date && entity.start_date.past?
days = entity.elapsed_days
content = content_tag(:strong, days)
content << " #{'day'.pluralize(days)} elapsed"
content.html_safe
days = entity.elapsed_days
"#{content_tag(:strong, days)} #{'day'.pluralize(days)} elapsed".html_safe
end
end
end
# frozen_string_literal: true
class EntityRequest
# We use EntityRequest object to collect parameters and variables
# from the controller. Because options that are being passed to the entity
......
# frozen_string_literal: true
class EnvironmentEntity < Grape::Entity
include RequestAwareEntity
......
# frozen_string_literal: true
class EnvironmentSerializer < BaseSerializer
include WithPagination
......
# frozen_string_literal: true
class GroupChildEntity < Grape::Entity
include ActionView::Helpers::NumberHelper
include RequestAwareEntity
......
# frozen_string_literal: true
class GroupChildSerializer < BaseSerializer
include WithPagination
......
# frozen_string_literal: true
class GroupEntity < Grape::Entity
include ActionView::Helpers::NumberHelper
include RequestAwareEntity
......
# frozen_string_literal: true
class GroupSerializer < BaseSerializer
include WithPagination
......
# frozen_string_literal: true
class GroupVariableEntity < Grape::Entity
expose :id
expose :key
......
# frozen_string_literal: true
class GroupVariableSerializer < BaseSerializer
entity GroupVariableEntity
end
# frozen_string_literal: true
class IssuableEntity < Grape::Entity
include RequestAwareEntity
......
# frozen_string_literal: true
class IssuableSidebarEntity < Grape::Entity
include TimeTrackableEntity
include RequestAwareEntity
......
# frozen_string_literal: true
class IssueEntity < IssuableEntity
include TimeTrackableEntity
......
# frozen_string_literal: true
class IssueSerializer < BaseSerializer
# This overrided method takes care of which entity should be used
# to serialize the `issue` based on `basic` key in `opts` param.
......
# frozen_string_literal: true
class IssueSidebarEntity < IssuableSidebarEntity
prepend ::EE::IssueSidebarEntity
......
# frozen_string_literal: true
class JobEntity < Grape::Entity
include RequestAwareEntity
......
# frozen_string_literal: true
class JobGroupEntity < Grape::Entity
include RequestAwareEntity
......
# frozen_string_literal: true
class LabelEntity < Grape::Entity
expose :id, if: ->(label, _) { !label.is_a?(GlobalLabel) }
......
# frozen_string_literal: true
class LabelSerializer < BaseSerializer
entity LabelEntity
......
# frozen_string_literal: true
class LfsFileLockEntity < Grape::Entity
root 'locks', 'lock'
......
# frozen_string_literal: true
class LfsFileLockSerializer < BaseSerializer
entity LfsFileLockEntity
end
# frozen_string_literal: true
class MergeRequestBasicEntity < IssuableSidebarEntity
expose :assignee_id
expose :merge_status
......
# frozen_string_literal: true
class MergeRequestBasicSerializer < BaseSerializer
entity MergeRequestBasicEntity
end
# frozen_string_literal: true
class MergeRequestCreateEntity < Grape::Entity
expose :iid
......
# frozen_string_literal: true
class MergeRequestCreateSerializer < BaseSerializer
entity MergeRequestCreateEntity
end
# frozen_string_literal: true
class MergeRequestDiffEntity < Grape::Entity
include Gitlab::Routing
include GitHelper
......
# frozen_string_literal: true
class MergeRequestMetricsEntity < Grape::Entity
expose :latest_closed_at, as: :closed_at
expose :merged_at
......
# frozen_string_literal: true
class MergeRequestSerializer < BaseSerializer
# This overrided method takes care of which entity should be used
# to serialize the `merge_request` based on `serializer` key in `opts` param.
......
# frozen_string_literal: true
class MergeRequestUserEntity < UserEntity
include RequestAwareEntity
include BlobHelper
......
# frozen_string_literal: true
class MergeRequestWidgetEntity < IssuableEntity
prepend ::EE::MergeRequestWidgetEntity
......
# frozen_string_literal: true
class NoteAttachmentEntity < Grape::Entity
expose :url
expose :filename
......
# frozen_string_literal: true
class NoteEntity < API::Entities::Note
include RequestAwareEntity
include NotesHelper
......
# frozen_string_literal: true
class NoteUserEntity < UserEntity
unexpose :web_url
end
# frozen_string_literal: true
class PipelineDetailsEntity < PipelineEntity
expose :details do
expose :ordered_stages, as: :stages, using: StageEntity
......
# frozen_string_literal: true
class PipelineEntity < Grape::Entity
include RequestAwareEntity
......
# frozen_string_literal: true
class PipelineSerializer < BaseSerializer
include WithPagination
entity PipelineDetailsEntity
......
# frozen_string_literal: true
class ProjectEntity < Grape::Entity
include RequestAwareEntity
......
# frozen_string_literal: true
class ProjectMirrorEntity < Grape::Entity
prepend ::EE::ProjectMirrorEntity
......
# frozen_string_literal: true
class ProjectNoteEntity < NoteEntity
expose :human_access do |note|
note.project.team.human_max_access(note.author_id)
......
# frozen_string_literal: true
class ProjectNoteSerializer < BaseSerializer
entity ProjectNoteEntity
end
# frozen_string_literal: true
class ProjectSerializer < BaseSerializer
entity ProjectEntity
end
# frozen_string_literal: true
module RequestAwareEntity
extend ActiveSupport::Concern
......
# frozen_string_literal: true
class RunnerEntity < Grape::Entity
include RequestAwareEntity
......
# frozen_string_literal: true
class StageEntity < Grape::Entity
include RequestAwareEntity
......
# frozen_string_literal: true
class StageSerializer < BaseSerializer
include WithPagination
......
# frozen_string_literal: true
class StatusEntity < Grape::Entity
include RequestAwareEntity
......
# frozen_string_literal: true
class SubmoduleEntity < Grape::Entity
include RequestAwareEntity
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment