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
95994503
Commit
95994503
authored
Feb 05, 2018
by
Clement Ho
Committed by
Fatih Acet
Feb 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace $.ajax in admin broadcast messages with axios
parent
3cb7b472
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
8 deletions
+15
-8
app/assets/javascripts/pages/admin/broadcast_messages/broadcast_message.js
...ripts/pages/admin/broadcast_messages/broadcast_message.js
+11
-6
app/controllers/admin/broadcast_messages_controller.rb
app/controllers/admin/broadcast_messages_controller.rb
+4
-1
app/views/admin/broadcast_messages/preview.js.haml
app/views/admin/broadcast_messages/preview.js.haml
+0
-1
No files found.
app/assets/javascripts/pages/admin/broadcast_messages/broadcast_message.js
View file @
95994503
import
_
from
'
underscore
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
flash
from
'
~/flash
'
;
import
{
__
}
from
'
~/locale
'
;
export
default
function
initBroadcastMessagesForm
()
{
$
(
'
input#broadcast_message_color
'
).
on
(
'
input
'
,
function
onMessageColorInput
()
{
...
...
@@ -18,13 +21,15 @@ export default function initBroadcastMessagesForm() {
if
(
message
===
''
)
{
$
(
'
.js-broadcast-message-preview
'
).
text
(
'
Your message here
'
);
}
else
{
$
.
ajax
({
url
:
previewPath
,
type
:
'
POST
'
,
data
:
{
broadcast_message
:
{
message
},
axios
.
post
(
previewPath
,
{
broadcast_message
:
{
message
,
},
});
})
.
then
(({
data
})
=>
{
$
(
'
.js-broadcast-message-preview
'
).
html
(
data
.
message
);
})
.
catch
(()
=>
flash
(
__
(
'
An error occurred while rendering preview broadcast message
'
)));
}
},
250
));
}
app/controllers/admin/broadcast_messages_controller.rb
View file @
95994503
class
Admin::BroadcastMessagesController
<
Admin
::
ApplicationController
include
BroadcastMessagesHelper
before_action
:finder
,
only:
[
:edit
,
:update
,
:destroy
]
def
index
...
...
@@ -37,7 +39,8 @@ class Admin::BroadcastMessagesController < Admin::ApplicationController
end
def
preview
@broadcast_message
=
BroadcastMessage
.
new
(
broadcast_message_params
)
broadcast_message
=
BroadcastMessage
.
new
(
broadcast_message_params
)
render
json:
{
message:
render_broadcast_message
(
broadcast_message
)
}
end
protected
...
...
app/views/admin/broadcast_messages/preview.js.haml
deleted
100644 → 0
View file @
3cb7b472
$('.js-broadcast-message-preview').html("
#{
j
(
render_broadcast_message
(
@broadcast_message
))
}
");
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