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
4add91b6
Commit
4add91b6
authored
Aug 21, 2017
by
Bryce Johnson
Committed by
Clement Ho
Aug 21, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use non-i18n values for setting new group-level issue/MR button text
parent
2db755b3
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
69 additions
and
27 deletions
+69
-27
app/assets/javascripts/project_select_combo_button.js
app/assets/javascripts/project_select_combo_button.js
+20
-13
app/views/dashboard/issues.html.haml
app/views/dashboard/issues.html.haml
+2
-2
app/views/dashboard/merge_requests.html.haml
app/views/dashboard/merge_requests.html.haml
+2
-2
app/views/dashboard/milestones/index.html.haml
app/views/dashboard/milestones/index.html.haml
+2
-2
app/views/groups/issues.html.haml
app/views/groups/issues.html.haml
+2
-2
app/views/groups/merge_requests.html.haml
app/views/groups/merge_requests.html.haml
+2
-2
app/views/shared/_new_project_item_select.html.haml
app/views/shared/_new_project_item_select.html.haml
+1
-1
app/views/shared/empty_states/_issues.html.haml
app/views/shared/empty_states/_issues.html.haml
+1
-1
app/views/shared/empty_states/_merge_requests.html.haml
app/views/shared/empty_states/_merge_requests.html.haml
+1
-1
spec/javascripts/fixtures/project_select_combo_button.html.haml
...avascripts/fixtures/project_select_combo_button.html.haml
+1
-1
spec/javascripts/project_select_combo_button_spec.js
spec/javascripts/project_select_combo_button_spec.js
+35
-0
No files found.
app/assets/javascripts/project_select_combo_button.js
View file @
4add91b6
...
...
@@ -4,10 +4,10 @@ export default class ProjectSelectComboButton {
constructor
(
select
)
{
this
.
projectSelectInput
=
$
(
select
);
this
.
newItemBtn
=
$
(
'
.new-project-item-link
'
);
this
.
newItemBtnBaseText
=
this
.
newItemBtn
.
data
(
'
label
'
);
this
.
itemType
=
this
.
deriveItemTypeFromLabel
();
this
.
resourceType
=
this
.
newItemBtn
.
data
(
'
type
'
);
this
.
resourceLabel
=
this
.
newItemBtn
.
data
(
'
label
'
);
this
.
formattedText
=
this
.
deriveTextVariants
();
this
.
groupId
=
this
.
projectSelectInput
.
data
(
'
groupId
'
);
this
.
bindEvents
();
this
.
initLocalStorage
();
}
...
...
@@ -23,9 +23,7 @@ export default class ProjectSelectComboButton {
const
localStorageIsSafe
=
AccessorUtilities
.
isLocalStorageAccessSafe
();
if
(
localStorageIsSafe
)
{
const
itemTypeKebabed
=
this
.
newItemBtnBaseText
.
toLowerCase
().
split
(
'
'
).
join
(
'
-
'
);
this
.
localStorageKey
=
[
'
group
'
,
this
.
groupId
,
itemTypeKebabed
,
'
recent-project
'
].
join
(
'
-
'
);
this
.
localStorageKey
=
[
'
group
'
,
this
.
groupId
,
this
.
formattedText
.
localStorageItemType
,
'
recent-project
'
].
join
(
'
-
'
);
this
.
setBtnTextFromLocalStorage
();
}
}
...
...
@@ -57,19 +55,14 @@ export default class ProjectSelectComboButton {
setNewItemBtnAttributes
(
project
)
{
if
(
project
)
{
this
.
newItemBtn
.
attr
(
'
href
'
,
project
.
url
);
this
.
newItemBtn
.
text
(
`
${
this
.
newItemBtnBaseText
}
in
${
project
.
name
}
`
);
this
.
newItemBtn
.
text
(
`
${
this
.
formattedText
.
defaultTextPrefix
}
in
${
project
.
name
}
`
);
this
.
newItemBtn
.
enable
();
}
else
{
this
.
newItemBtn
.
text
(
`Select project to create
${
this
.
itemType
}
`
);
this
.
newItemBtn
.
text
(
`Select project to create
${
this
.
formattedText
.
presetTextSuffix
}
`
);
this
.
newItemBtn
.
disable
();
}
}
deriveItemTypeFromLabel
()
{
// label is either 'New issue' or 'New merge request'
return
this
.
newItemBtnBaseText
.
split
(
'
'
).
slice
(
1
).
join
(
'
'
);
}
getProjectFromLocalStorage
()
{
const
projectString
=
localStorage
.
getItem
(
this
.
localStorageKey
);
...
...
@@ -81,5 +74,19 @@ export default class ProjectSelectComboButton {
localStorage
.
setItem
(
this
.
localStorageKey
,
projectString
);
}
deriveTextVariants
()
{
const
defaultTextPrefix
=
this
.
resourceLabel
;
// the trailing slice call depluralizes each of these strings (e.g. new-issues -> new-issue)
const
localStorageItemType
=
`new-
${
this
.
resourceType
.
split
(
'
_
'
).
join
(
'
-
'
).
slice
(
0
,
-
1
)}
`
;
const
presetTextSuffix
=
this
.
resourceType
.
split
(
'
_
'
).
join
(
'
'
).
slice
(
0
,
-
1
);
return
{
localStorageItemType
,
// new-issue / new-merge-request
defaultTextPrefix
,
// New issue / New merge request
presetTextSuffix
,
// issue / merge request
};
}
}
app/views/dashboard/issues.html.haml
View file @
4add91b6
...
...
@@ -8,14 +8,14 @@
-
content_for
:breadcrumbs_extra
do
=
link_to
params
.
merge
(
rss_url_options
),
class:
'btn has-tooltip append-right-10'
,
title:
'Subscribe'
do
=
icon
(
'rss'
)
=
render
'shared/new_project_item_select'
,
path:
'issues/new'
,
label:
"New issue"
,
with_feature_enabled:
'issues'
=
render
'shared/new_project_item_select'
,
path:
'issues/new'
,
label:
"New issue"
,
with_feature_enabled:
'issues'
,
type: :issues
.top-area
=
render
'shared/issuable/nav'
,
type: :issues
.nav-controls
{
class:
(
"visible-xs"
if
show_new_nav?
)
}
=
link_to
params
.
merge
(
rss_url_options
),
class:
'btn has-tooltip'
,
title:
'Subscribe'
do
=
icon
(
'rss'
)
=
render
'shared/new_project_item_select'
,
path:
'issues/new'
,
label:
"New issue"
,
with_feature_enabled:
'issues'
=
render
'shared/new_project_item_select'
,
path:
'issues/new'
,
label:
"New issue"
,
with_feature_enabled:
'issues'
,
type: :issues
=
render
'shared/issuable/filter'
,
type: :issues
=
render
'shared/issues'
app/views/dashboard/merge_requests.html.haml
View file @
4add91b6
...
...
@@ -4,12 +4,12 @@
-
if
show_new_nav?
-
content_for
:breadcrumbs_extra
do
=
render
'shared/new_project_item_select'
,
path:
'merge_requests/new'
,
label:
"New merge request"
,
with_feature_enabled:
'merge_requests'
=
render
'shared/new_project_item_select'
,
path:
'merge_requests/new'
,
label:
"New merge request"
,
with_feature_enabled:
'merge_requests'
,
type: :merge_requests
.top-area
=
render
'shared/issuable/nav'
,
type: :merge_requests
.nav-controls
{
class:
(
"visible-xs"
if
show_new_nav?
)
}
=
render
'shared/new_project_item_select'
,
path:
'merge_requests/new'
,
label:
"New merge request"
,
with_feature_enabled:
'merge_requests'
=
render
'shared/new_project_item_select'
,
path:
'merge_requests/new'
,
label:
"New merge request"
,
with_feature_enabled:
'merge_requests'
,
type: :merge_requests
=
render
'shared/issuable/filter'
,
type: :merge_requests
=
render
'shared/merge_requests'
app/views/dashboard/milestones/index.html.haml
View file @
4add91b6
...
...
@@ -4,13 +4,13 @@
-
if
show_new_nav?
-
content_for
:breadcrumbs_extra
do
=
render
'shared/new_project_item_select'
,
path:
'milestones/new'
,
label:
'New milestone'
,
include_groups:
true
=
render
'shared/new_project_item_select'
,
path:
'milestones/new'
,
label:
'New milestone'
,
include_groups:
true
,
type: :milestones
.top-area
=
render
'shared/milestones_filter'
,
counts:
@milestone_states
.nav-controls
{
class:
(
"visible-xs"
if
show_new_nav?
)
}
=
render
'shared/new_project_item_select'
,
path:
'milestones/new'
,
label:
'New milestone'
,
include_groups:
true
=
render
'shared/new_project_item_select'
,
path:
'milestones/new'
,
label:
'New milestone'
,
include_groups:
true
,
type: :milestones
.milestones
%ul
.content-list
...
...
app/views/groups/issues.html.haml
View file @
4add91b6
...
...
@@ -12,7 +12,7 @@
-
content_for
:breadcrumbs_extra
do
=
link_to
params
.
merge
(
rss_url_options
),
class:
'btn btn-default append-right-10'
do
=
icon
(
'rss'
)
=
render
'shared/new_project_item_select'
,
path:
'issues/new'
,
label:
"New issue"
=
render
'shared/new_project_item_select'
,
path:
'issues/new'
,
label:
"New issue"
,
type: :issues
-
if
group_issues_exists
.top-area
...
...
@@ -22,7 +22,7 @@
=
icon
(
'rss'
)
%span
.icon-label
Subscribe
=
render
'shared/new_project_item_select'
,
path:
'issues/new'
,
label:
"New issue"
=
render
'shared/new_project_item_select'
,
path:
'issues/new'
,
label:
"New issue"
,
type: :issues
=
render
'shared/issuable/search_bar'
,
type: :issues
...
...
app/views/groups/merge_requests.html.haml
View file @
4add91b6
...
...
@@ -2,7 +2,7 @@
-
if
show_new_nav?
&&
current_user
-
content_for
:breadcrumbs_extra
do
=
render
'shared/new_project_item_select'
,
path:
'merge_requests/new'
,
label:
"New merge request"
=
render
'shared/new_project_item_select'
,
path:
'merge_requests/new'
,
label:
"New merge request"
,
type: :merge_requests
-
if
@group_merge_requests
.
empty?
=
render
'shared/empty_states/merge_requests'
,
project_select_button:
true
...
...
@@ -11,7 +11,7 @@
=
render
'shared/issuable/nav'
,
type: :merge_requests
-
if
current_user
.nav-controls
{
class:
(
"visible-xs"
if
show_new_nav?
)
}
=
render
'shared/new_project_item_select'
,
path:
'merge_requests/new'
,
label:
"New merge request"
=
render
'shared/new_project_item_select'
,
path:
'merge_requests/new'
,
label:
"New merge request"
,
type: :merge_requests
=
render
'shared/issuable/filter'
,
type: :merge_requests
...
...
app/views/shared/_new_project_item_select.html.haml
View file @
4add91b6
-
if
any_projects?
(
@projects
)
.project-item-select-holder.btn-group.pull-right
%a
.btn.btn-new.new-project-item-link
{
href:
''
,
data:
{
label:
local_assigns
[
:label
]
}
}
%a
.btn.btn-new.new-project-item-link
{
href:
''
,
data:
{
label:
local_assigns
[
:label
]
,
type:
local_assigns
[
:type
]
}
}
=
icon
(
'spinner spin'
)
=
project_select_tag
:project_path
,
class:
"project-item-select"
,
data:
{
include_groups:
local_assigns
[
:include_groups
],
order_by:
'last_activity_at'
,
relative_path:
local_assigns
[
:path
]
},
with_feature_enabled:
local_assigns
[
:with_feature_enabled
]
%button
.btn.btn-new.new-project-item-select-button
...
...
app/views/shared/empty_states/_issues.html.haml
View file @
4add91b6
...
...
@@ -15,7 +15,7 @@
Issues can be bugs, tasks or ideas to be discussed.
Also, issues are searchable and filterable.
-
if
project_select_button
=
render
'shared/new_project_item_select'
,
path:
'issues/new'
,
label:
'New issue'
=
render
'shared/new_project_item_select'
,
path:
'issues/new'
,
label:
'New issue'
,
type: :issues
-
else
=
link_to
'New issue'
,
button_path
,
class:
'btn btn-new'
,
title:
'New issue'
,
id:
'new_issue_link'
-
else
...
...
app/views/shared/empty_states/_merge_requests.html.haml
View file @
4add91b6
...
...
@@ -14,7 +14,7 @@
%p
Interested parties can even contribute by pushing commits if they want to.
-
if
project_select_button
=
render
'shared/new_project_item_select'
,
path:
'merge_requests/new'
,
label:
'New merge request'
=
render
'shared/new_project_item_select'
,
path:
'merge_requests/new'
,
label:
'New merge request'
,
type: :merge_requests
-
else
=
link_to
'New merge request'
,
button_path
,
class:
'btn btn-new'
,
title:
'New merge request'
,
id:
'new_merge_request_link'
-
else
...
...
spec/javascripts/fixtures/project_select_combo_button.html.haml
View file @
4add91b6
.project-item-select-holder
%input
.project-item-select
{
data:
{
group_id:
'12345'
,
relative_path:
'issues/new'
}
}
%a
.new-project-item-link
{
data:
{
label:
'New issue'
},
href:
''
}
%a
.new-project-item-link
{
data:
{
label:
'New issue'
,
type:
'issues'
},
href:
''
}
%i
.fa.fa-spinner.spin
%a
.new-project-item-select-button
%i
.fa.fa-caret-down
spec/javascripts/project_select_combo_button_spec.js
View file @
4add91b6
...
...
@@ -101,5 +101,40 @@ describe('Project Select Combo Button', function () {
window
.
localStorage
.
clear
();
});
});
describe
(
'
deriveTextVariants
'
,
function
()
{
beforeEach
(
function
()
{
this
.
mockExecutionContext
=
{
resourceType
:
''
,
resourceLabel
:
''
,
};
this
.
comboButton
=
new
ProjectSelectComboButton
(
this
.
projectSelectInput
);
this
.
method
=
this
.
comboButton
.
deriveTextVariants
.
bind
(
this
.
mockExecutionContext
);
});
it
(
'
correctly derives test variants for merge requests
'
,
function
()
{
this
.
mockExecutionContext
.
resourceType
=
'
merge_requests
'
;
this
.
mockExecutionContext
.
resourceLabel
=
'
New merge request
'
;
const
returnedVariants
=
this
.
method
();
expect
(
returnedVariants
.
localStorageItemType
).
toBe
(
'
new-merge-request
'
);
expect
(
returnedVariants
.
defaultTextPrefix
).
toBe
(
'
New merge request
'
);
expect
(
returnedVariants
.
presetTextSuffix
).
toBe
(
'
merge request
'
);
});
it
(
'
correctly derives text variants for issues
'
,
function
()
{
this
.
mockExecutionContext
.
resourceType
=
'
issues
'
;
this
.
mockExecutionContext
.
resourceLabel
=
'
New issue
'
;
const
returnedVariants
=
this
.
method
();
expect
(
returnedVariants
.
localStorageItemType
).
toBe
(
'
new-issue
'
);
expect
(
returnedVariants
.
defaultTextPrefix
).
toBe
(
'
New issue
'
);
expect
(
returnedVariants
.
presetTextSuffix
).
toBe
(
'
issue
'
);
});
});
});
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