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
003adefd
Commit
003adefd
authored
May 18, 2021
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove dynamic haml-generated js from admin labels
parent
91d1c713
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
8 deletions
+23
-8
app/assets/javascripts/pages/admin/labels/index/index.js
app/assets/javascripts/pages/admin/labels/index/index.js
+20
-2
app/controllers/admin/labels_controller.rb
app/controllers/admin/labels_controller.rb
+1
-1
app/views/admin/labels/_label.html.haml
app/views/admin/labels/_label.html.haml
+1
-1
app/views/admin/labels/destroy.js.haml
app/views/admin/labels/destroy.js.haml
+0
-3
spec/features/admin/admin_labels_spec.rb
spec/features/admin/admin_labels_spec.rb
+1
-1
No files found.
app/assets/javascripts/pages/admin/labels/index/index.js
View file @
003adefd
import
initDeprecatedRemoveRowBehavior
from
'
~/behaviors/deprecated_remove_row_behavior
'
;
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
const
pagination
=
document
.
querySelector
(
'
.labels .gl-pagination
'
);
const
emptyState
=
document
.
querySelector
(
'
.labels .nothing-here-block.hidden
'
);
document
.
addEventListener
(
'
DOMContentLoaded
'
,
initDeprecatedRemoveRowBehavior
);
function
removeLabelSuccessCallback
()
{
this
.
closest
(
'
li
'
).
classList
.
add
(
'
gl-display-none!
'
);
const
labelsCount
=
document
.
querySelectorAll
(
'
ul.manage-labels-list li:not(.gl-display-none
\\
!)
'
,
).
length
;
// display the empty state if there are no more labels
if
(
labelsCount
<
1
&&
!
pagination
&&
emptyState
)
{
emptyState
.
classList
.
remove
(
'
hidden
'
);
}
}
document
.
querySelectorAll
(
'
.js-remove-label
'
).
forEach
((
row
)
=>
{
row
.
addEventListener
(
'
ajax:success
'
,
removeLabelSuccessCallback
);
});
});
app/controllers/admin/labels_controller.rb
View file @
003adefd
...
@@ -47,7 +47,7 @@ class Admin::LabelsController < Admin::ApplicationController
...
@@ -47,7 +47,7 @@ class Admin::LabelsController < Admin::ApplicationController
format
.
html
do
format
.
html
do
redirect_to
admin_labels_path
,
status: :found
,
notice:
_
(
'Label was removed'
)
redirect_to
admin_labels_path
,
status: :found
,
notice:
_
(
'Label was removed'
)
end
end
format
.
js
format
.
js
{
head
:ok
}
end
end
end
end
...
...
app/views/admin/labels/_label.html.haml
View file @
003adefd
...
@@ -3,5 +3,5 @@
...
@@ -3,5 +3,5 @@
.label-actions-list
.label-actions-list
=
link_to
edit_admin_label_path
(
label
),
class:
'btn btn-default gl-button btn-default-tertiary label-action has-tooltip'
,
title:
_
(
'Edit'
),
data:
{
placement:
'bottom'
},
aria_label:
_
(
'Edit'
)
do
=
link_to
edit_admin_label_path
(
label
),
class:
'btn btn-default gl-button btn-default-tertiary label-action has-tooltip'
,
title:
_
(
'Edit'
),
data:
{
placement:
'bottom'
},
aria_label:
_
(
'Edit'
)
do
=
sprite_icon
(
'pencil'
)
=
sprite_icon
(
'pencil'
)
=
link_to
admin_label_path
(
label
),
class:
'btn btn-default gl-button btn-default-tertiary hover-red js-remove-
row
label-action has-tooltip'
,
title:
_
(
'Delete'
),
data:
{
placement:
'bottom'
,
confirm:
"Delete this label? Are you sure?"
},
aria_label:
_
(
'Delete'
),
method: :delete
,
remote:
true
do
=
link_to
admin_label_path
(
label
),
class:
'btn btn-default gl-button btn-default-tertiary hover-red js-remove-
label
label-action has-tooltip'
,
title:
_
(
'Delete'
),
data:
{
placement:
'bottom'
,
confirm:
"Delete this label? Are you sure?"
},
aria_label:
_
(
'Delete'
),
method: :delete
,
remote:
true
do
=
sprite_icon
(
'remove'
)
=
sprite_icon
(
'remove'
)
app/views/admin/labels/destroy.js.haml
deleted
100644 → 0
View file @
91d1c713
-
if
@labels
.
size
==
0
var emptyState = document.querySelector('.labels .nothing-here-block.hidden');
if (emptyState) emptyState.classList.remove('hidden');
spec/features/admin/admin_labels_spec.rb
View file @
003adefd
...
@@ -36,7 +36,7 @@ RSpec.describe 'admin issues labels' do
...
@@ -36,7 +36,7 @@ RSpec.describe 'admin issues labels' do
it
'deletes all labels'
,
:js
do
it
'deletes all labels'
,
:js
do
page
.
within
'.labels'
do
page
.
within
'.labels'
do
page
.
all
(
'.js-remove-
row
'
).
each
do
|
remove
|
page
.
all
(
'.js-remove-
label
'
).
each
do
|
remove
|
accept_confirm
{
remove
.
click
}
accept_confirm
{
remove
.
click
}
wait_for_requests
wait_for_requests
end
end
...
...
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