Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-11-25 21:14:13 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-11-25 21:14:13 +0300
commit1c635e68ea6fb392244f0d9f8c9dd2c7bd1c95e6 (patch)
tree052cfeba83f0db195c3861cd3a0173df30bb8a01 /app
parentd03aeb1110374d140a42622716597ccfa8e4ba57 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/repository/components/code_owners.vue127
-rw-r--r--app/assets/javascripts/repository/components/last_commit.vue2
-rw-r--r--app/assets/javascripts/repository/index.js17
-rw-r--r--app/assets/javascripts/repository/queries/code_owners_info.query.graphql15
-rw-r--r--app/assets/javascripts/runner/components/runner_list.vue10
-rw-r--r--app/assets/javascripts/vue_merge_request_widget/components/extensions/base.vue25
-rw-r--r--app/graphql/types/repository/blob_type.rb4
-rw-r--r--app/models/concerns/packages/debian/component_file.rb8
-rw-r--r--app/presenters/blob_presenter.rb4
-rw-r--r--app/services/packages/debian/generate_distribution_service.rb2
-rw-r--r--app/views/projects/_files.html.haml5
11 files changed, 199 insertions, 20 deletions
diff --git a/app/assets/javascripts/repository/components/code_owners.vue b/app/assets/javascripts/repository/components/code_owners.vue
new file mode 100644
index 00000000000..52f75c476a8
--- /dev/null
+++ b/app/assets/javascripts/repository/components/code_owners.vue
@@ -0,0 +1,127 @@
+<script>
+import { GlIcon, GlLink } from '@gitlab/ui';
+import { __ } from '~/locale';
+import createFlash from '~/flash';
+import { helpPagePath } from '~/helpers/help_page_helper';
+import codeOwnersInfoQuery from '../queries/code_owners_info.query.graphql';
+import getRefMixin from '../mixins/get_ref';
+
+export default {
+ i18n: {
+ title: __('Code owners'),
+ about: __('About this feature'),
+ andSeparator: __('and'),
+ errorMessage: __('An error occurred while loading code owners.'),
+ },
+ codeOwnersHelpPath: helpPagePath('user/project/code_owners'),
+ components: {
+ GlIcon,
+ GlLink,
+ },
+ mixins: [getRefMixin],
+ apollo: {
+ project: {
+ query: codeOwnersInfoQuery,
+ variables() {
+ return {
+ projectPath: this.projectPath,
+ filePath: this.filePath,
+ ref: this.ref,
+ };
+ },
+ skip() {
+ return !this.filePath;
+ },
+ result() {
+ this.isFetching = false;
+ },
+ error() {
+ createFlash({ message: this.$options.i18n.errorMessage });
+ },
+ },
+ },
+ props: {
+ projectPath: {
+ type: String,
+ required: true,
+ },
+ filePath: {
+ type: String,
+ required: false,
+ default: null,
+ },
+ },
+ data() {
+ return {
+ isFetching: false,
+ project: {
+ repository: {
+ blobs: {
+ nodes: [
+ {
+ codeOwners: [],
+ },
+ ],
+ },
+ },
+ },
+ };
+ },
+ computed: {
+ blobInfo() {
+ return this.project?.repository?.blobs?.nodes[0];
+ },
+ codeOwners() {
+ return this.blobInfo?.codeOwners || [];
+ },
+ hasCodeOwners() {
+ return this.filePath && Boolean(this.codeOwners.length);
+ },
+ commaSeparateList() {
+ return this.codeOwners.length > 2;
+ },
+ showAndSeparator() {
+ return this.codeOwners.length > 1;
+ },
+ lastListItem() {
+ return this.codeOwners.length - 1;
+ },
+ },
+ watch: {
+ filePath() {
+ this.isFetching = true;
+ this.$apollo.queries.project.refetch();
+ },
+ },
+};
+</script>
+
+<template>
+ <div
+ v-if="hasCodeOwners && !isFetching"
+ class="well-segment blob-auxiliary-viewer file-owner-content qa-file-owner-content"
+ >
+ <gl-icon name="users" data-testid="users-icon" />
+ <strong>{{ $options.i18n.title }}</strong>
+ <gl-link :href="$options.codeOwnersHelpPath" target="_blank" :title="$options.i18n.about">
+ <gl-icon name="question-o" data-testid="help-icon" />
+ </gl-link>
+ :
+ <div
+ v-for="(owner, index) in codeOwners"
+ :key="index"
+ :class="[
+ { 'gl-display-inline-block': commaSeparateList, 'gl-display-inline': !commaSeparateList },
+ ]"
+ data-testid="code-owners"
+ >
+ <span v-if="commaSeparateList && index > 0" data-testid="comma-separator">,</span>
+ <span v-if="showAndSeparator && index === lastListItem" data-testid="and-separator">{{
+ $options.i18n.andSeparator
+ }}</span>
+ <gl-link :href="owner.webPath" target="_blank" :title="$options.i18n.about">
+ {{ owner.name }}
+ </gl-link>
+ </div>
+ </div>
+</template>
diff --git a/app/assets/javascripts/repository/components/last_commit.vue b/app/assets/javascripts/repository/components/last_commit.vue
index 62066973ee6..43e114a91d3 100644
--- a/app/assets/javascripts/repository/components/last_commit.vue
+++ b/app/assets/javascripts/repository/components/last_commit.vue
@@ -111,7 +111,7 @@ export default {
</script>
<template>
- <div class="info-well d-none d-sm-flex project-last-commit commit p-3">
+ <div class="well-segment commit gl-p-5 gl-w-full">
<gl-loading-icon v-if="isLoading" size="md" color="dark" class="m-auto" />
<template v-else-if="commit">
<user-avatar-link
diff --git a/app/assets/javascripts/repository/index.js b/app/assets/javascripts/repository/index.js
index 45e026ad695..fc671f35691 100644
--- a/app/assets/javascripts/repository/index.js
+++ b/app/assets/javascripts/repository/index.js
@@ -9,6 +9,7 @@ import App from './components/app.vue';
import Breadcrumbs from './components/breadcrumbs.vue';
import DirectoryDownloadLinks from './components/directory_download_links.vue';
import LastCommit from './components/last_commit.vue';
+import CodeOwners from './components/code_owners.vue';
import apolloProvider from './graphql';
import commitsQuery from './queries/commits.query.graphql';
import projectPathQuery from './queries/project_path.query.graphql';
@@ -71,7 +72,23 @@ export default function setupVueRepositoryList() {
},
});
+ const initCodeOwnersApp = () =>
+ new Vue({
+ el: document.getElementById('js-code-owners'),
+ router,
+ apolloProvider,
+ render(h) {
+ return h(CodeOwners, {
+ props: {
+ filePath: this.$route.params.path,
+ projectPath,
+ },
+ });
+ },
+ });
+
initLastCommitApp();
+ initCodeOwnersApp();
router.afterEach(({ params: { path } }) => {
setTitle(path, ref, fullName);
diff --git a/app/assets/javascripts/repository/queries/code_owners_info.query.graphql b/app/assets/javascripts/repository/queries/code_owners_info.query.graphql
new file mode 100644
index 00000000000..29c6265bbbd
--- /dev/null
+++ b/app/assets/javascripts/repository/queries/code_owners_info.query.graphql
@@ -0,0 +1,15 @@
+query getCodeOwnersInfo($projectPath: ID!, $filePath: String!, $ref: String!) {
+ project(fullPath: $projectPath) {
+ id
+ repository {
+ blobs(paths: [$filePath], ref: $ref) {
+ nodes {
+ codeOwners {
+ name
+ webPath
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/app/assets/javascripts/runner/components/runner_list.vue b/app/assets/javascripts/runner/components/runner_list.vue
index f8dbc469c22..96a5a3843a1 100644
--- a/app/assets/javascripts/runner/components/runner_list.vue
+++ b/app/assets/javascripts/runner/components/runner_list.vue
@@ -1,5 +1,6 @@
<script>
import { GlTable, GlTooltipDirective, GlSkeletonLoader } from '@gitlab/ui';
+import TooltipOnTruncate from '~/vue_shared/components/tooltip_on_truncate.vue';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { __, s__ } from '~/locale';
import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue';
@@ -32,6 +33,7 @@ export default {
components: {
GlTable,
GlSkeletonLoader,
+ TooltipOnTruncate,
TimeAgo,
RunnerActionsCell,
RunnerSummaryCell,
@@ -101,11 +103,15 @@ export default {
</template>
<template #cell(version)="{ item: { version } }">
- {{ version }}
+ <tooltip-on-truncate class="gl-display-block gl-text-truncate" :title="version">
+ {{ version }}
+ </tooltip-on-truncate>
</template>
<template #cell(ipAddress)="{ item: { ipAddress } }">
- {{ ipAddress }}
+ <tooltip-on-truncate class="gl-display-block gl-text-truncate" :title="ipAddress">
+ {{ ipAddress }}
+ </tooltip-on-truncate>
</template>
<template #cell(tagList)="{ item: { tagList } }">
diff --git a/app/assets/javascripts/vue_merge_request_widget/components/extensions/base.vue b/app/assets/javascripts/vue_merge_request_widget/components/extensions/base.vue
index 4413ab62ca9..5f77c0cd2f3 100644
--- a/app/assets/javascripts/vue_merge_request_widget/components/extensions/base.vue
+++ b/app/assets/javascripts/vue_merge_request_widget/components/extensions/base.vue
@@ -104,16 +104,7 @@ export default {
},
},
mounted() {
- this.fetchCollapsedData(this.$props)
- .then((data) => {
- this.collapsedData = data;
- this.loadingState = null;
- })
- .catch((e) => {
- this.loadingState = LOADING_STATES.collapsedError;
-
- Sentry.captureException(e);
- });
+ this.loadCollapsedData();
},
methods: {
triggerRedisTracking: once(function triggerRedisTracking() {
@@ -126,6 +117,20 @@ export default {
this.triggerRedisTracking();
},
+ loadCollapsedData() {
+ this.loadingState = LOADING_STATES.collapsedLoading;
+
+ this.fetchCollapsedData(this.$props)
+ .then((data) => {
+ this.collapsedData = data;
+ this.loadingState = null;
+ })
+ .catch((e) => {
+ this.loadingState = LOADING_STATES.collapsedError;
+
+ Sentry.captureException(e);
+ });
+ },
loadAllData() {
if (this.hasFullData) return;
diff --git a/app/graphql/types/repository/blob_type.rb b/app/graphql/types/repository/blob_type.rb
index 104171e6772..0182a372df3 100644
--- a/app/graphql/types/repository/blob_type.rb
+++ b/app/graphql/types/repository/blob_type.rb
@@ -71,6 +71,10 @@ module Types
field :pipeline_editor_path, GraphQL::Types::String, null: true,
description: 'Web path to edit .gitlab-ci.yml file.'
+ field :code_owners, [Types::UserType], null: true,
+ description: 'List of code owners for the blob.',
+ calls_gitaly: true
+
field :file_type, GraphQL::Types::String, null: true,
description: 'Expected format of the blob based on the extension.'
diff --git a/app/models/concerns/packages/debian/component_file.rb b/app/models/concerns/packages/debian/component_file.rb
index 9cf66c756a0..77409549e85 100644
--- a/app/models/concerns/packages/debian/component_file.rb
+++ b/app/models/concerns/packages/debian/component_file.rb
@@ -20,13 +20,13 @@ module Packages
belongs_to :component, class_name: "Packages::Debian::#{container_type.capitalize}Component", inverse_of: :files
belongs_to :architecture, class_name: "Packages::Debian::#{container_type.capitalize}Architecture", inverse_of: :files, optional: true
- enum file_type: { packages: 1, source: 2, di_packages: 3 }
+ enum file_type: { packages: 1, sources: 2, di_packages: 3 }
enum compression_type: { gz: 1, bz2: 2, xz: 3 }
validates :component, presence: true
validates :file_type, presence: true
- validates :architecture, presence: true, unless: :source?
- validates :architecture, absence: true, if: :source?
+ validates :architecture, presence: true, unless: :sources?
+ validates :architecture, absence: true, if: :sources?
validates :file, length: { minimum: 0, allow_nil: false }
validates :size, presence: true
validates :file_store, presence: true
@@ -81,7 +81,7 @@ module Packages
case file_type
when 'packages'
"#{component.name}/binary-#{architecture.name}/#{file_name}#{extension}"
- when 'source'
+ when 'sources'
"#{component.name}/source/#{file_name}#{extension}"
when 'di_packages'
"#{component.name}/debian-installer/binary-#{architecture.name}/#{file_name}#{extension}"
diff --git a/app/presenters/blob_presenter.rb b/app/presenters/blob_presenter.rb
index 5835a77d0b9..5466e8e0b05 100644
--- a/app/presenters/blob_presenter.rb
+++ b/app/presenters/blob_presenter.rb
@@ -66,6 +66,10 @@ class BlobPresenter < Gitlab::View::Presenter::Delegated
project_ci_pipeline_editor_path(project, branch_name: blob.commit_id) if can_collaborate_with_project?(project) && blob.path == project.ci_config_path_or_default
end
+ def code_owners
+ Gitlab::CodeOwners.for_blob(project, blob)
+ end
+
def fork_and_edit_path
fork_path_for_current_user(project, edit_blob_path)
end
diff --git a/app/services/packages/debian/generate_distribution_service.rb b/app/services/packages/debian/generate_distribution_service.rb
index 74b07e05aa6..33bf877a153 100644
--- a/app/services/packages/debian/generate_distribution_service.rb
+++ b/app/services/packages/debian/generate_distribution_service.rb
@@ -91,7 +91,7 @@ module Packages
generate_component_file(component, :packages, architecture, :deb)
generate_component_file(component, :di_packages, architecture, :udeb)
end
- generate_component_file(component, :source, nil, :dsc)
+ generate_component_file(component, :sources, nil, :dsc)
end
end
diff --git a/app/views/projects/_files.html.haml b/app/views/projects/_files.html.haml
index cdcc98552f9..2f4a61865f8 100644
--- a/app/views/projects/_files.html.haml
+++ b/app/views/projects/_files.html.haml
@@ -10,10 +10,11 @@
.nav-block.gl-display-flex.gl-xs-flex-direction-column.gl-align-items-stretch
= render 'projects/tree/tree_header', tree: @tree
- #js-last-commit
- .info-well.gl-display-none.gl-sm-display-flex.project-last-commit
+ .info-well.gl-display-none.gl-sm-display-flex.project-last-commit.gl-flex-direction-column
+ #js-last-commit.gl-m-auto
.gl-spinner-container.m-auto
= loading_icon(size: 'md', color: 'dark', css_class: 'align-text-bottom')
+ #js-code-owners
- if is_project_overview
.project-buttons.gl-mb-3.js-show-on-project-root