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
1f0b9525
Commit
1f0b9525
authored
Sep 01, 2020
by
Tom Quirk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename parseDesignRouteHash function
Rename it to extractDesignNoteId
parent
dc510fbf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
13 deletions
+13
-13
app/assets/javascripts/design_management/pages/design/index.vue
...sets/javascripts/design_management/pages/design/index.vue
+2
-2
app/assets/javascripts/design_management/utils/design_management_utils.js
...cripts/design_management/utils/design_management_utils.js
+4
-4
spec/frontend/design_management/utils/design_management_utils_spec.js
...d/design_management/utils/design_management_utils_spec.js
+7
-7
No files found.
app/assets/javascripts/design_management/pages/design/index.vue
View file @
1f0b9525
...
...
@@ -20,7 +20,7 @@ import {
extractDesign
,
updateImageDiffNoteOptimisticResponse
,
toDiffNoteGid
,
parseDesignRouteHash
,
extractDesignNoteId
,
}
from
'
../../utils/design_management_utils
'
;
import
{
updateStoreAfterAddImageDiffNote
,
...
...
@@ -281,7 +281,7 @@ export default {
});
},
updateActiveDiscussionFromUrl
()
{
const
noteId
=
parseDesignRouteHash
(
this
.
$route
.
hash
);
const
noteId
=
extractDesignNoteId
(
this
.
$route
.
hash
);
const
diffNoteGid
=
noteId
?
toDiffNoteGid
(
noteId
)
:
undefined
;
return
this
.
updateActiveDiscussion
(
diffNoteGid
,
ACTIVE_DISCUSSION_SOURCE_TYPES
.
url
);
},
...
...
app/assets/javascripts/design_management/utils/design_management_utils.js
View file @
1f0b9525
...
...
@@ -38,11 +38,11 @@ export const toDiffNoteGid = noteId => `gid://gitlab/DiffNote/${noteId}`;
/**
* Return the note ID from a URL hash parameter
* @param {String}
hash URL hash
* @param {String}
urlHash URL hash, including `#` prefix
*/
export
const
parseDesignRouteHash
=
h
ash
=>
{
const
[,
noteId
]
=
h
ash
.
match
(
'
#note_([0-9]+$)
'
)
||
[];
return
noteId
;
export
const
extractDesignNoteId
=
urlH
ash
=>
{
const
[,
noteId
]
=
urlH
ash
.
match
(
'
#note_([0-9]+$)
'
)
||
[];
return
noteId
||
null
;
};
/**
...
...
spec/frontend/design_management/utils/design_management_utils_spec.js
View file @
1f0b9525
...
...
@@ -6,7 +6,7 @@ import {
updateImageDiffNoteOptimisticResponse
,
isValidDesignFile
,
extractDesign
,
parseDesignRouteHash
,
extractDesignNoteId
,
}
from
'
~/design_management/utils/design_management_utils
'
;
import
mockResponseNoDesigns
from
'
../mock_data/no_designs
'
;
import
mockResponseWithDesigns
from
'
../mock_data/designs
'
;
...
...
@@ -173,18 +173,18 @@ describe('extractDesign', () => {
});
});
describe
(
'
parseDesignRouteHash
'
,
()
=>
{
describe
(
'
extractDesignNoteId
'
,
()
=>
{
it
.
each
`
hash | expectedNoteId
${
'
#note_0
'
}
|
${
'
0
'
}
${
'
#note_1
'
}
|
${
'
1
'
}
${
'
#note_23
'
}
|
${
'
23
'
}
${
'
#note_456
'
}
|
${
'
456
'
}
${
'
note_1
'
}
|
${
undefined
}
${
'
#note_
'
}
|
${
undefined
}
${
'
#note_asd
'
}
|
${
undefined
}
${
'
#note_1asd
'
}
|
${
undefined
}
${
'
note_1
'
}
|
${
null
}
${
'
#note_
'
}
|
${
null
}
${
'
#note_asd
'
}
|
${
null
}
${
'
#note_1asd
'
}
|
${
null
}
`
(
'
returns $expectedNoteId when hash is $hash
'
,
({
hash
,
expectedNoteId
})
=>
{
expect
(
parseDesignRouteHash
(
hash
)).
toBe
(
expectedNoteId
);
expect
(
extractDesignNoteId
(
hash
)).
toBe
(
expectedNoteId
);
});
});
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