Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
14cca608
Commit
14cca608
authored
Sep 12, 2019
by
Lee Tickett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add user preference for configuring default whitespace display in diffs
parent
c7b2e996
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
46 additions
and
3 deletions
+46
-3
app/assets/javascripts/diffs/index.js
app/assets/javascripts/diffs/index.js
+7
-1
app/controllers/profiles/preferences_controller.rb
app/controllers/profiles/preferences_controller.rb
+2
-1
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+1
-0
app/models/user.rb
app/models/user.rb
+1
-0
app/views/profiles/preferences/show.html.haml
app/views/profiles/preferences/show.html.haml
+4
-0
app/views/projects/merge_requests/show.html.haml
app/views/projects/merge_requests/show.html.haml
+2
-1
db/migrate/20190907184714_add_show_whitespace_in_diffs_to_user_preferences.rb
...84714_add_show_whitespace_in_diffs_to_user_preferences.rb
+20
-0
db/schema.rb
db/schema.rb
+1
-0
ee/changelogs/unreleased/set-default-whitespace-diff.yml
ee/changelogs/unreleased/set-default-whitespace-diff.yml
+5
-0
locale/gitlab.pot
locale/gitlab.pot
+3
-0
No files found.
app/assets/javascripts/diffs/index.js
View file @
14cca608
...
@@ -74,6 +74,7 @@ export default function initDiffsApp(store) {
...
@@ -74,6 +74,7 @@ export default function initDiffsApp(store) {
isFluidLayout
:
parseBoolean
(
dataset
.
isFluidLayout
),
isFluidLayout
:
parseBoolean
(
dataset
.
isFluidLayout
),
dismissEndpoint
:
dataset
.
dismissEndpoint
,
dismissEndpoint
:
dataset
.
dismissEndpoint
,
showSuggestPopover
:
parseBoolean
(
dataset
.
showSuggestPopover
),
showSuggestPopover
:
parseBoolean
(
dataset
.
showSuggestPopover
),
showWhitespaceDefault
:
parseBoolean
(
dataset
.
showWhitespaceDefault
),
};
};
},
},
computed
:
{
computed
:
{
...
@@ -82,11 +83,15 @@ export default function initDiffsApp(store) {
...
@@ -82,11 +83,15 @@ export default function initDiffsApp(store) {
}),
}),
},
},
created
()
{
created
()
{
let
hideWhitespace
=
getParameterValues
(
'
w
'
)[
0
];
const
treeListStored
=
localStorage
.
getItem
(
TREE_LIST_STORAGE_KEY
);
const
treeListStored
=
localStorage
.
getItem
(
TREE_LIST_STORAGE_KEY
);
const
renderTreeList
=
treeListStored
!==
null
?
parseBoolean
(
treeListStored
)
:
true
;
const
renderTreeList
=
treeListStored
!==
null
?
parseBoolean
(
treeListStored
)
:
true
;
this
.
setRenderTreeList
(
renderTreeList
);
this
.
setRenderTreeList
(
renderTreeList
);
this
.
setShowWhitespace
({
showWhitespace
:
getParameterValues
(
'
w
'
)[
0
]
!==
'
1
'
});
if
(
!
hideWhitespace
)
{
hideWhitespace
=
this
.
showWhitespaceDefault
?
'
0
'
:
'
1
'
;
}
this
.
setShowWhitespace
({
showWhitespace
:
hideWhitespace
!==
'
1
'
});
},
},
methods
:
{
methods
:
{
...
mapActions
(
'
diffs
'
,
[
'
setRenderTreeList
'
,
'
setShowWhitespace
'
]),
...
mapActions
(
'
diffs
'
,
[
'
setRenderTreeList
'
,
'
setShowWhitespace
'
]),
...
@@ -103,6 +108,7 @@ export default function initDiffsApp(store) {
...
@@ -103,6 +108,7 @@ export default function initDiffsApp(store) {
isFluidLayout
:
this
.
isFluidLayout
,
isFluidLayout
:
this
.
isFluidLayout
,
dismissEndpoint
:
this
.
dismissEndpoint
,
dismissEndpoint
:
this
.
dismissEndpoint
,
showSuggestPopover
:
this
.
showSuggestPopover
,
showSuggestPopover
:
this
.
showSuggestPopover
,
showWhitespaceDefault
:
this
.
showWhitespaceDefault
,
},
},
});
});
},
},
...
...
app/controllers/profiles/preferences_controller.rb
View file @
14cca608
...
@@ -46,7 +46,8 @@ class Profiles::PreferencesController < Profiles::ApplicationController
...
@@ -46,7 +46,8 @@ class Profiles::PreferencesController < Profiles::ApplicationController
:first_day_of_week
,
:first_day_of_week
,
:preferred_language
,
:preferred_language
,
:time_display_relative
,
:time_display_relative
,
:time_format_in_24h
:time_format_in_24h
,
:show_whitespace_in_diffs
]
]
end
end
end
end
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
14cca608
...
@@ -48,6 +48,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
...
@@ -48,6 +48,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
@commits_count
=
@merge_request
.
commits_count
@commits_count
=
@merge_request
.
commits_count
@issuable_sidebar
=
serializer
.
represent
(
@merge_request
,
serializer:
'sidebar'
)
@issuable_sidebar
=
serializer
.
represent
(
@merge_request
,
serializer:
'sidebar'
)
@current_user_data
=
UserSerializer
.
new
(
project:
@project
).
represent
(
current_user
,
{},
MergeRequestUserEntity
).
to_json
@current_user_data
=
UserSerializer
.
new
(
project:
@project
).
represent
(
current_user
,
{},
MergeRequestUserEntity
).
to_json
@show_whitespace_default
=
current_user
.
nil?
||
current_user
.
show_whitespace_in_diffs
set_pipeline_variables
set_pipeline_variables
...
...
app/models/user.rb
View file @
14cca608
...
@@ -235,6 +235,7 @@ class User < ApplicationRecord
...
@@ -235,6 +235,7 @@ class User < ApplicationRecord
delegate
:timezone
,
:timezone
=
,
to: :user_preference
delegate
:timezone
,
:timezone
=
,
to: :user_preference
delegate
:time_display_relative
,
:time_display_relative
=
,
to: :user_preference
delegate
:time_display_relative
,
:time_display_relative
=
,
to: :user_preference
delegate
:time_format_in_24h
,
:time_format_in_24h
=
,
to: :user_preference
delegate
:time_format_in_24h
,
:time_format_in_24h
=
,
to: :user_preference
delegate
:show_whitespace_in_diffs
,
:show_whitespace_in_diffs
=
,
to: :user_preference
accepts_nested_attributes_for
:user_preference
,
update_only:
true
accepts_nested_attributes_for
:user_preference
,
update_only:
true
...
...
app/views/profiles/preferences/show.html.haml
View file @
14cca608
...
@@ -61,6 +61,10 @@
...
@@ -61,6 +61,10 @@
=
f
.
select
:project_view
,
project_view_choices
,
{},
class:
'select2'
=
f
.
select
:project_view
,
project_view_choices
,
{},
class:
'select2'
.form-text.text-muted
.form-text.text-muted
=
s_
(
'Preferences|Choose what content you want to see on a project’s overview page.'
)
=
s_
(
'Preferences|Choose what content you want to see on a project’s overview page.'
)
.form-group.form-check
=
f
.
check_box
:show_whitespace_in_diffs
,
class:
'form-check-input'
=
f
.
label
:show_whitespace_in_diffs
,
class:
'form-check-label'
do
=
s_
(
'Preferences|Show whitespace in diffs'
)
.col-sm-12
.col-sm-12
%hr
%hr
...
...
app/views/projects/merge_requests/show.html.haml
View file @
14cca608
...
@@ -83,7 +83,8 @@
...
@@ -83,7 +83,8 @@
changes_empty_state_illustration:
image_path
(
'illustrations/merge_request_changes_empty.svg'
),
changes_empty_state_illustration:
image_path
(
'illustrations/merge_request_changes_empty.svg'
),
is_fluid_layout:
fluid_layout
.
to_s
,
is_fluid_layout:
fluid_layout
.
to_s
,
dismiss_endpoint:
user_callouts_path
,
dismiss_endpoint:
user_callouts_path
,
show_suggest_popover:
show_suggest_popover?
.
to_s
}
}
show_suggest_popover:
show_suggest_popover?
.
to_s
,
show_whitespace_default:
@show_whitespace_default
.
to_s
}
}
.mr-loading-status
.mr-loading-status
=
spinner
=
spinner
...
...
db/migrate/20190907184714_add_show_whitespace_in_diffs_to_user_preferences.rb
0 → 100644
View file @
14cca608
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
AddShowWhitespaceInDiffsToUserPreferences
<
ActiveRecord
::
Migration
[
5.2
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
add_column_with_default
:user_preferences
,
:show_whitespace_in_diffs
,
:boolean
,
default:
true
,
allow_null:
false
end
def
down
remove_column
:user_preferences
,
:show_whitespace_in_diffs
end
end
db/schema.rb
View file @
14cca608
...
@@ -3467,6 +3467,7 @@ ActiveRecord::Schema.define(version: 2019_09_12_061145) do
...
@@ -3467,6 +3467,7 @@ ActiveRecord::Schema.define(version: 2019_09_12_061145) do
t
.
boolean
"time_display_relative"
t
.
boolean
"time_display_relative"
t
.
boolean
"time_format_in_24h"
t
.
boolean
"time_format_in_24h"
t
.
string
"projects_sort"
,
limit:
64
t
.
string
"projects_sort"
,
limit:
64
t
.
boolean
"show_whitespace_in_diffs"
,
default:
true
,
null:
false
t
.
index
[
"user_id"
],
name:
"index_user_preferences_on_user_id"
,
unique:
true
t
.
index
[
"user_id"
],
name:
"index_user_preferences_on_user_id"
,
unique:
true
end
end
...
...
ee/changelogs/unreleased/set-default-whitespace-diff.yml
0 → 100644
View file @
14cca608
---
title
:
Set default whitespace diff behaviour
merge_request
:
16570
author
:
Lee Tickett
type
:
added
locale/gitlab.pot
View file @
14cca608
...
@@ -11302,6 +11302,9 @@ msgstr ""
...
@@ -11302,6 +11302,9 @@ msgstr ""
msgid "Preferences|Project overview content"
msgid "Preferences|Project overview content"
msgstr ""
msgstr ""
msgid "Preferences|Show whitespace in diffs"
msgstr ""
msgid "Preferences|Syntax highlighting theme"
msgid "Preferences|Syntax highlighting theme"
msgstr ""
msgstr ""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment