Commit a22b50dc authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'ph/useWebPathDescriptionHTMLInRepo' into 'master'

Uses webPath and descriptionHTML in repository browser

Closes #230426

See merge request gitlab-org/gitlab!38047
parents 58b322f6 e7a00630
...@@ -9,9 +9,9 @@ import { joinPaths, escapeFileUrl } from '~/lib/utils/url_utility'; ...@@ -9,9 +9,9 @@ import { joinPaths, escapeFileUrl } from '~/lib/utils/url_utility';
import { __ } from '../../locale'; import { __ } from '../../locale';
import Icon from '../../vue_shared/components/icon.vue'; import Icon from '../../vue_shared/components/icon.vue';
import getRefMixin from '../mixins/get_ref'; import getRefMixin from '../mixins/get_ref';
import getProjectShortPath from '../queries/getProjectShortPath.query.graphql'; import projectShortPathQuery from '../queries/project_short_path.query.graphql';
import getProjectPath from '../queries/getProjectPath.query.graphql'; import projectPathQuery from '../queries/project_path.query.graphql';
import getPermissions from '../queries/getPermissions.query.graphql'; import permissionsQuery from '../queries/permissions.query.graphql';
const ROW_TYPES = { const ROW_TYPES = {
header: 'header', header: 'header',
...@@ -28,13 +28,13 @@ export default { ...@@ -28,13 +28,13 @@ export default {
}, },
apollo: { apollo: {
projectShortPath: { projectShortPath: {
query: getProjectShortPath, query: projectShortPathQuery,
}, },
projectPath: { projectPath: {
query: getProjectPath, query: projectPathQuery,
}, },
userPermissions: { userPermissions: {
query: getPermissions, query: permissionsQuery,
variables() { variables() {
return { return {
projectPath: this.projectPath, projectPath: this.projectPath,
......
...@@ -8,8 +8,8 @@ import TimeagoTooltip from '../../vue_shared/components/time_ago_tooltip.vue'; ...@@ -8,8 +8,8 @@ import TimeagoTooltip from '../../vue_shared/components/time_ago_tooltip.vue';
import CiIcon from '../../vue_shared/components/ci_icon.vue'; import CiIcon from '../../vue_shared/components/ci_icon.vue';
import ClipboardButton from '../../vue_shared/components/clipboard_button.vue'; import ClipboardButton from '../../vue_shared/components/clipboard_button.vue';
import getRefMixin from '../mixins/get_ref'; import getRefMixin from '../mixins/get_ref';
import getProjectPath from '../queries/getProjectPath.query.graphql'; import projectPathQuery from '../queries/project_path.query.graphql';
import pathLastCommit from '../queries/pathLastCommit.query.graphql'; import pathLastCommitQuery from '../queries/path_last_commit.query.graphql';
export default { export default {
components: { components: {
...@@ -28,10 +28,10 @@ export default { ...@@ -28,10 +28,10 @@ export default {
mixins: [getRefMixin], mixins: [getRefMixin],
apollo: { apollo: {
projectPath: { projectPath: {
query: getProjectPath, query: projectPathQuery,
}, },
commit: { commit: {
query: pathLastCommit, query: pathLastCommitQuery,
variables() { variables() {
return { return {
projectPath: this.projectPath, projectPath: this.projectPath,
...@@ -102,7 +102,7 @@ export default { ...@@ -102,7 +102,7 @@ export default {
<template v-else-if="commit"> <template v-else-if="commit">
<user-avatar-link <user-avatar-link
v-if="commit.author" v-if="commit.author"
:link-href="commit.author.webUrl" :link-href="commit.author.webPath"
:img-src="commit.author.avatarUrl" :img-src="commit.author.avatarUrl"
:img-size="40" :img-size="40"
class="avatar-cell" class="avatar-cell"
...@@ -118,13 +118,13 @@ export default { ...@@ -118,13 +118,13 @@ export default {
<div class="commit-detail flex-list"> <div class="commit-detail flex-list">
<div class="commit-content qa-commit-content"> <div class="commit-content qa-commit-content">
<gl-link <gl-link
:href="commit.webUrl" :href="commit.webPath"
:class="{ 'font-italic': !commit.message }" :class="{ 'font-italic': !commit.message }"
class="commit-row-message item-title" class="commit-row-message item-title"
v-html="commit.titleHtml" v-html="commit.titleHtml"
/> />
<gl-deprecated-button <gl-deprecated-button
v-if="commit.description" v-if="commit.descriptionHtml"
:class="{ open: showDescription }" :class="{ open: showDescription }"
:aria-label="__('Show commit description')" :aria-label="__('Show commit description')"
class="text-expander" class="text-expander"
...@@ -135,7 +135,7 @@ export default { ...@@ -135,7 +135,7 @@ export default {
<div class="committer"> <div class="committer">
<gl-link <gl-link
v-if="commit.author" v-if="commit.author"
:href="commit.author.webUrl" :href="commit.author.webPath"
class="commit-author-link js-user-link" class="commit-author-link js-user-link"
> >
{{ commit.author.name }} {{ commit.author.name }}
...@@ -147,11 +147,11 @@ export default { ...@@ -147,11 +147,11 @@ export default {
<timeago-tooltip :time="commit.authoredDate" tooltip-placement="bottom" /> <timeago-tooltip :time="commit.authoredDate" tooltip-placement="bottom" />
</div> </div>
<pre <pre
v-if="commit.description" v-if="commit.descriptionHtml"
:class="{ 'd-block': showDescription }" :class="{ 'd-block': showDescription }"
class="commit-row-description gl-mb-3" class="commit-row-description gl-mb-3"
>{{ commit.description }}</pre v-html="commit.descriptionHtml"
> ></pre>
</div> </div>
<div class="commit-actions flex-row"> <div class="commit-actions flex-row">
<div v-if="commit.signatureHtml" v-html="commit.signatureHtml"></div> <div v-if="commit.signatureHtml" v-html="commit.signatureHtml"></div>
......
...@@ -3,15 +3,15 @@ import $ from 'jquery'; ...@@ -3,15 +3,15 @@ import $ from 'jquery';
import '~/behaviors/markdown/render_gfm'; import '~/behaviors/markdown/render_gfm';
import { GlLink, GlLoadingIcon } from '@gitlab/ui'; import { GlLink, GlLoadingIcon } from '@gitlab/ui';
import { handleLocationHash } from '~/lib/utils/common_utils'; import { handleLocationHash } from '~/lib/utils/common_utils';
import getReadmeQuery from '../../queries/getReadme.query.graphql'; import readmeQuery from '../../queries/readme.query.graphql';
export default { export default {
apollo: { apollo: {
readme: { readme: {
query: getReadmeQuery, query: readmeQuery,
variables() { variables() {
return { return {
url: this.blob.webUrl, url: this.blob.webPath,
}; };
}, },
loadingKey: 'loading', loadingKey: 'loading',
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { GlSkeletonLoading } from '@gitlab/ui'; import { GlSkeletonLoading } from '@gitlab/ui';
import { sprintf, __ } from '../../../locale'; import { sprintf, __ } from '../../../locale';
import getRefMixin from '../../mixins/get_ref'; import getRefMixin from '../../mixins/get_ref';
import getProjectPath from '../../queries/getProjectPath.query.graphql'; import projectPathQuery from '../../queries/project_path.query.graphql';
import TableHeader from './header.vue'; import TableHeader from './header.vue';
import TableRow from './row.vue'; import TableRow from './row.vue';
import ParentRow from './parent_row.vue'; import ParentRow from './parent_row.vue';
...@@ -17,7 +17,7 @@ export default { ...@@ -17,7 +17,7 @@ export default {
mixins: [getRefMixin], mixins: [getRefMixin],
apollo: { apollo: {
projectPath: { projectPath: {
query: getProjectPath, query: projectPathQuery,
}, },
}, },
props: { props: {
...@@ -96,7 +96,7 @@ export default { ...@@ -96,7 +96,7 @@ export default {
:name="entry.name" :name="entry.name"
:path="entry.flatPath" :path="entry.flatPath"
:type="entry.type" :type="entry.type"
:url="entry.webUrl" :url="entry.webUrl || entry.webPath"
:mode="entry.mode" :mode="entry.mode"
:submodule-tree-url="entry.treeUrl" :submodule-tree-url="entry.treeUrl"
:lfs-oid="entry.lfsOid" :lfs-oid="entry.lfsOid"
......
...@@ -12,7 +12,7 @@ import { escapeFileUrl } from '~/lib/utils/url_utility'; ...@@ -12,7 +12,7 @@ import { escapeFileUrl } from '~/lib/utils/url_utility';
import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import FileIcon from '~/vue_shared/components/file_icon.vue'; import FileIcon from '~/vue_shared/components/file_icon.vue';
import getRefMixin from '../../mixins/get_ref'; import getRefMixin from '../../mixins/get_ref';
import getCommit from '../../queries/getCommit.query.graphql'; import commitQuery from '../../queries/commit.query.graphql';
export default { export default {
components: { components: {
...@@ -29,7 +29,7 @@ export default { ...@@ -29,7 +29,7 @@ export default {
}, },
apollo: { apollo: {
commit: { commit: {
query: getCommit, query: commitQuery,
variables() { variables() {
return { return {
fileName: this.name, fileName: this.name,
......
...@@ -3,8 +3,8 @@ import createFlash from '~/flash'; ...@@ -3,8 +3,8 @@ import createFlash from '~/flash';
import { __ } from '../../locale'; import { __ } from '../../locale';
import FileTable from './table/index.vue'; import FileTable from './table/index.vue';
import getRefMixin from '../mixins/get_ref'; import getRefMixin from '../mixins/get_ref';
import getFiles from '../queries/getFiles.query.graphql'; import filesQuery from '../queries/files.query.graphql';
import getProjectPath from '../queries/getProjectPath.query.graphql'; import projectPathQuery from '../queries/project_path.query.graphql';
import FilePreview from './preview/index.vue'; import FilePreview from './preview/index.vue';
import { readmeFile } from '../utils/readme'; import { readmeFile } from '../utils/readme';
...@@ -18,7 +18,7 @@ export default { ...@@ -18,7 +18,7 @@ export default {
mixins: [getRefMixin], mixins: [getRefMixin],
apollo: { apollo: {
projectPath: { projectPath: {
query: getProjectPath, query: projectPathQuery,
}, },
}, },
props: { props: {
...@@ -70,7 +70,7 @@ export default { ...@@ -70,7 +70,7 @@ export default {
return this.$apollo return this.$apollo
.query({ .query({
query: getFiles, query: filesQuery,
variables: { variables: {
projectPath: this.projectPath, projectPath: this.projectPath,
ref: this.ref, ref: this.ref,
......
import { normalizeData } from 'ee_else_ce/repository/utils/commit'; import { normalizeData } from 'ee_else_ce/repository/utils/commit';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import getCommits from './queries/getCommits.query.graphql'; import commitsQuery from './queries/commits.query.graphql';
import getProjectPath from './queries/getProjectPath.query.graphql'; import projectPathQuery from './queries/project_path.query.graphql';
import getRef from './queries/getRef.query.graphql'; import refQuery from './queries/ref.query.graphql';
let fetchpromise; let fetchpromise;
let resolvers = []; let resolvers = [];
...@@ -22,8 +22,8 @@ export function fetchLogsTree(client, path, offset, resolver = null) { ...@@ -22,8 +22,8 @@ export function fetchLogsTree(client, path, offset, resolver = null) {
if (fetchpromise) return fetchpromise; if (fetchpromise) return fetchpromise;
const { projectPath } = client.readQuery({ query: getProjectPath }); const { projectPath } = client.readQuery({ query: projectPathQuery });
const { escapedRef } = client.readQuery({ query: getRef }); const { escapedRef } = client.readQuery({ query: refQuery });
fetchpromise = axios fetchpromise = axios
.get( .get(
...@@ -36,10 +36,10 @@ export function fetchLogsTree(client, path, offset, resolver = null) { ...@@ -36,10 +36,10 @@ export function fetchLogsTree(client, path, offset, resolver = null) {
) )
.then(({ data, headers }) => { .then(({ data, headers }) => {
const headerLogsOffset = headers['more-logs-offset']; const headerLogsOffset = headers['more-logs-offset'];
const { commits } = client.readQuery({ query: getCommits }); const { commits } = client.readQuery({ query: commitsQuery });
const newCommitData = [...commits, ...normalizeData(data, path)]; const newCommitData = [...commits, ...normalizeData(data, path)];
client.writeQuery({ client.writeQuery({
query: getCommits, query: commitsQuery,
data: { commits: newCommitData }, data: { commits: newCommitData },
}); });
......
import getRef from '../queries/getRef.query.graphql'; import refQuery from '../queries/ref.query.graphql';
export default { export default {
apollo: { apollo: {
ref: { ref: {
query: getRef, query: refQuery,
manual: true, manual: true,
result({ data, loading }) { result({ data, loading }) {
if (!loading) { if (!loading) {
......
import getFiles from '../queries/getFiles.query.graphql'; import filesQuery from '../queries/files.query.graphql';
import getRefMixin from './get_ref'; import getRefMixin from './get_ref';
import getProjectPath from '../queries/getProjectPath.query.graphql'; import projectPathQuery from '../queries/project_path.query.graphql';
export default { export default {
mixins: [getRefMixin], mixins: [getRefMixin],
apollo: { apollo: {
projectPath: { projectPath: {
query: getProjectPath, query: projectPathQuery,
}, },
}, },
data() { data() {
...@@ -21,7 +21,7 @@ export default { ...@@ -21,7 +21,7 @@ export default {
return this.$apollo return this.$apollo
.query({ .query({
query: getFiles, query: filesQuery,
variables: { variables: {
projectPath: this.projectPath, projectPath: this.projectPath,
ref: this.ref, ref: this.ref,
......
...@@ -22,7 +22,7 @@ query getFiles( ...@@ -22,7 +22,7 @@ query getFiles(
edges { edges {
node { node {
...TreeEntry ...TreeEntry
webUrl webPath
} }
} }
pageInfo { pageInfo {
...@@ -46,7 +46,7 @@ query getFiles( ...@@ -46,7 +46,7 @@ query getFiles(
node { node {
...TreeEntry ...TreeEntry
mode mode
webUrl webPath
lfsOid lfsOid
} }
} }
......
...@@ -6,7 +6,7 @@ query pathLastCommit($projectPath: ID!, $path: String, $ref: String!) { ...@@ -6,7 +6,7 @@ query pathLastCommit($projectPath: ID!, $path: String, $ref: String!) {
sha sha
title title
titleHtml titleHtml
description descriptionHtml
message message
webUrl webUrl
authoredDate authoredDate
......
---
title: Fix HTML not rendering in last commit widget
merge_request: 38047
author:
type: fixed
...@@ -10,7 +10,7 @@ exports[`Repository last commit component renders commit widget 1`] = ` ...@@ -10,7 +10,7 @@ exports[`Repository last commit component renders commit widget 1`] = `
imgcssclasses="" imgcssclasses=""
imgsize="40" imgsize="40"
imgsrc="https://test.com" imgsrc="https://test.com"
linkhref="https://test.com/test" linkhref="/test"
tooltipplacement="top" tooltipplacement="top"
tooltiptext="" tooltiptext=""
username="" username=""
...@@ -24,7 +24,7 @@ exports[`Repository last commit component renders commit widget 1`] = ` ...@@ -24,7 +24,7 @@ exports[`Repository last commit component renders commit widget 1`] = `
> >
<gl-link-stub <gl-link-stub
class="commit-row-message item-title" class="commit-row-message item-title"
href="https://test.com/commit/123" href="/commit/123"
> >
Commit title Commit title
</gl-link-stub> </gl-link-stub>
...@@ -36,7 +36,7 @@ exports[`Repository last commit component renders commit widget 1`] = ` ...@@ -36,7 +36,7 @@ exports[`Repository last commit component renders commit widget 1`] = `
> >
<gl-link-stub <gl-link-stub
class="commit-author-link js-user-link" class="commit-author-link js-user-link"
href="https://test.com/test" href="/test"
> >
Test Test
...@@ -110,7 +110,7 @@ exports[`Repository last commit component renders the signature HTML as returned ...@@ -110,7 +110,7 @@ exports[`Repository last commit component renders the signature HTML as returned
imgcssclasses="" imgcssclasses=""
imgsize="40" imgsize="40"
imgsrc="https://test.com" imgsrc="https://test.com"
linkhref="https://test.com/test" linkhref="/test"
tooltipplacement="top" tooltipplacement="top"
tooltiptext="" tooltiptext=""
username="" username=""
...@@ -124,7 +124,7 @@ exports[`Repository last commit component renders the signature HTML as returned ...@@ -124,7 +124,7 @@ exports[`Repository last commit component renders the signature HTML as returned
> >
<gl-link-stub <gl-link-stub
class="commit-row-message item-title" class="commit-row-message item-title"
href="https://test.com/commit/123" href="/commit/123"
> >
Commit title Commit title
</gl-link-stub> </gl-link-stub>
...@@ -136,7 +136,7 @@ exports[`Repository last commit component renders the signature HTML as returned ...@@ -136,7 +136,7 @@ exports[`Repository last commit component renders the signature HTML as returned
> >
<gl-link-stub <gl-link-stub
class="commit-author-link js-user-link" class="commit-author-link js-user-link"
href="https://test.com/test" href="/test"
> >
Test Test
......
...@@ -11,12 +11,12 @@ function createCommitData(data = {}) { ...@@ -11,12 +11,12 @@ function createCommitData(data = {}) {
title: 'Commit title', title: 'Commit title',
titleHtml: 'Commit title', titleHtml: 'Commit title',
message: 'Commit message', message: 'Commit message',
webUrl: 'https://test.com/commit/123', webPath: '/commit/123',
authoredDate: '2019-01-01', authoredDate: '2019-01-01',
author: { author: {
name: 'Test', name: 'Test',
avatarUrl: 'https://test.com', avatarUrl: 'https://test.com',
webUrl: 'https://test.com/test', webPath: '/test',
}, },
pipeline: { pipeline: {
detailedStatus: { detailedStatus: {
...@@ -108,7 +108,7 @@ describe('Repository last commit component', () => { ...@@ -108,7 +108,7 @@ describe('Repository last commit component', () => {
}); });
it('does not render description expander when description is null', () => { it('does not render description expander when description is null', () => {
factory(createCommitData({ description: null })); factory(createCommitData({ descriptionHtml: null }));
return vm.vm.$nextTick(() => { return vm.vm.$nextTick(() => {
expect(vm.find('.text-expander').exists()).toBe(false); expect(vm.find('.text-expander').exists()).toBe(false);
...@@ -117,7 +117,7 @@ describe('Repository last commit component', () => { ...@@ -117,7 +117,7 @@ describe('Repository last commit component', () => {
}); });
it('expands commit description when clicking expander', () => { it('expands commit description when clicking expander', () => {
factory(createCommitData({ description: 'Test description' })); factory(createCommitData({ descriptionHtml: 'Test description' }));
return vm.vm return vm.vm
.$nextTick() .$nextTick()
......
...@@ -13,7 +13,7 @@ const MOCK_BLOBS = [ ...@@ -13,7 +13,7 @@ const MOCK_BLOBS = [
flatPath: 'blob', flatPath: 'blob',
name: 'blob.md', name: 'blob.md',
type: 'blob', type: 'blob',
webUrl: 'http://test.com', webPath: '/blob',
}, },
{ {
id: '124abc', id: '124abc',
......
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