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
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/diffs/store/utils.js')
-rw-r--r--app/assets/javascripts/diffs/store/utils.js116
1 files changed, 0 insertions, 116 deletions
diff --git a/app/assets/javascripts/diffs/store/utils.js b/app/assets/javascripts/diffs/store/utils.js
index 7fa51b9ddea..75d2cf43b94 100644
--- a/app/assets/javascripts/diffs/store/utils.js
+++ b/app/assets/javascripts/diffs/store/utils.js
@@ -1,6 +1,5 @@
import { property, isEqual } from 'lodash';
import { diffModes, diffViewerModes } from '~/ide/constants';
-import { truncatePathMiddleToLength } from '~/lib/utils/text_utility';
import {
LINE_POSITION_LEFT,
LINE_POSITION_RIGHT,
@@ -11,10 +10,7 @@ import {
OLD_LINE_TYPE,
MATCH_LINE_TYPE,
LINES_TO_BE_RENDERED_DIRECTLY,
- TREE_TYPE,
INLINE_DIFF_LINES_KEY,
- SHOW_WHITESPACE,
- NO_SHOW_WHITESPACE,
CONFLICT_OUR,
CONFLICT_THEIR,
CONFLICT_MARKER,
@@ -485,111 +481,6 @@ export function isDiscussionApplicableToLine({ discussion, diffPosition, latestD
return latestDiff && discussion.active && line_code === discussion.line_code;
}
-export const getLowestSingleFolder = (folder) => {
- const getFolder = (blob, start = []) =>
- blob.tree.reduce(
- (acc, file) => {
- const shouldGetFolder = file.tree.length === 1 && file.tree[0].type === TREE_TYPE;
- const currentFileTypeTree = file.type === TREE_TYPE;
- const path = shouldGetFolder || currentFileTypeTree ? acc.path.concat(file.name) : acc.path;
- const tree = shouldGetFolder || currentFileTypeTree ? acc.tree.concat(file) : acc.tree;
-
- if (shouldGetFolder) {
- const firstFolder = getFolder(file);
-
- path.push(...firstFolder.path);
- tree.push(...firstFolder.tree);
- }
-
- return {
- ...acc,
- path,
- tree,
- };
- },
- { path: start, tree: [] },
- );
- const { path, tree } = getFolder(folder, [folder.name]);
-
- return {
- path: truncatePathMiddleToLength(path.join('/'), 40),
- treeAcc: tree.length ? tree[tree.length - 1].tree : null,
- };
-};
-
-export const flattenTree = (tree) => {
- const flatten = (blobTree) =>
- blobTree.reduce((acc, file) => {
- const blob = file;
- let treeToFlatten = blob.tree;
-
- if (file.type === TREE_TYPE && file.tree.length === 1) {
- const { treeAcc, path } = getLowestSingleFolder(file);
-
- if (treeAcc) {
- blob.name = path;
- treeToFlatten = flatten(treeAcc);
- }
- }
-
- blob.tree = flatten(treeToFlatten);
-
- return acc.concat(blob);
- }, []);
-
- return flatten(tree);
-};
-
-export const generateTreeList = (files) => {
- const { treeEntries, tree } = files.reduce(
- (acc, file) => {
- const split = file.new_path.split('/');
-
- split.forEach((name, i) => {
- const parent = acc.treeEntries[split.slice(0, i).join('/')];
- const path = `${parent ? `${parent.path}/` : ''}${name}`;
-
- if (!acc.treeEntries[path]) {
- const type = path === file.new_path ? 'blob' : 'tree';
- acc.treeEntries[path] = {
- key: path,
- path,
- name,
- type,
- tree: [],
- };
-
- const entry = acc.treeEntries[path];
-
- if (type === 'blob') {
- Object.assign(entry, {
- changed: true,
- tempFile: file.new_file,
- deleted: file.deleted_file,
- fileHash: file.file_hash,
- addedLines: file.added_lines,
- removedLines: file.removed_lines,
- parentPath: parent ? `${parent.path}/` : '/',
- submodule: file.submodule,
- });
- } else {
- Object.assign(entry, {
- opened: true,
- });
- }
-
- (parent ? parent.tree : acc.tree).push(entry);
- }
- });
-
- return acc;
- },
- { treeEntries: {}, tree: [] },
- );
-
- return { treeEntries, tree: flattenTree(tree) };
-};
-
export const getDiffMode = (diffFile) => {
const diffModeKey = Object.keys(diffModes).find((key) => diffFile[`${key}_file`]);
return (
@@ -666,10 +557,3 @@ export const allDiscussionWrappersExpanded = (diff) => {
return discussionsExpanded;
};
-
-export const getDefaultWhitespace = (queryString, cookie) => {
- // Querystring should override stored cookie value
- if (queryString) return queryString === SHOW_WHITESPACE;
- if (cookie === NO_SHOW_WHITESPACE) return false;
- return true;
-};