Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gpt
large_projects
gitlabhq1
Commits
75434a33
Commit
75434a33
authored
7 years ago
by
Jose
Browse files
Options
Download
Email Patches
Plain Diff
Fix close merge request button text
parent
62078e6e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
2 deletions
+21
-2
app/assets/javascripts/lib/utils/text_utility.js
app/assets/javascripts/lib/utils/text_utility.js
+13
-0
app/assets/javascripts/notes/components/comment_form.vue
app/assets/javascripts/notes/components/comment_form.vue
+2
-2
spec/javascripts/lib/utils/text_utility_spec.js
spec/javascripts/lib/utils/text_utility_spec.js
+6
-0
No files found.
app/assets/javascripts/lib/utils/text_utility.js
View file @
75434a33
...
...
@@ -102,3 +102,16 @@ export const convertToSentenceCase = string => {
return
splitWord
.
join
(
'
'
);
};
/**
* Splits camelCase or PascalCase words
* e.g. HelloWorld => Hello World
*
* @param {*} string
*/
export
const
splitCamelCase
=
string
=>
(
string
.
replace
(
/
([
A-Z
]
+
)([
A-Z
][
a-z
])
/g
,
'
$1 $2
'
)
.
replace
(
/
([
a-z
\d])([
A-Z
])
/g
,
'
$1 $2
'
)
.
trim
()
);
This diff is collapsed.
Click to expand it.
app/assets/javascripts/notes/components/comment_form.vue
View file @
75434a33
...
...
@@ -7,7 +7,7 @@ import { __, sprintf } from '~/locale';
import
Flash
from
'
../../flash
'
;
import
Autosave
from
'
../../autosave
'
;
import
TaskList
from
'
../../task_list
'
;
import
{
capitalizeFirstCharacter
,
convertToCamelCase
}
from
'
../../lib/utils/text_utility
'
;
import
{
capitalizeFirstCharacter
,
convertToCamelCase
,
splitCamelCase
}
from
'
../../lib/utils/text_utility
'
;
import
*
as
constants
from
'
../constants
'
;
import
eventHub
from
'
../event_hub
'
;
import
issueWarning
from
'
../../vue_shared/components/issue/issue_warning.vue
'
;
...
...
@@ -53,7 +53,7 @@ export default {
]),
...
mapState
([
'
isToggleStateButtonLoading
'
]),
noteableDisplayName
()
{
return
this
.
noteableType
.
replace
(
/_/g
,
'
'
);
return
splitCamelCase
(
this
.
noteableType
).
toLowerCase
(
);
},
isLoggedIn
()
{
return
this
.
getUserData
.
id
;
...
...
This diff is collapsed.
Click to expand it.
spec/javascripts/lib/utils/text_utility_spec.js
View file @
75434a33
...
...
@@ -98,4 +98,10 @@ describe('text_utility', () => {
expect
(
textUtils
.
truncateSha
(
'
shortsha
'
)).
toBe
(
'
shortsha
'
);
});
});
describe
(
'
splitCamelCase
'
,
()
=>
{
it
(
'
separates a PascalCase word to two
'
,
()
=>
{
expect
(
textUtils
.
splitCamelCase
(
'
HelloWorld
'
)).
toBe
(
'
Hello World
'
);
});
});
});
This diff is collapsed.
Click to expand it.
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