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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
b172ef2f
Commit
b172ef2f
authored
May 26, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restore notifications to MR widget
parent
8f2af757
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
43 deletions
+53
-43
app/assets/javascripts/lib/utils/notify.js
app/assets/javascripts/lib/utils/notify.js
+37
-42
app/assets/javascripts/main.js
app/assets/javascripts/main.js
+0
-1
app/assets/javascripts/vue_merge_request_widget/dependencies.js
...sets/javascripts/vue_merge_request_widget/dependencies.js
+1
-0
app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js
...javascripts/vue_merge_request_widget/mr_widget_options.js
+12
-0
app/assets/javascripts/vue_merge_request_widget/stores/mr_widget_store.js
...cripts/vue_merge_request_widget/stores/mr_widget_store.js
+2
-0
lib/gitlab/gon_helper.rb
lib/gitlab/gon_helper.rb
+1
-0
No files found.
app/assets/javascripts/lib/utils/notify.js
View file @
b172ef2f
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, one-var, one-var-declaration-per-line, consistent-return, prefer-arrow-callback, no-return-assign, object-shorthand, comma-dangle, no-param-reassign, max-len */
(
function
()
{
(
function
(
w
)
{
var
notificationGranted
,
notifyMe
,
notifyPermissions
;
notificationGranted
=
function
(
message
,
opts
,
onclick
)
{
var
notification
;
notification
=
new
Notification
(
message
,
opts
);
setTimeout
(
function
()
{
return
notification
.
close
();
// Hide the notification after X amount of seconds
},
8000
);
if
(
onclick
)
{
return
notification
.
onclick
=
onclick
;
}
};
notifyPermissions
=
function
()
{
if
(
'
Notification
'
in
window
)
{
return
Notification
.
requestPermission
();
}
};
notifyMe
=
function
(
message
,
body
,
icon
,
onclick
)
{
var
opts
;
opts
=
{
body
:
body
,
icon
:
icon
};
// Let's check if the browser supports notifications
if
(
!
(
'
Notification
'
in
window
))
{
function
notificationGranted
(
message
,
opts
,
onclick
)
{
var
notification
;
notification
=
new
Notification
(
message
,
opts
);
setTimeout
(
function
()
{
// Hide the notification after X amount of seconds
return
notification
.
close
();
},
8000
);
return
notification
.
onclick
=
onclick
||
notification
.
close
;
}
// do nothing
}
else
if
(
Notification
.
permission
===
'
granted
'
)
{
// If it's okay let's create a notification
function
notifyPermissions
()
{
if
(
'
Notification
'
in
window
)
{
return
Notification
.
requestPermission
();
}
}
function
notifyMe
(
message
,
body
,
icon
,
onclick
)
{
var
opts
;
opts
=
{
body
:
body
,
icon
:
icon
};
// Let's check if the browser supports notifications
if
(
!
(
'
Notification
'
in
window
))
{
// do nothing
}
else
if
(
Notification
.
permission
===
'
granted
'
)
{
// If it's okay let's create a notification
return
notificationGranted
(
message
,
opts
,
onclick
);
}
else
if
(
Notification
.
permission
!==
'
denied
'
)
{
return
Notification
.
requestPermission
(
function
(
permission
)
{
// If the user accepts, let's create a notification
if
(
permission
===
'
granted
'
)
{
return
notificationGranted
(
message
,
opts
,
onclick
);
}
else
if
(
Notification
.
permission
!==
'
denied
'
)
{
return
Notification
.
requestPermission
(
function
(
permission
)
{
// If the user accepts, let's create a notification
if
(
permission
===
'
granted
'
)
{
return
notificationGranted
(
message
,
opts
,
onclick
);
}
});
}
};
w
.
notify
=
notifyMe
;
return
w
.
notifyPermissions
=
notifyPermissions
;
})(
window
);
}).
call
(
window
)
;
}
)
;
}
}
export
{
notifyMe
as
default
,
notifyPermissions
,
notificationGranted
}
;
app/assets/javascripts/main.js
View file @
b172ef2f
...
...
@@ -56,7 +56,6 @@ import './lib/utils/animate';
import
'
./lib/utils/bootstrap_linked_tabs
'
;
import
'
./lib/utils/common_utils
'
;
import
'
./lib/utils/datetime_utility
'
;
import
'
./lib/utils/notify
'
;
import
'
./lib/utils/pretty_time
'
;
import
'
./lib/utils/text_utility
'
;
import
'
./lib/utils/url_utility
'
;
...
...
app/assets/javascripts/vue_merge_request_widget/dependencies.js
View file @
b172ef2f
...
...
@@ -41,3 +41,4 @@ export { default as getStateKey } from './stores/get_state_key';
export
{
default
as
mrWidgetOptions
}
from
'
./mr_widget_options
'
;
export
{
default
as
stateMaps
}
from
'
./stores/state_maps
'
;
export
{
default
as
SquashBeforeMerge
}
from
'
./components/states/mr_widget_squash_before_merge
'
;
export
{
default
as
notifyMe
}
from
'
../lib/utils/notify
'
;
app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js
View file @
b172ef2f
...
...
@@ -29,6 +29,7 @@ import {
eventHub
,
stateMaps
,
SquashBeforeMerge
,
notifyMe
,
}
from
'
./dependencies
'
;
export
default
{
...
...
@@ -77,8 +78,10 @@ export default {
this
.
service
.
checkStatus
()
.
then
(
res
=>
res
.
json
())
.
then
((
res
)
=>
{
this
.
handleNotification
(
res
);
this
.
mr
.
setData
(
res
);
this
.
setFavicon
();
if
(
cb
)
{
cb
.
call
(
null
,
res
);
}
...
...
@@ -136,6 +139,15 @@ export default {
new
Flash
(
'
Something went wrong. Please try again.
'
);
// eslint-disable-line
});
},
handleNotification
(
data
)
{
if
(
data
.
ci_status
===
this
.
mr
.
ciStatus
)
return
;
const
label
=
data
.
pipeline
.
details
.
status
.
label
;
const
title
=
`Pipeline
${
label
}
`
;
const
message
=
`Pipeline
${
label
}
for "
${
data
.
title
}
"`
;
notifyMe
(
title
,
message
,
this
.
mr
.
gitlabLogo
);
},
resumePolling
()
{
this
.
pollingInterval
.
resume
();
},
...
...
app/assets/javascripts/vue_merge_request_widget/stores/mr_widget_store.js
View file @
b172ef2f
...
...
@@ -5,6 +5,8 @@ export default class MergeRequestStore {
constructor
(
data
)
{
this
.
sha
=
data
.
diff_head_sha
;
this
.
gitlabLogo
=
gon
.
gitlab_logo
;
this
.
setData
(
data
);
}
...
...
lib/gitlab/gon_helper.rb
View file @
b172ef2f
...
...
@@ -13,6 +13,7 @@ module Gitlab
gon
.
sentry_dsn
=
current_application_settings
.
clientside_sentry_dsn
if
current_application_settings
.
clientside_sentry_enabled
gon
.
gitlab_url
=
Gitlab
.
config
.
gitlab
.
url
gon
.
revision
=
Gitlab
::
REVISION
gon
.
gitlab_logo
=
ActionController
::
Base
.
helpers
.
asset_path
(
'gitlab_logo.png'
)
if
current_user
gon
.
current_user_id
=
current_user
.
id
...
...
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