diff --git a/app/assets/javascripts/diffs/store/getters.js b/app/assets/javascripts/diffs/store/getters.js index 3ec9720c907..9ee73998177 100644 --- a/app/assets/javascripts/diffs/store/getters.js +++ b/app/assets/javascripts/diffs/store/getters.js @@ -170,5 +170,8 @@ export const diffLines = state => (file, unifiedDiffComponents) => { return null; } - return parallelizeDiffLines(file.highlighted_diff_lines || []); + return parallelizeDiffLines( + file.highlighted_diff_lines || [], + state.diffViewType === INLINE_DIFF_VIEW_TYPE, + ); }; diff --git a/app/assets/javascripts/diffs/store/utils.js b/app/assets/javascripts/diffs/store/utils.js index 79598ecea26..f87f57c32c3 100644 --- a/app/assets/javascripts/diffs/store/utils.js +++ b/app/assets/javascripts/diffs/store/utils.js @@ -36,9 +36,12 @@ export const isMeta = line => ['match', 'new-nonewline', 'old-nonewline'].includ * * @param {Object[]} diffLines - inline diff lines * + * @param {Boolean} inline - is inline context or not + * * @returns {Object[]} parallel lines */ -export const parallelizeDiffLines = (diffLines = []) => { + +export const parallelizeDiffLines = (diffLines, inline) => { let freeRightIndex = null; const lines = []; @@ -57,7 +60,7 @@ export const parallelizeDiffLines = (diffLines = []) => { } index += 1; } else if (isAdded(line)) { - if (freeRightIndex !== null) { + if (freeRightIndex !== null && !inline) { // If an old line came before this without a line on the right, this // line can be put to the right of it. lines[freeRightIndex].right = line; diff --git a/app/assets/stylesheets/framework/diffs.scss b/app/assets/stylesheets/framework/diffs.scss index f193785140d..e16ab5ee72f 100644 --- a/app/assets/stylesheets/framework/diffs.scss +++ b/app/assets/stylesheets/framework/diffs.scss @@ -641,12 +641,12 @@ table.code { } } - .diff-grid-left .old:nth-child(2) [data-linenumber], + .diff-grid-left .old:nth-child(1) [data-linenumber], .diff-grid-right .new:nth-child(2) [data-linenumber] { display: inline; } - .diff-grid-left .old:nth-child(3) [data-linenumber], + .diff-grid-left .old:nth-child(2) [data-linenumber], .diff-grid-right .new:nth-child(1) [data-linenumber] { display: none; } diff --git a/changelogs/unreleased/jdb-fix-unified-diffs-inline.yml b/changelogs/unreleased/jdb-fix-unified-diffs-inline.yml new file mode 100644 index 00000000000..19d60428347 --- /dev/null +++ b/changelogs/unreleased/jdb-fix-unified-diffs-inline.yml @@ -0,0 +1,5 @@ +--- +title: Fix unified component inline display +merge_request: 47345 +author: +type: fixed diff --git a/doc/user/admin_area/settings/visibility_and_access_controls.md b/doc/user/admin_area/settings/visibility_and_access_controls.md index 95a87378e18..3740dc95c12 100644 --- a/doc/user/admin_area/settings/visibility_and_access_controls.md +++ b/doc/user/admin_area/settings/visibility_and_access_controls.md @@ -78,7 +78,7 @@ CAUTION: **Warning:** The default behavior of [Delayed Project deletion](https://gitlab.com/gitlab-org/gitlab/-/issues/32935) in GitLab 12.6 was changed to [Immediate deletion](https://gitlab.com/gitlab-org/gitlab/-/issues/220382) in GitLab 13.2. -Projects within a group can be deleted after a delayed period, by [configuring in Group Settings](../../group/index.md#enabling-delayed-project-removal). +Projects within a group (but not a personal namespace) can be deleted after a delayed period, by [configuring in Group Settings](../../group/index.md#enabling-delayed-project-removal). The default period is 7 days, and can be changed. Setting this period to 0 will enable immediate removal of projects or groups. diff --git a/doc/user/project/index.md b/doc/user/project/index.md index a00f93bac9c..976d4d75059 100644 --- a/doc/user/project/index.md +++ b/doc/user/project/index.md @@ -192,17 +192,7 @@ To delete a project, first navigate to the home page for that project. 1. Click **Delete project** 1. Confirm this action by typing in the expected text. -### Delayed deletion **(PREMIUM)** - -By default, projects in a personal namespace are deleted after a seven day delay. - -Admins can restore the project during this period of time. -This delay [may be changed by an admin](../admin_area/settings/visibility_and_access_controls.md#default-deletion-delay). - -Admins can view all projects pending deletion. If you're an administrator, go to the top navigation bar, click **Projects > Your projects**, and then select the **Deleted projects** tab. -From this tab an admin can restore any project. - -For information on delay deletion of projects within a group, please see [Enabling delayed Project removal](../group/index.md#enabling-delayed-project-removal) +Projects in personal namespaces are deleted immediately on request. For information on delayed deletion of projects within a group, please see [Enabling delayed project removal](../group/index.md#enabling-delayed-project-removal). ## CI/CD for external repositories **(PREMIUM)** diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 7b32a7107da..299aa1d90d8 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -18551,6 +18551,9 @@ msgstr "" msgid "Not all data has been processed yet, the accuracy of the chart for the selected timeframe is limited." msgstr "" +msgid "Not applicable to personal namespaced projects, which are deleted immediately on request." +msgstr "" + msgid "Not available" msgstr "" diff --git a/spec/frontend/diffs/store/utils_spec.js b/spec/frontend/diffs/store/utils_spec.js index 39a482c85ae..866be0abd22 100644 --- a/spec/frontend/diffs/store/utils_spec.js +++ b/spec/frontend/diffs/store/utils_spec.js @@ -1221,5 +1221,26 @@ describe('DiffsStoreUtils', () => { file.parallel_diff_lines, ); }); + + /** + * What's going on here? + * + * The inline version of parallelizeDiffLines simply keeps the difflines + * in the same order they are received as opposed to shuffling them + * to be "side by side". + * + * This keeps the underlying data structure the same which simplifies + * the components, but keeps the changes grouped together as users + * expect when viewing changes inline. + */ + it('converts inline diff lines to inline diff lines with a parallel structure', () => { + const file = getDiffFileMock(); + const files = utils.parallelizeDiffLines(file.highlighted_diff_lines, true); + + expect(files[5].left).toEqual(file.parallel_diff_lines[5].left); + expect(files[5].right).toBeNull(); + expect(files[6].left).toBeNull(); + expect(files[6].right).toEqual(file.parallel_diff_lines[5].right); + }); }); });