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
Show 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';
...
@@ -12,6 +12,7 @@ import ZenMode from '~/zen_mode';
const
MR_SOURCE_BRANCH
=
'
merge_request[source_branch]
'
;
const
MR_SOURCE_BRANCH
=
'
merge_request[source_branch]
'
;
const
MR_TARGET_BRANCH
=
'
merge_request[target_branch]
'
;
const
MR_TARGET_BRANCH
=
'
merge_request[target_branch]
'
;
const
DATA_ISSUES_NEW_PATH
=
'
data-new-issue-path
'
;
function
organizeQuery
(
obj
,
isFallbackKey
=
false
)
{
function
organizeQuery
(
obj
,
isFallbackKey
=
false
)
{
if
(
!
obj
[
MR_SOURCE_BRANCH
]
&&
!
obj
[
MR_TARGET_BRANCH
])
{
if
(
!
obj
[
MR_SOURCE_BRANCH
]
&&
!
obj
[
MR_TARGET_BRANCH
])
{
...
@@ -68,6 +69,7 @@ export default class IssuableForm {
...
@@ -68,6 +69,7 @@ export default class IssuableForm {
this
.
reviewersSelect
=
new
UsersSelect
(
undefined
,
'
.js-reviewer-search
'
);
this
.
reviewersSelect
=
new
UsersSelect
(
undefined
,
'
.js-reviewer-search
'
);
this
.
zenMode
=
new
ZenMode
();
this
.
zenMode
=
new
ZenMode
();
this
.
newIssuePath
=
form
[
0
].
getAttribute
(
DATA_ISSUES_NEW_PATH
);
this
.
titleField
=
this
.
form
.
find
(
'
input[name*="[title]"]
'
);
this
.
titleField
=
this
.
form
.
find
(
'
input[name*="[title]"]
'
);
this
.
descriptionField
=
this
.
form
.
find
(
'
textarea[name*="[description]"]
'
);
this
.
descriptionField
=
this
.
form
.
find
(
'
textarea[name*="[description]"]
'
);
if
(
!
(
this
.
titleField
.
length
&&
this
.
descriptionField
.
length
))
{
if
(
!
(
this
.
titleField
.
length
&&
this
.
descriptionField
.
length
))
{
...
@@ -104,8 +106,8 @@ export default class IssuableForm {
...
@@ -104,8 +106,8 @@ export default class IssuableForm {
}
}
initAutosave
()
{
initAutosave
()
{
const
{
search
}
=
document
.
location
;
const
{
search
,
pathname
}
=
document
.
location
;
const
searchTerm
=
format
(
search
);
const
searchTerm
=
this
.
newIssuePath
===
pathname
?
''
:
format
(
search
);
const
fallbackKey
=
getFallbackKey
();
const
fallbackKey
=
getFallbackKey
();
this
.
autosave
=
new
Autosave
(
this
.
autosave
=
new
Autosave
(
...
...
app/helpers/issues_helper.rb
View file @
d07ae262
...
@@ -239,6 +239,12 @@ module IssuesHelper
...
@@ -239,6 +239,12 @@ module IssuesHelper
)
)
end
end
def
issues_form_data
(
project
)
{
new_issue_path:
new_project_issue_path
(
project
)
}
end
# Overridden in EE
# Overridden in EE
def
scoped_labels_available?
(
parent
)
def
scoped_labels_available?
(
parent
)
false
false
...
...
app/views/projects/issues/_form.html.haml
View file @
d07ae262
=
form_for
[
@project
,
@issue
],
=
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
=
render
'shared/issuable/form'
,
f:
f
,
issuable:
@issue
spec/frontend/issuable/issuable_form_spec.js
View file @
d07ae262
import
$
from
'
jquery
'
;
import
$
from
'
jquery
'
;
import
IssuableForm
from
'
~/issuable/issuable_form
'
;
import
IssuableForm
from
'
~/issuable/issuable_form
'
;
import
setWindowLocation
from
'
helpers/set_window_location_helper
'
;
function
createIssuable
()
{
const
instance
=
new
IssuableForm
(
$
(
document
.
createElement
(
'
form
'
)));
instance
.
titleField
=
$
(
document
.
createElement
(
'
input
'
));
return
instance
;
}
describe
(
'
IssuableForm
'
,
()
=>
{
describe
(
'
IssuableForm
'
,
()
=>
{
let
instance
;
let
instance
;
const
createIssuable
=
(
form
)
=>
{
instance
=
new
IssuableForm
(
form
);
};
beforeEach
(()
=>
{
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
'
,
()
=>
{
describe
(
'
removeWip
'
,
()
=>
{
...
...
spec/helpers/issues_helper_spec.rb
View file @
d07ae262
...
@@ -368,6 +368,16 @@ RSpec.describe IssuesHelper do
...
@@ -368,6 +368,16 @@ RSpec.describe IssuesHelper do
end
end
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
describe
'#issue_manual_ordering_class'
do
context
'when sorting by relative position'
do
context
'when sorting by relative position'
do
before
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