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
d07ae262
Commit
d07ae262
authored
Mar 22, 2022
by
Sean Arnold
Committed by
Miguel Rincon
Mar 22, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignore search param for autosave on issue new form
Changelog: changed
parent
81f5f80f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
12 deletions
+56
-12
app/assets/javascripts/issuable/issuable_form.js
app/assets/javascripts/issuable/issuable_form.js
+4
-2
app/helpers/issues_helper.rb
app/helpers/issues_helper.rb
+6
-0
app/views/projects/issues/_form.html.haml
app/views/projects/issues/_form.html.haml
+1
-1
spec/frontend/issuable/issuable_form_spec.js
spec/frontend/issuable/issuable_form_spec.js
+35
-9
spec/helpers/issues_helper_spec.rb
spec/helpers/issues_helper_spec.rb
+10
-0
No files found.
app/assets/javascripts/issuable/issuable_form.js
View file @
d07ae262
...
...
@@ -12,6 +12,7 @@ import ZenMode from '~/zen_mode';
const
MR_SOURCE_BRANCH
=
'
merge_request[source_branch]
'
;
const
MR_TARGET_BRANCH
=
'
merge_request[target_branch]
'
;
const
DATA_ISSUES_NEW_PATH
=
'
data-new-issue-path
'
;
function
organizeQuery
(
obj
,
isFallbackKey
=
false
)
{
if
(
!
obj
[
MR_SOURCE_BRANCH
]
&&
!
obj
[
MR_TARGET_BRANCH
])
{
...
...
@@ -68,6 +69,7 @@ export default class IssuableForm {
this
.
reviewersSelect
=
new
UsersSelect
(
undefined
,
'
.js-reviewer-search
'
);
this
.
zenMode
=
new
ZenMode
();
this
.
newIssuePath
=
form
[
0
].
getAttribute
(
DATA_ISSUES_NEW_PATH
);
this
.
titleField
=
this
.
form
.
find
(
'
input[name*="[title]"]
'
);
this
.
descriptionField
=
this
.
form
.
find
(
'
textarea[name*="[description]"]
'
);
if
(
!
(
this
.
titleField
.
length
&&
this
.
descriptionField
.
length
))
{
...
...
@@ -104,8 +106,8 @@ export default class IssuableForm {
}
initAutosave
()
{
const
{
search
}
=
document
.
location
;
const
searchTerm
=
format
(
search
);
const
{
search
,
pathname
}
=
document
.
location
;
const
searchTerm
=
this
.
newIssuePath
===
pathname
?
''
:
format
(
search
);
const
fallbackKey
=
getFallbackKey
();
this
.
autosave
=
new
Autosave
(
...
...
app/helpers/issues_helper.rb
View file @
d07ae262
...
...
@@ -239,6 +239,12 @@ module IssuesHelper
)
end
def
issues_form_data
(
project
)
{
new_issue_path:
new_project_issue_path
(
project
)
}
end
# Overridden in EE
def
scoped_labels_available?
(
parent
)
false
...
...
app/views/projects/issues/_form.html.haml
View file @
d07ae262
=
form_for
[
@project
,
@issue
],
html:
{
class:
'issue-form common-note-form gl-mt-3 js-quick-submit gl-show-field-errors'
}
do
|
f
|
html:
{
class:
'issue-form common-note-form gl-mt-3 js-quick-submit gl-show-field-errors'
,
data:
issues_form_data
(
@project
)
}
do
|
f
|
=
render
'shared/issuable/form'
,
f:
f
,
issuable:
@issue
spec/frontend/issuable/issuable_form_spec.js
View file @
d07ae262
import
$
from
'
jquery
'
;
import
IssuableForm
from
'
~/issuable/issuable_form
'
;
function
createIssuable
()
{
const
instance
=
new
IssuableForm
(
$
(
document
.
createElement
(
'
form
'
)));
instance
.
titleField
=
$
(
document
.
createElement
(
'
input
'
));
return
instance
;
}
import
setWindowLocation
from
'
helpers/set_window_location_helper
'
;
describe
(
'
IssuableForm
'
,
()
=>
{
let
instance
;
const
createIssuable
=
(
form
)
=>
{
instance
=
new
IssuableForm
(
form
);
};
beforeEach
(()
=>
{
instance
=
createIssuable
();
setFixtures
(
`
<form>
<input name="[title]" />
</form>
`
);
createIssuable
(
$
(
'
form
'
));
});
describe
(
'
initAutosave
'
,
()
=>
{
it
(
'
creates autosave with the searchTerm included
'
,
()
=>
{
setWindowLocation
(
'
https://gitlab.test/foo?bar=true
'
);
const
autosave
=
instance
.
initAutosave
();
expect
(
autosave
.
key
.
includes
(
'
bar=true
'
)).
toBe
(
true
);
});
it
(
"
creates autosave fields without the searchTerm if it's an issue new form
"
,
()
=>
{
setFixtures
(
`
<form data-new-issue-path="/issues/new">
<input name="[title]" />
</form>
`
);
createIssuable
(
$
(
'
form
'
));
setWindowLocation
(
'
https://gitlab.test/issues/new?bar=true
'
);
const
autosave
=
instance
.
initAutosave
();
expect
(
autosave
.
key
.
includes
(
'
bar=true
'
)).
toBe
(
false
);
});
});
describe
(
'
removeWip
'
,
()
=>
{
...
...
spec/helpers/issues_helper_spec.rb
View file @
d07ae262
...
...
@@ -368,6 +368,16 @@ RSpec.describe IssuesHelper do
end
end
describe
'#issues_form_data'
do
it
'returns expected result'
do
expected
=
{
new_issue_path:
new_project_issue_path
(
project
)
}
expect
(
helper
.
issues_form_data
(
project
)).
to
include
(
expected
)
end
end
describe
'#issue_manual_ordering_class'
do
context
'when sorting by relative position'
do
before
do
...
...
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