diff options
author | Felipe Artur <felipefac@gmail.com> | 2018-07-17 21:17:07 -0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2018-07-17 21:17:07 -0300 |
commit | c97d822c1b76be57d5b988940311f8a3238b6a5e (patch) | |
tree | e5ff2ecb49c9ed29397c4266a2ccbae9e6540464 | |
parent | 5238eb5eb71396beaade7d0a80f180269bcd21a5 (diff) | |
parent | 07f4b095f8de2a3968705f103701c5075669b2a5 (diff) | |
download | gitlab-ce-c97d822c1b76be57d5b988940311f8a3238b6a5e.tar.gz |
Merge branch '11-1-stable-prepare-rc13' into 11-1-stable
38 files changed, 417 insertions, 225 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 610a5ecba6d..70f5351a916 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -327,7 +327,7 @@ cloud-native-image: cache: {} script: - gem install gitlab --no-ri --no-rdoc - - ./scripts/trigger-build cng + - BUILD_TRIGGER_TOKEN=$CI_JOB_TOKEN scripts/trigger-build cng only: - tags@gitlab-org/gitlab-ce - tags@gitlab-org/gitlab-ee diff --git a/app/assets/javascripts/diffs/components/app.vue b/app/assets/javascripts/diffs/components/app.vue index 1d1415fe6ca..7cc4e6a2c3a 100644 --- a/app/assets/javascripts/diffs/components/app.vue +++ b/app/assets/javascripts/diffs/components/app.vue @@ -85,6 +85,9 @@ export default { } return __('Show latest version'); }, + canCurrentUserFork() { + return this.currentUser.canFork === true && this.currentUser.canCreateMergeRequest; + }, }, watch: { diffViewType() { @@ -192,7 +195,7 @@ export default { v-for="file in diffFiles" :key="file.newPath" :file="file" - :current-user="currentUser" + :can-current-user-fork="canCurrentUserFork" /> </div> <no-changes v-else /> diff --git a/app/assets/javascripts/diffs/components/diff_file.vue b/app/assets/javascripts/diffs/components/diff_file.vue index 944084f05c9..7e7058d8d08 100644 --- a/app/assets/javascripts/diffs/components/diff_file.vue +++ b/app/assets/javascripts/diffs/components/diff_file.vue @@ -18,8 +18,8 @@ export default { type: Object, required: true, }, - currentUser: { - type: Object, + canCurrentUserFork: { + type: Boolean, required: true, }, }, @@ -87,7 +87,7 @@ export default { class="diff-file file-holder" > <diff-file-header - :current-user="currentUser" + :can-current-user-fork="canCurrentUserFork" :diff-file="file" :collapsible="true" :expanded="!isCollapsed" diff --git a/app/assets/javascripts/diffs/components/diff_file_header.vue b/app/assets/javascripts/diffs/components/diff_file_header.vue index c5abd0a9568..c494d3bcd3e 100644 --- a/app/assets/javascripts/diffs/components/diff_file_header.vue +++ b/app/assets/javascripts/diffs/components/diff_file_header.vue @@ -39,8 +39,8 @@ export default { required: false, default: true, }, - currentUser: { - type: Object, + canCurrentUserFork: { + type: Boolean, required: true, }, }, @@ -228,7 +228,7 @@ export default { <edit-button v-if="!diffFile.deletedFile" - :current-user="currentUser" + :can-current-user-fork="canCurrentUserFork" :edit-path="diffFile.editPath" :can-modify-blob="diffFile.canModifyBlob" @showForkMessage="showForkMessage" diff --git a/app/assets/javascripts/diffs/components/diff_line_note_form.vue b/app/assets/javascripts/diffs/components/diff_line_note_form.vue index db380e68bd1..32f9516d332 100644 --- a/app/assets/javascripts/diffs/components/diff_line_note_form.vue +++ b/app/assets/javascripts/diffs/components/diff_line_note_form.vue @@ -13,12 +13,8 @@ export default { noteForm, }, props: { - diffFile: { - type: Object, - required: true, - }, - diffLines: { - type: Array, + diffFileHash: { + type: String, required: true, }, line: { @@ -40,6 +36,7 @@ export default { noteableData: state => state.notes.noteableData, diffViewType: state => state.diffs.diffViewType, }), + ...mapGetters('diffs', ['getDiffFileByHash']), ...mapGetters(['isLoggedIn', 'noteableType', 'getNoteableData', 'getNotesDataByProp']), }, mounted() { @@ -68,13 +65,14 @@ export default { }); }, handleSaveNote(note) { + const selectedDiffFile = this.getDiffFileByHash(this.diffFileHash); const postData = getNoteFormData({ note, noteableData: this.noteableData, noteableType: this.noteableType, noteTargetLine: this.noteTargetLine, diffViewType: this.diffViewType, - diffFile: this.diffFile, + diffFile: selectedDiffFile, linePosition: this.position, }); diff --git a/app/assets/javascripts/diffs/components/diff_table_cell.vue b/app/assets/javascripts/diffs/components/diff_table_cell.vue index bd02b45a63c..5962f30d9bb 100644 --- a/app/assets/javascripts/diffs/components/diff_table_cell.vue +++ b/app/assets/javascripts/diffs/components/diff_table_cell.vue @@ -24,8 +24,12 @@ export default { type: Object, required: true, }, - diffFile: { - type: Object, + fileHash: { + type: String, + required: true, + }, + contextLinesPath: { + type: String, required: true, }, diffViewType: { @@ -120,14 +124,14 @@ export default { :class="classNameMap" > <diff-line-gutter-content - :file-hash="diffFile.fileHash" + :file-hash="fileHash" + :context-lines-path="contextLinesPath" :line-type="normalizedLine.type" :line-code="normalizedLine.lineCode" :line-position="linePosition" :line-number="lineNumber" :meta-data="normalizedLine.metaData" :show-comment-button="showCommentButton" - :context-lines-path="diffFile.contextLinesPath" :is-bottom="isBottom" :is-match-line="isMatchLine" :is-context-line="isContentLine" diff --git a/app/assets/javascripts/diffs/components/edit_button.vue b/app/assets/javascripts/diffs/components/edit_button.vue index ebf90631d76..2fb85ca2f07 100644 --- a/app/assets/javascripts/diffs/components/edit_button.vue +++ b/app/assets/javascripts/diffs/components/edit_button.vue @@ -5,8 +5,8 @@ export default { type: String, required: true, }, - currentUser: { - type: Object, + canCurrentUserFork: { + type: Boolean, required: true, }, canModifyBlob: { @@ -17,12 +17,12 @@ export default { }, methods: { handleEditClick(evt) { - if (!this.currentUser || this.canModifyBlob) { + if (!this.canCurrentUserFork || this.canModifyBlob) { // if we can Edit, do default Edit button behavior return; } - if (this.currentUser.canFork && this.currentUser.canCreateMergeRequest) { + if (this.canCurrentUserFork) { evt.preventDefault(); this.$emit('showForkMessage'); } diff --git a/app/assets/javascripts/diffs/components/inline_diff_comment_row.vue b/app/assets/javascripts/diffs/components/inline_diff_comment_row.vue index 1e8f2eecd76..ca265dd892c 100644 --- a/app/assets/javascripts/diffs/components/inline_diff_comment_row.vue +++ b/app/assets/javascripts/diffs/components/inline_diff_comment_row.vue @@ -13,12 +13,8 @@ export default { type: Object, required: true, }, - diffFile: { - type: Object, - required: true, - }, - diffLines: { - type: Array, + diffFileHash: { + type: String, required: true, }, lineIndex: { @@ -58,10 +54,9 @@ export default { /> <diff-line-note-form v-if="diffLineCommentForms[line.lineCode]" - :diff-file="diffFile" - :diff-lines="diffLines" + :diff-file-hash="diffFileHash" :line="line" - :note-target-line="diffLines[lineIndex]" + :note-target-line="line" /> </div> </td> diff --git a/app/assets/javascripts/diffs/components/inline_diff_table_row.vue b/app/assets/javascripts/diffs/components/inline_diff_table_row.vue index 8e4715c9862..0197a510ef1 100644 --- a/app/assets/javascripts/diffs/components/inline_diff_table_row.vue +++ b/app/assets/javascripts/diffs/components/inline_diff_table_row.vue @@ -16,8 +16,12 @@ export default { DiffTableCell, }, props: { - diffFile: { - type: Object, + fileHash: { + type: String, + required: true, + }, + contextLinesPath: { + type: String, required: true, }, line: { @@ -50,7 +54,7 @@ export default { inlineRowId() { const { lineCode, oldLine, newLine } = this.line; - return lineCode || `${this.diffFile.fileHash}_${oldLine}_${newLine}`; + return lineCode || `${this.fileHash}_${oldLine}_${newLine}`; }, }, created() { @@ -78,7 +82,8 @@ export default { @mouseout="handleMouseMove" > <diff-table-cell - :diff-file="diffFile" + :file-hash="fileHash" + :context-lines-path="contextLinesPath" :line="line" :line-type="oldLineType" :is-bottom="isBottom" @@ -87,7 +92,8 @@ export default { class="diff-line-num old_line" /> <diff-table-cell - :diff-file="diffFile" + :file-hash="fileHash" + :context-lines-path="contextLinesPath" :line="line" :line-type="newLineType" :is-bottom="isBottom" diff --git a/app/assets/javascripts/diffs/components/inline_diff_view.vue b/app/assets/javascripts/diffs/components/inline_diff_view.vue index 9c1359f7c89..9fd19b74cd7 100644 --- a/app/assets/javascripts/diffs/components/inline_diff_view.vue +++ b/app/assets/javascripts/diffs/components/inline_diff_view.vue @@ -60,15 +60,15 @@ export default { v-for="(line, index) in normalizedDiffLines" > <inline-diff-table-row - :diff-file="diffFile" + :file-hash="diffFile.fileHash" + :context-lines-path="diffFile.contextLinesPath" :line="line" :is-bottom="index + 1 === diffLinesLength" :key="line.lineCode" /> <inline-diff-comment-row v-if="shouldRenderCommentRow(line)" - :diff-file="diffFile" - :diff-lines="normalizedDiffLines" + :diff-file-hash="diffFile.fileHash" :line="line" :line-index="index" :key="index" diff --git a/app/assets/javascripts/diffs/components/parallel_diff_comment_row.vue b/app/assets/javascripts/diffs/components/parallel_diff_comment_row.vue index 1e20792b647..cc5248c25d9 100644 --- a/app/assets/javascripts/diffs/components/parallel_diff_comment_row.vue +++ b/app/assets/javascripts/diffs/components/parallel_diff_comment_row.vue @@ -13,12 +13,8 @@ export default { type: Object, required: true, }, - diffFile: { - type: Object, - required: true, - }, - diffLines: { - type: Array, + diffFileHash: { + type: String, required: true, }, lineIndex: { @@ -91,10 +87,9 @@ export default { <diff-line-note-form v-if="diffLineCommentForms[leftLineCode] && diffLineCommentForms[leftLineCode]" - :diff-file="diffFile" - :diff-lines="diffLines" + :diff-file-hash="diffFileHash" :line="line.left" - :note-target-line="diffLines[lineIndex].left" + :note-target-line="line.left" position="left" /> </td> @@ -112,10 +107,9 @@ export default { <diff-line-note-form v-if="diffLineCommentForms[rightLineCode] && diffLineCommentForms[rightLineCode] && line.right.type" - :diff-file="diffFile" - :diff-lines="diffLines" + :diff-file-hash="diffFileHash" :line="line.right" - :note-target-line="diffLines[lineIndex].right" + :note-target-line="line.right" position="right" /> </td> diff --git a/app/assets/javascripts/diffs/components/parallel_diff_table_row.vue b/app/assets/javascripts/diffs/components/parallel_diff_table_row.vue index b76fc63205b..ee5bb4d8d05 100644 --- a/app/assets/javascripts/diffs/components/parallel_diff_table_row.vue +++ b/app/assets/javascripts/diffs/components/parallel_diff_table_row.vue @@ -19,8 +19,12 @@ export default { DiffTableCell, }, props: { - diffFile: { - type: Object, + fileHash: { + type: String, + required: true, + }, + contextLinesPath: { + type: String, required: true, }, line: { @@ -103,7 +107,8 @@ export default { @mouseout="handleMouseMove" > <diff-table-cell - :diff-file="diffFile" + :file-hash="fileHash" + :context-lines-path="contextLinesPath" :line="line" :line-type="oldLineType" :line-position="linePositionLeft" @@ -123,7 +128,8 @@ export default { > </td> <diff-table-cell - :diff-file="diffFile" + :file-hash="fileHash" + :context-lines-path="contextLinesPath" :line="line" :line-type="newLineType" :line-position="linePositionRight" diff --git a/app/assets/javascripts/diffs/components/parallel_diff_view.vue b/app/assets/javascripts/diffs/components/parallel_diff_view.vue index 216865474a6..32528c9e7ab 100644 --- a/app/assets/javascripts/diffs/components/parallel_diff_view.vue +++ b/app/assets/javascripts/diffs/components/parallel_diff_view.vue @@ -93,17 +93,17 @@ export default { v-for="(line, index) in parallelDiffLines" > <parallel-diff-table-row - :diff-file="diffFile" + :file-hash="diffFile.fileHash" + :context-lines-path="diffFile.contextLinesPath" :line="line" :is-bottom="index + 1 === diffLinesLength" :key="index" /> <parallel-diff-comment-row v-if="shouldRenderCommentRow(line)" - :key="line.left.lineCode || line.right.lineCode" + :key="`dcr-${index}`" :line="line" - :diff-file="diffFile" - :diff-lines="parallelDiffLines" + :diff-file-hash="diffFile.fileHash" :line-index="index" /> </template> diff --git a/app/assets/javascripts/diffs/store/getters.js b/app/assets/javascripts/diffs/store/getters.js index f89acb73ed8..855de79adf8 100644 --- a/app/assets/javascripts/diffs/store/getters.js +++ b/app/assets/javascripts/diffs/store/getters.js @@ -57,4 +57,8 @@ export const getDiffFileDiscussions = (state, getters, rootState, rootGetters) = ) || []; // prevent babel-plugin-rewire from generating an invalid default during karma∂ tests +export const getDiffFileByHash = state => fileHash => + state.diffFiles.find(file => file.fileHash === fileHash); + +// prevent babel-plugin-rewire from generating an invalid default during karma tests export default () => {}; diff --git a/app/assets/javascripts/monitoring/stores/monitoring_store.js b/app/assets/javascripts/monitoring/stores/monitoring_store.js index 748b8cb6e6e..176f7d9eef2 100644 --- a/app/assets/javascripts/monitoring/stores/monitoring_store.js +++ b/app/assets/javascripts/monitoring/stores/monitoring_store.js @@ -1,7 +1,10 @@ import _ from 'underscore'; function sortMetrics(metrics) { - return _.chain(metrics).sortBy('title').sortBy('weight').value(); + return _.chain(metrics) + .sortBy('title') + .sortBy('weight') + .value(); } function normalizeMetrics(metrics) { @@ -39,7 +42,9 @@ export default class MonitoringStore { } storeEnvironmentsData(environmentsData = []) { - this.environmentsData = environmentsData; + this.environmentsData = environmentsData.filter( + environment => !!environment.latest.last_deployment, + ); } getMetricsCount() { diff --git a/app/assets/javascripts/notes/components/diff_with_note.vue b/app/assets/javascripts/notes/components/diff_with_note.vue index 9c2908c477e..27ff7dea909 100644 --- a/app/assets/javascripts/notes/components/diff_with_note.vue +++ b/app/assets/javascripts/notes/components/diff_with_note.vue @@ -1,94 +1,90 @@ <script> - import { mapState, mapActions } from 'vuex'; - import imageDiffHelper from '~/image_diff/helpers/index'; - import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; - import DiffFileHeader from '~/diffs/components/diff_file_header.vue'; - import SkeletonLoadingContainer from '~/vue_shared/components/skeleton_loading_container.vue'; - import { trimFirstCharOfLineContent } from '~/diffs/store/utils'; +import { mapState, mapActions } from 'vuex'; +import imageDiffHelper from '~/image_diff/helpers/index'; +import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; +import DiffFileHeader from '~/diffs/components/diff_file_header.vue'; +import SkeletonLoadingContainer from '~/vue_shared/components/skeleton_loading_container.vue'; +import { trimFirstCharOfLineContent } from '~/diffs/store/utils'; - export default { - components: { - DiffFileHeader, - SkeletonLoadingContainer, +export default { + components: { + DiffFileHeader, + SkeletonLoadingContainer, + }, + props: { + discussion: { + type: Object, + required: true, }, - props: { - discussion: { - type: Object, - required: true, - }, + }, + data() { + return { + error: false, + }; + }, + computed: { + ...mapState({ + noteableData: state => state.notes.noteableData, + }), + hasTruncatedDiffLines() { + return this.discussion.truncatedDiffLines && this.discussion.truncatedDiffLines.length !== 0; }, - data() { - return { - error: false, - }; + isDiscussionsExpanded() { + return true; // TODO: @fatihacet - Fix this. }, - computed: { - ...mapState({ - noteableData: state => state.notes.noteableData, - }), - hasTruncatedDiffLines() { - return this.discussion.truncatedDiffLines && - this.discussion.truncatedDiffLines.length !== 0; - }, - isDiscussionsExpanded() { - return true; // TODO: @fatihacet - Fix this. - }, - isCollapsed() { - return this.diffFile.collapsed || false; - }, - isImageDiff() { - return !this.diffFile.text; - }, - diffFileClass() { - const { text } = this.diffFile; - return text ? 'text-file' : 'js-image-file'; - }, - diffFile() { - return convertObjectPropsToCamelCase(this.discussion.diffFile, { deep: true }); - }, - imageDiffHtml() { - return this.discussion.imageDiffHtml; - }, - currentUser() { - return this.noteableData.current_user; - }, - userColorScheme() { - return window.gon.user_color_scheme; - }, - normalizedDiffLines() { - if (this.discussion.truncatedDiffLines) { - return this.discussion.truncatedDiffLines.map(line => - trimFirstCharOfLineContent(convertObjectPropsToCamelCase(line)), - ); - } - - return []; - }, + isCollapsed() { + return this.diffFile.collapsed || false; + }, + isImageDiff() { + return !this.diffFile.text; + }, + diffFileClass() { + const { text } = this.diffFile; + return text ? 'text-file' : 'js-image-file'; + }, + diffFile() { + return convertObjectPropsToCamelCase(this.discussion.diffFile, { deep: true }); }, - mounted() { - if (this.isImageDiff) { - const canCreateNote = false; - const renderCommentBadge = true; - imageDiffHelper.initImageDiff(this.$refs.fileHolder, canCreateNote, renderCommentBadge); - } else if (!this.hasTruncatedDiffLines) { - this.fetchDiff(); + imageDiffHtml() { + return this.discussion.imageDiffHtml; + }, + userColorScheme() { + return window.gon.user_color_scheme; + }, + normalizedDiffLines() { + if (this.discussion.truncatedDiffLines) { + return this.discussion.truncatedDiffLines.map(line => + trimFirstCharOfLineContent(convertObjectPropsToCamelCase(line)), + ); } + + return []; + }, + }, + mounted() { + if (this.isImageDiff) { + const canCreateNote = false; + const renderCommentBadge = true; + imageDiffHelper.initImageDiff(this.$refs.fileHolder, canCreateNote, renderCommentBadge); + } else if (!this.hasTruncatedDiffLines) { + this.fetchDiff(); + } + }, + methods: { + ...mapActions(['fetchDiscussionDiffLines']), + rowTag(html) { + return html.outerHTML ? 'tr' : 'template'; }, - methods: { - ...mapActions(['fetchDiscussionDiffLines']), - rowTag(html) { - return html.outerHTML ? 'tr' : 'template'; - }, - fetchDiff() { - this.error = false; - this.fetchDiscussionDiffLines(this.discussion) - .then(this.highlight) - .catch(() => { - this.error = true; - }); - }, + fetchDiff() { + this.error = false; + this.fetchDiscussionDiffLines(this.discussion) + .then(this.highlight) + .catch(() => { + this.error = true; + }); }, - }; + }, +}; </script> <template> @@ -99,7 +95,7 @@ > <diff-file-header :diff-file="diffFile" - :current-user="currentUser" + :can-current-user-fork="false" :discussions-expanded="isDiscussionsExpanded" :expanded="!isCollapsed" /> diff --git a/app/assets/javascripts/pipelines/components/stage.vue b/app/assets/javascripts/pipelines/components/stage.vue index 56fdb858088..c7df69c69ed 100644 --- a/app/assets/javascripts/pipelines/components/stage.vue +++ b/app/assets/javascripts/pipelines/components/stage.vue @@ -175,6 +175,7 @@ export default { <span :aria-label="stage.title" aria-hidden="true" + class="no-pointer-events" > <icon :name="borderlessIcon" /> </span> diff --git a/app/assets/stylesheets/bootstrap_migration.scss b/app/assets/stylesheets/bootstrap_migration.scss index ded33e8b151..806612ba87a 100644 --- a/app/assets/stylesheets/bootstrap_migration.scss +++ b/app/assets/stylesheets/bootstrap_migration.scss @@ -128,7 +128,8 @@ table { border-spacing: 0; } -.tooltip { +.tooltip, +.no-pointer-events { // Fix bootstrap4 bug whereby tooltips flicker when they are hovered over their borders pointer-events: none; } diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb index ef1bf283d0c..358b896702b 100644 --- a/app/helpers/application_settings_helper.rb +++ b/app/helpers/application_settings_helper.rb @@ -251,6 +251,7 @@ module ApplicationSettingsHelper :user_oauth_applications, :version_check_enabled, :allow_local_requests_from_hooks_and_services, + :hide_third_party_offers, :enforce_terms, :terms, :mirror_available diff --git a/app/helpers/clusters_helper.rb b/app/helpers/clusters_helper.rb index c24d340d184..8fd0b6f14c6 100644 --- a/app/helpers/clusters_helper.rb +++ b/app/helpers/clusters_helper.rb @@ -4,6 +4,7 @@ module ClustersHelper end def render_gcp_signup_offer + return if Gitlab::CurrentSettings.current_application_settings.hide_third_party_offers? return unless show_gcp_signup_offer? content_tag :section, class: 'no-animate expanded' do diff --git a/app/helpers/submodule_helper.rb b/app/helpers/submodule_helper.rb index 9151543dfdc..ebfde993456 100644 --- a/app/helpers/submodule_helper.rb +++ b/app/helpers/submodule_helper.rb @@ -8,7 +8,7 @@ module SubmoduleHelper url = repository.submodule_url_for(ref, submodule_item.path) if url == '.' || url == './' - url = File.join(Gitlab.config.gitlab.url, @project.full_path) + url = File.join(Gitlab.config.gitlab.url, repository.project.full_path) end if url =~ %r{([^/:]+)/([^/]+(?:\.git)?)\Z} @@ -31,7 +31,7 @@ module SubmoduleHelper [namespace_project_path(namespace, project), namespace_project_tree_path(namespace, project, submodule_item.id)] elsif relative_self_url?(url) - relative_self_links(url, submodule_item.id) + relative_self_links(url, submodule_item.id, repository.project) elsif github_dot_com_url?(url) standard_links('github.com', namespace, project, submodule_item.id) elsif gitlab_dot_com_url?(url) @@ -73,7 +73,7 @@ module SubmoduleHelper [base, [base, '/tree/', commit].join('')] end - def relative_self_links(url, commit) + def relative_self_links(url, commit, project) url.rstrip! # Map relative links to a namespace and project # For example: @@ -85,7 +85,7 @@ module SubmoduleHelper namespace = components.pop.gsub(/^\.\.$/, '') if namespace.empty? - namespace = @project.namespace.full_path + namespace = project.namespace.full_path end begin diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index bddeb8b0352..f770b219422 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -294,6 +294,7 @@ class ApplicationSetting < ActiveRecord::Base gitaly_timeout_medium: 30, gitaly_timeout_default: 55, allow_local_requests_from_hooks_and_services: false, + hide_third_party_offers: false, mirror_available: true } end diff --git a/app/views/admin/application_settings/_third_party_offers.html.haml b/app/views/admin/application_settings/_third_party_offers.html.haml new file mode 100644 index 00000000000..c5d775d4bf5 --- /dev/null +++ b/app/views/admin/application_settings/_third_party_offers.html.haml @@ -0,0 +1,13 @@ +- application_setting = local_assigns.fetch(:application_setting) + += form_for application_setting, url: admin_application_settings_path, html: { class: 'fieldset-form' } do |f| + = form_errors(application_setting) + + %fieldset + .form-group + .form-check + = f.check_box :hide_third_party_offers, class: 'form-check-input' + = f.label :hide_third_party_offers, class: 'form-check-label' do + Do not display offers from third parties within GitLab + + = f.submit 'Save changes', class: "btn btn-success" diff --git a/app/views/admin/application_settings/show.html.haml b/app/views/admin/application_settings/show.html.haml index bd43504dd37..5cb8001a364 100644 --- a/app/views/admin/application_settings/show.html.haml +++ b/app/views/admin/application_settings/show.html.haml @@ -325,5 +325,16 @@ .settings-content = render partial: 'repository_mirrors_form' +%section.settings.as-third-party-offers.no-animate#js-third-party-offers-settings{ class: ('expanded' if expanded) } + .settings-header + %h4 + = _('Third party offers') + %button.btn.btn-default.js-settings-toggle{ type: 'button' } + = expanded ? _('Collapse') : _('Expand') + %p + = _('Control the display of third party offers.') + .settings-content + = render 'third_party_offers', application_setting: @application_setting + = render_if_exists 'admin/application_settings/pseudonymizer_settings', expanded: expanded diff --git a/changelogs/unreleased/48578-disable-gcp-free-credit-banner-at-instance-level.yml b/changelogs/unreleased/48578-disable-gcp-free-credit-banner-at-instance-level.yml new file mode 100644 index 00000000000..575767df912 --- /dev/null +++ b/changelogs/unreleased/48578-disable-gcp-free-credit-banner-at-instance-level.yml @@ -0,0 +1,5 @@ +--- +title: Add option to hide third party offers in admin application settings +merge_request: 20379 +author: +type: added diff --git a/db/migrate/20180704204006_add_hide_third_party_offers_to_application_settings.rb b/db/migrate/20180704204006_add_hide_third_party_offers_to_application_settings.rb new file mode 100644 index 00000000000..6631c5d1b6c --- /dev/null +++ b/db/migrate/20180704204006_add_hide_third_party_offers_to_application_settings.rb @@ -0,0 +1,18 @@ +class AddHideThirdPartyOffersToApplicationSettings < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_column_with_default(:application_settings, :hide_third_party_offers, + :boolean, + default: false, + allow_null: false) + end + + def down + remove_column(:application_settings, :hide_third_party_offers) + end +end diff --git a/db/schema.rb b/db/schema.rb index 79091892441..d2aa31fae30 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180702120647) do +ActiveRecord::Schema.define(version: 20180704204006) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -167,6 +167,7 @@ ActiveRecord::Schema.define(version: 20180702120647) do t.boolean "allow_local_requests_from_hooks_and_services", default: false, null: false t.boolean "enforce_terms", default: false t.boolean "mirror_available", default: true, null: false + t.boolean "hide_third_party_offers", default: false, null: false end create_table "audit_events", force: :cascade do |t| diff --git a/doc/administration/index.md b/doc/administration/index.md index 922cc45d8c4..88190b2df5f 100644 --- a/doc/administration/index.md +++ b/doc/administration/index.md @@ -45,6 +45,7 @@ Learn how to install, configure, update, and maintain your GitLab instance. - [Environment variables](environment_variables.md): Supported environment variables that can be used to override their defaults values in order to configure GitLab. - [Plugins](plugins.md): With custom plugins, GitLab administrators can introduce custom integrations without modifying GitLab's source code. - [Enforcing Terms of Service](../user/admin_area/settings/terms.md) +- [Third party offers](../user/admin_area/settings/third_party_offers.md) #### Customizing GitLab's appearance diff --git a/doc/user/admin_area/settings/third_party_offers.md b/doc/user/admin_area/settings/third_party_offers.md new file mode 100644 index 00000000000..177251b52b9 --- /dev/null +++ b/doc/user/admin_area/settings/third_party_offers.md @@ -0,0 +1,6 @@ +# Third party offers + +> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/20379) +> in [GitLab Core](https://about.gitlab.com/pricing/) 11.1 + +The display of third party offers can be controlled in the Admin Area -> Settings page. diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 1959ee27e40..f2e4eda576f 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -8,8 +8,8 @@ msgid "" msgstr "" "Project-Id-Version: gitlab 1.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-07-01 21:24+1000\n" -"PO-Revision-Date: 2018-07-01 21:24+1000\n" +"POT-Creation-Date: 2018-07-10 08:56+0200\n" +"PO-Revision-Date: 2018-07-10 08:56+0200\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" "Language: \n" @@ -369,9 +369,18 @@ msgstr "" msgid "Alternatively, you can use a %{personal_access_token_link}. When you create your Personal Access Token, you will need to select the <code>repo</code> scope, so we can display a list of your public and private repositories which are available to import." msgstr "" +msgid "An error accured whilst committing your changes." +msgstr "" + msgid "An error occured creating the new branch." msgstr "" +msgid "An error occured whilst fetching the job trace." +msgstr "" + +msgid "An error occured whilst fetching the latest pipline." +msgstr "" + msgid "An error occured whilst loading all the files." msgstr "" @@ -390,6 +399,9 @@ msgstr "" msgid "An error occured whilst loading the merge request." msgstr "" +msgid "An error occured whilst loading the pipelines jobs." +msgstr "" + msgid "An error occurred previewing the blob" msgstr "" @@ -1085,9 +1097,6 @@ msgstr "" msgid "ClusterIntegration|Add Kubernetes cluster" msgstr "" -msgid "ClusterIntegration|Add an existing Kubernetes cluster" -msgstr "" - msgid "ClusterIntegration|Advanced options on this Kubernetes cluster's integration" msgstr "" @@ -1109,9 +1118,6 @@ msgstr "" msgid "ClusterIntegration|Certificate Authority bundle (PEM format)" msgstr "" -msgid "ClusterIntegration|Choose how to set up Kubernetes cluster integration" -msgstr "" - msgid "ClusterIntegration|Choose which of your project's environments will use this Kubernetes cluster." msgstr "" @@ -1139,18 +1145,6 @@ msgstr "" msgid "ClusterIntegration|Create Kubernetes cluster" msgstr "" -msgid "ClusterIntegration|Create Kubernetes cluster on Google Kubernetes Engine" -msgstr "" - -msgid "ClusterIntegration|Create a new Kubernetes cluster on Google Kubernetes Engine right from GitLab" -msgstr "" - -msgid "ClusterIntegration|Create on Google Kubernetes Engine" -msgstr "" - -msgid "ClusterIntegration|Enter the details for an existing Kubernetes cluster" -msgstr "" - msgid "ClusterIntegration|Enter the details for your Kubernetes cluster" msgstr "" @@ -1650,6 +1644,9 @@ msgstr "" msgid "ContributorsPage|Please wait a moment, this page will automatically refresh when ready." msgstr "" +msgid "Control the display of third party offers." +msgstr "" + msgid "Copy URL to clipboard" msgstr "" @@ -1662,6 +1659,9 @@ msgstr "" msgid "Copy commit SHA to clipboard" msgstr "" +msgid "Copy file name to clipboard" +msgstr "" + msgid "Copy file path to clipboard" msgstr "" @@ -2102,9 +2102,18 @@ msgstr "" msgid "Environments|An error occurred while making the request." msgstr "" +msgid "Environments|An error occurred while stopping the environment, please try again" +msgstr "" + +msgid "Environments|Are you sure you want to stop this environment?" +msgstr "" + msgid "Environments|Commit" msgstr "" +msgid "Environments|Deploy to..." +msgstr "" + msgid "Environments|Deployment" msgstr "" @@ -2117,43 +2126,49 @@ msgstr "" msgid "Environments|Job" msgstr "" +msgid "Environments|Learn more about stopping environments" +msgstr "" + msgid "Environments|New environment" msgstr "" msgid "Environments|No deployments yet" msgstr "" -msgid "Environments|Open" +msgid "Environments|Note that this action will stop the environment, but it will %{emphasis_start}not%{emphasis_end} have an effect on any existing deployment due to no “stop environment action” being defined in the %{ci_config_link_start}.gitlab-ci.yml%{ci_config_link_end} file." +msgstr "" + +msgid "Environments|Open live environment" msgstr "" -msgid "Environments|Re-deploy" +msgid "Environments|Re-deploy to environment" msgstr "" msgid "Environments|Read more about environments" msgstr "" -msgid "Environments|Rollback" +msgid "Environments|Rollback environment" msgstr "" msgid "Environments|Show all" msgstr "" -msgid "Environments|Updated" +msgid "Environments|Stop" msgstr "" -msgid "Environments|You don't have any environments right now." +msgid "Environments|Stop environment" msgstr "" -msgid "Error Reporting and Logging" +msgid "Environments|Updated" msgstr "" -msgid "Error committing changes. Please try again." +msgid "Environments|You don't have any environments right now." msgstr "" -msgid "Error fetching contributors data." +msgid "Error Reporting and Logging" msgstr "" -msgid "Error fetching job trace" +msgid "Error fetching contributors data." msgstr "" msgid "Error fetching labels." @@ -2174,6 +2189,9 @@ msgstr "" msgid "Error loading last commit." msgstr "" +msgid "Error loading markdown preview" +msgstr "" + msgid "Error loading merge requests." msgstr "" @@ -2231,6 +2249,9 @@ msgstr "" msgid "Expand sidebar" msgstr "" +msgid "Explore groups" +msgstr "" + msgid "Explore projects" msgstr "" @@ -2446,6 +2467,27 @@ msgstr "" msgid "Groups can also be nested by creating %{subgroup_docs_link_start}subgroups%{subgroup_docs_link_end}." msgstr "" +msgid "GroupsDropdown|Frequently visited" +msgstr "" + +msgid "GroupsDropdown|Groups you visit often will appear here" +msgstr "" + +msgid "GroupsDropdown|Loading groups" +msgstr "" + +msgid "GroupsDropdown|Search your groups" +msgstr "" + +msgid "GroupsDropdown|Something went wrong on our end." +msgstr "" + +msgid "GroupsDropdown|Sorry, no groups matched your search" +msgstr "" + +msgid "GroupsDropdown|This feature requires browser localStorage support" +msgstr "" + msgid "GroupsEmptyState|A group is a collection of several projects." msgstr "" @@ -2628,7 +2670,7 @@ msgstr "" msgid "Introducing Cycle Analytics" msgstr "" -msgid "Issue Board" +msgid "Issue Boards" msgstr "" msgid "Issue events" @@ -2822,9 +2864,6 @@ msgstr "" msgid "Locked to current projects" msgstr "" -msgid "Login" -msgstr "" - msgid "Manage all notifications" msgstr "" @@ -2861,6 +2900,9 @@ msgstr "" msgid "Members" msgstr "" +msgid "Merge Request" +msgstr "" + msgid "Merge Request:" msgstr "" @@ -2903,12 +2945,42 @@ msgstr "" msgid "Messages" msgstr "" +msgid "Metrics" +msgstr "" + msgid "Metrics - Influx" msgstr "" msgid "Metrics - Prometheus" msgstr "" +msgid "Metrics|Check out the CI/CD documentation on deploying to an environment" +msgstr "" + +msgid "Metrics|Environment" +msgstr "" + +msgid "Metrics|Learn about environments" +msgstr "" + +msgid "Metrics|No deployed environments" +msgstr "" + +msgid "Metrics|There was an error fetching the environments data, please try again" +msgstr "" + +msgid "Metrics|There was an error getting deployment information." +msgstr "" + +msgid "Metrics|There was an error getting environments information." +msgstr "" + +msgid "Metrics|Unexpected deployment data response from prometheus endpoint" +msgstr "" + +msgid "Metrics|Unexpected metrics data response from prometheus endpoint" +msgstr "" + msgid "Milestone" msgstr "" @@ -2992,12 +3064,6 @@ msgid_plural "New Issues" msgstr[0] "" msgstr[1] "" -msgid "New Kubernetes Cluster" -msgstr "" - -msgid "New Kubernetes cluster" -msgstr "" - msgid "New Label" msgstr "" @@ -3214,6 +3280,9 @@ msgstr "" msgid "Only project members can comment." msgstr "" +msgid "Oops, are you sure?" +msgstr "" + msgid "Open in Xcode" msgstr "" @@ -3502,6 +3571,9 @@ msgstr "" msgid "Profiles|Account scheduled for removal." msgstr "" +msgid "Profiles|Add key" +msgstr "" + msgid "Profiles|Change username" msgstr "" @@ -3529,9 +3601,15 @@ msgstr "" msgid "Profiles|Path" msgstr "" +msgid "Profiles|This doesn't look like a public SSH key, are you sure you want to add it?" +msgstr "" + msgid "Profiles|Type your %{confirmationValue} to confirm:" msgstr "" +msgid "Profiles|Typically starts with \"ssh-rsa …\"" +msgstr "" + msgid "Profiles|Update username" msgstr "" @@ -3550,6 +3628,9 @@ msgstr "" msgid "Profiles|Your account is currently an owner in these groups:" msgstr "" +msgid "Profiles|e.g. My MacBook key" +msgstr "" + msgid "Profiles|your account" msgstr "" @@ -3637,9 +3718,6 @@ msgstr "" msgid "ProjectsDropdown|Sorry, no projects matched your search" msgstr "" -msgid "ProjectsDropdown|This feature requires browser localStorage support" -msgstr "" - msgid "PrometheusDashboard|Time" msgstr "" @@ -3745,9 +3823,6 @@ msgstr "" msgid "Quick actions can be used in the issues description and comment boxes." msgstr "" -msgid "Re-deploy" -msgstr "" - msgid "Read more" msgstr "" @@ -3882,9 +3957,6 @@ msgstr "" msgid "Reviewing (merge request !%{mergeRequestId})" msgstr "" -msgid "Rollback" -msgstr "" - msgid "Runner token" msgstr "" @@ -4525,12 +4597,6 @@ msgstr "" msgid "There are problems accessing Git storage: " msgstr "" -msgid "There was an error loading jobs" -msgstr "" - -msgid "There was an error loading latest pipeline" -msgstr "" - msgid "There was an error loading users activity calendar." msgstr "" @@ -4552,6 +4618,9 @@ msgstr "" msgid "They can be managed using the %{link}." msgstr "" +msgid "Third party offers" +msgstr "" + msgid "This GitLab instance does not provide any shared Runners yet. Instance administrators can register shared Runners in the admin area." msgstr "" @@ -4811,6 +4880,9 @@ msgstr "" msgid "Tip:" msgstr "" +msgid "Title" +msgstr "" + msgid "To GitLab" msgstr "" @@ -5179,6 +5251,9 @@ msgstr "" msgid "Yes" msgstr "" +msgid "Yes, add it" +msgstr "" + msgid "You are going to remove %{group_name}. Removed groups CANNOT be restored! Are you ABSOLUTELY sure?" msgstr "" @@ -5438,6 +5513,9 @@ msgstr "" msgid "mrWidget|Merged by" msgstr "" +msgid "mrWidget|Open in Web IDE" +msgstr "" + msgid "mrWidget|Plain diff" msgstr "" @@ -5507,9 +5585,6 @@ msgstr "" msgid "mrWidget|This project is archived, write access has been disabled" msgstr "" -msgid "mrWidget|Web IDE" -msgstr "" - msgid "mrWidget|You can merge this merge request manually using the" msgstr "" diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb index 9c6758abe86..a852ca689e7 100644 --- a/spec/features/admin/admin_settings_spec.rb +++ b/spec/features/admin/admin_settings_spec.rb @@ -272,6 +272,16 @@ describe 'Admin updates settings' do expect(Gitlab::CurrentSettings.allow_local_requests_from_hooks_and_services).to be true end + it 'Enable hiding third party offers' do + page.within('.as-third-party-offers') do + check 'Do not display offers from third parties within GitLab' + click_button 'Save changes' + end + + expect(page).to have_content "Application settings saved successfully" + expect(Gitlab::CurrentSettings.hide_third_party_offers).to be true + end + it 'Change Slack Notifications Service template settings' do first(:link, 'Service Templates').click click_link 'Slack notifications' diff --git a/spec/helpers/submodule_helper_spec.rb b/spec/helpers/submodule_helper_spec.rb index 5a2e4b34069..a64f8a11ef2 100644 --- a/spec/helpers/submodule_helper_spec.rb +++ b/spec/helpers/submodule_helper_spec.rb @@ -92,11 +92,10 @@ describe SubmoduleHelper do context 'in-repository submodule' do let(:group) { create(:group, name: "Master Project", path: "master-project") } let(:project) { create(:project, group: group) } - before do - self.instance_variable_set(:@project, project) - end it 'in-repository' do + allow(repo).to receive(:project).and_return(project) + stub_url('./') expect(submodule_links(submodule_item)).to eq(["/master-project/#{project.path}", "/master-project/#{project.path}/tree/hash"]) end @@ -167,32 +166,28 @@ describe SubmoduleHelper do let(:project) { create(:project, group: group) } let(:commit_id) { sample_commit[:id] } - before do - self.instance_variable_set(:@project, project) - end - it 'one level down' do - result = relative_self_links('../test.git', commit_id) + result = relative_self_links('../test.git', commit_id, project) expect(result).to eq(["/#{group.path}/test", "/#{group.path}/test/tree/#{commit_id}"]) end it 'with trailing whitespace' do - result = relative_self_links('../test.git ', commit_id) + result = relative_self_links('../test.git ', commit_id, project) expect(result).to eq(["/#{group.path}/test", "/#{group.path}/test/tree/#{commit_id}"]) end it 'two levels down' do - result = relative_self_links('../../test.git', commit_id) + result = relative_self_links('../../test.git', commit_id, project) expect(result).to eq(["/#{group.path}/test", "/#{group.path}/test/tree/#{commit_id}"]) end it 'one level down with namespace and repo' do - result = relative_self_links('../foobar/test.git', commit_id) + result = relative_self_links('../foobar/test.git', commit_id, project) expect(result).to eq(["/foobar/test", "/foobar/test/tree/#{commit_id}"]) end it 'two levels down with namespace and repo' do - result = relative_self_links('../foobar/baz/test.git', commit_id) + result = relative_self_links('../foobar/baz/test.git', commit_id, project) expect(result).to eq(["/baz/test", "/baz/test/tree/#{commit_id}"]) end @@ -201,7 +196,7 @@ describe SubmoduleHelper do let(:project) { create(:project, namespace: user.namespace) } it 'one level down with personal project' do - result = relative_self_links('../test.git', commit_id) + result = relative_self_links('../test.git', commit_id, project) expect(result).to eq(["/#{user.username}/test", "/#{user.username}/test/tree/#{commit_id}"]) end end diff --git a/spec/javascripts/diffs/components/diff_file_header_spec.js b/spec/javascripts/diffs/components/diff_file_header_spec.js index 0f3a95da5bf..241ff07026e 100644 --- a/spec/javascripts/diffs/components/diff_file_header_spec.js +++ b/spec/javascripts/diffs/components/diff_file_header_spec.js @@ -24,7 +24,7 @@ describe('diff_file_header', () => { const diffFile = convertObjectPropsToCamelCase(diffDiscussionMock.diff_file, { deep: true }); props = { diffFile, - currentUser: {}, + canCurrentUserFork: false, }; }); diff --git a/spec/javascripts/diffs/components/diff_file_spec.js b/spec/javascripts/diffs/components/diff_file_spec.js index 9b994543e19..7a4616ec8eb 100644 --- a/spec/javascripts/diffs/components/diff_file_spec.js +++ b/spec/javascripts/diffs/components/diff_file_spec.js @@ -11,7 +11,7 @@ describe('DiffFile', () => { beforeEach(() => { vm = createComponentWithStore(Vue.extend(DiffFileComponent), store, { file: getDiffFileMock(), - currentUser: {}, + canCurrentUserFork: false, }).$mount(); }); diff --git a/spec/javascripts/diffs/components/diff_line_note_form_spec.js b/spec/javascripts/diffs/components/diff_line_note_form_spec.js index 81cd4f9769a..4600aaea70b 100644 --- a/spec/javascripts/diffs/components/diff_line_note_form_spec.js +++ b/spec/javascripts/diffs/components/diff_line_note_form_spec.js @@ -15,7 +15,7 @@ describe('DiffLineNoteForm', () => { diffLines = diffFile.highlightedDiffLines; component = createComponentWithStore(Vue.extend(DiffLineNoteForm), store, { - diffFile, + diffFileHash: diffFile.fileHash, diffLines, line: diffLines[0], noteTargetLine: diffLines[0], diff --git a/spec/javascripts/diffs/store/getters_spec.js b/spec/javascripts/diffs/store/getters_spec.js index 919b612bb6a..6210d4a7124 100644 --- a/spec/javascripts/diffs/store/getters_spec.js +++ b/spec/javascripts/diffs/store/getters_spec.js @@ -184,4 +184,23 @@ describe('Diffs Module Getters', () => { ).toEqual(0); }); }); + + describe('getDiffFileByHash', () => { + it('returns file by hash', () => { + const fileA = { + fileHash: '123', + }; + const fileB = { + fileHash: '456', + }; + localState.diffFiles = [fileA, fileB]; + + expect(getters.getDiffFileByHash(localState)('456')).toEqual(fileB); + }); + + it('returns null if no matching file is found', () => { + localState.diffFiles = []; + expect(getters.getDiffFileByHash(localState)('123')).toBeUndefined(); + }); + }); }); diff --git a/spec/javascripts/monitoring/mock_data.js b/spec/javascripts/monitoring/mock_data.js index 10808315372..e4c98a3bcb5 100644 --- a/spec/javascripts/monitoring/mock_data.js +++ b/spec/javascripts/monitoring/mock_data.js @@ -6561,6 +6561,9 @@ export const environmentData = [ folder_path: '/root/hello-prometheus/environments/folders/production', created_at: '2018-06-29T16:53:38.301Z', updated_at: '2018-06-29T16:57:09.825Z', + last_deployment: { + id: 127, + }, }, }, { @@ -6580,6 +6583,20 @@ export const environmentData = [ folder_path: '/root/hello-prometheus/environments/folders/review', created_at: '2018-07-03T18:39:41.702Z', updated_at: '2018-07-03T18:44:54.010Z', + last_deployment: { + id: 128, + }, + }, + }, + { + name: 'no-deployment', + size: 1, + latest: { + id: 36, + name: 'no-deployment/noop-branch', + state: 'available', + created_at: '2018-07-04T18:39:41.702Z', + updated_at: '2018-07-04T18:44:54.010Z', }, }, ]; diff --git a/spec/javascripts/monitoring/monitoring_store_spec.js b/spec/javascripts/monitoring/monitoring_store_spec.js index 08d54946787..ccdf4eda563 100644 --- a/spec/javascripts/monitoring/monitoring_store_spec.js +++ b/spec/javascripts/monitoring/monitoring_store_spec.js @@ -1,5 +1,5 @@ import MonitoringStore from '~/monitoring/stores/monitoring_store'; -import MonitoringMock, { deploymentData } from './mock_data'; +import MonitoringMock, { deploymentData, environmentData } from './mock_data'; describe('MonitoringStore', function () { this.store = new MonitoringStore(); @@ -21,4 +21,9 @@ describe('MonitoringStore', function () { expect(this.store.deploymentData.length).toEqual(3); expect(typeof this.store.deploymentData[0]).toEqual('object'); }); + + it('only stores environment data that contains deployments', () => { + this.store.storeEnvironmentsData(environmentData); + expect(this.store.environmentsData.length).toEqual(2); + }); }); |