Commit d9c23919 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'ph/vueFileListLockLabelFoss' into 'master'

Only load lock labels in EE

See merge request gitlab-org/gitlab!20143
parents dfd15940 bc0c339f
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { normalizeData } from 'ee_else_ce/repository/utils/commit';
import getCommits from './queries/getCommits.query.graphql'; import getCommits from './queries/getCommits.query.graphql';
import getProjectPath from './queries/getProjectPath.query.graphql'; import getProjectPath from './queries/getProjectPath.query.graphql';
import getRef from './queries/getRef.query.graphql'; import getRef from './queries/getRef.query.graphql';
...@@ -6,19 +7,6 @@ import getRef from './queries/getRef.query.graphql'; ...@@ -6,19 +7,6 @@ import getRef from './queries/getRef.query.graphql';
let fetchpromise; let fetchpromise;
let resolvers = []; let resolvers = [];
export function normalizeData(data) {
return data.map(d => ({
sha: d.commit.id,
message: d.commit.message,
committedDate: d.commit.committed_date,
commitPath: d.commit_path,
fileName: d.file_name,
type: d.type,
lockLabel: d.lock_label,
__typename: 'LogTreeCommit',
}));
}
export function resolveCommit(commits, { resolve, entry }) { export function resolveCommit(commits, { resolve, entry }) {
const commit = commits.find(c => c.fileName === entry.name && c.type === entry.type); const commit = commits.find(c => c.fileName === entry.name && c.type === entry.type);
......
fragment TreeEntryCommit on LogTreeCommit {
sha
message
committedDate
commitPath
fileName
type
}
#import "ee_else_ce/repository/queries/commit.fragment.graphql"
query getCommit($fileName: String!, $type: String!, $path: String!) { query getCommit($fileName: String!, $type: String!, $path: String!) {
commit(path: $path, fileName: $fileName, type: $type) @client { commit(path: $path, fileName: $fileName, type: $type) @client {
sha ...TreeEntryCommit
message
committedDate
commitPath
fileName
type
lockLabel
} }
} }
#import "ee_else_ce/repository/queries/commit.fragment.graphql"
query getCommits { query getCommits {
commits @client { commits @client {
sha ...TreeEntryCommit
message
committedDate
commitPath
fileName
type
lockLabel
} }
} }
// eslint-disable-next-line import/prefer-default-export
export function normalizeData(data, extra = () => {}) {
return data.map(d => ({
sha: d.commit.id,
message: d.commit.message,
committedDate: d.commit.committed_date,
commitPath: d.commit_path,
fileName: d.file_name,
type: d.type,
__typename: 'LogTreeCommit',
...extra(d),
}));
}
fragment TreeEntryCommit on LogTreeCommit {
sha
message
committedDate
commitPath
fileName
type
lockLabel
}
import { normalizeData as normalizeDataFOSS } from '~/repository/utils/commit';
// eslint-disable-next-line import/prefer-default-export
export function normalizeData(data) {
return normalizeDataFOSS(data, d => ({
lockLabel: d.lock_label,
}));
}
import { normalizeData } from 'ee/repository/utils/commit';
const mockData = [
{
commit: {
id: '123',
message: 'testing message',
committed_date: '2019-01-01',
},
commit_path: `https://test.com`,
file_name: 'index.js',
type: 'blob',
lock_label: 'Locked',
},
];
describe('normalizeData', () => {
it('normalizes data into LogTreeCommit object', () => {
expect(normalizeData(mockData)).toEqual([
{
sha: '123',
message: 'testing message',
committedDate: '2019-01-01',
commitPath: 'https://test.com',
fileName: 'index.js',
type: 'blob',
lockLabel: 'Locked',
__typename: 'LogTreeCommit',
},
]);
});
});
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { normalizeData, resolveCommit, fetchLogsTree } from '~/repository/log_tree'; import { resolveCommit, fetchLogsTree } from '~/repository/log_tree';
const mockData = [ const mockData = [
{ {
...@@ -15,22 +15,6 @@ const mockData = [ ...@@ -15,22 +15,6 @@ const mockData = [
}, },
]; ];
describe('normalizeData', () => {
it('normalizes data into LogTreeCommit object', () => {
expect(normalizeData(mockData)).toEqual([
{
sha: '123',
message: 'testing message',
committedDate: '2019-01-01',
commitPath: 'https://test.com',
fileName: 'index.js',
type: 'blob',
__typename: 'LogTreeCommit',
},
]);
});
});
describe('resolveCommit', () => { describe('resolveCommit', () => {
it('calls resolve when commit found', () => { it('calls resolve when commit found', () => {
const resolver = { const resolver = {
......
import { normalizeData } from '~/repository/utils/commit';
const mockData = [
{
commit: {
id: '123',
message: 'testing message',
committed_date: '2019-01-01',
},
commit_path: `https://test.com`,
file_name: 'index.js',
type: 'blob',
},
];
describe('normalizeData', () => {
it('normalizes data into LogTreeCommit object', () => {
expect(normalizeData(mockData)).toEqual([
{
sha: '123',
message: 'testing message',
committedDate: '2019-01-01',
commitPath: 'https://test.com',
fileName: 'index.js',
type: 'blob',
__typename: 'LogTreeCommit',
},
]);
});
});
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