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
Léo-Paul Géneau
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 */
/* 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
notificationGranted
(
message
,
opts
,
onclick
)
{
(
function
(
w
)
{
var
notification
;
var
notificationGranted
,
notifyMe
,
notifyPermissions
;
notification
=
new
Notification
(
message
,
opts
);
notificationGranted
=
function
(
message
,
opts
,
onclick
)
{
setTimeout
(
function
()
{
var
notification
;
// Hide the notification after X amount of seconds
notification
=
new
Notification
(
message
,
opts
);
return
notification
.
close
();
setTimeout
(
function
()
{
},
8000
);
return
notification
.
close
();
// Hide the notification after X amount of seconds
return
notification
.
onclick
=
onclick
||
notification
.
close
;
},
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
))
{
// do nothing
function
notifyPermissions
()
{
}
else
if
(
Notification
.
permission
===
'
granted
'
)
{
if
(
'
Notification
'
in
window
)
{
// If it's okay let's create a notification
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
);
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';
...
@@ -56,7 +56,6 @@ import './lib/utils/animate';
import
'
./lib/utils/bootstrap_linked_tabs
'
;
import
'
./lib/utils/bootstrap_linked_tabs
'
;
import
'
./lib/utils/common_utils
'
;
import
'
./lib/utils/common_utils
'
;
import
'
./lib/utils/datetime_utility
'
;
import
'
./lib/utils/datetime_utility
'
;
import
'
./lib/utils/notify
'
;
import
'
./lib/utils/pretty_time
'
;
import
'
./lib/utils/pretty_time
'
;
import
'
./lib/utils/text_utility
'
;
import
'
./lib/utils/text_utility
'
;
import
'
./lib/utils/url_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';
...
@@ -41,3 +41,4 @@ export { default as getStateKey } from './stores/get_state_key';
export
{
default
as
mrWidgetOptions
}
from
'
./mr_widget_options
'
;
export
{
default
as
mrWidgetOptions
}
from
'
./mr_widget_options
'
;
export
{
default
as
stateMaps
}
from
'
./stores/state_maps
'
;
export
{
default
as
stateMaps
}
from
'
./stores/state_maps
'
;
export
{
default
as
SquashBeforeMerge
}
from
'
./components/states/mr_widget_squash_before_merge
'
;
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 {
...
@@ -29,6 +29,7 @@ import {
eventHub
,
eventHub
,
stateMaps
,
stateMaps
,
SquashBeforeMerge
,
SquashBeforeMerge
,
notifyMe
,
}
from
'
./dependencies
'
;
}
from
'
./dependencies
'
;
export
default
{
export
default
{
...
@@ -77,8 +78,10 @@ export default {
...
@@ -77,8 +78,10 @@ export default {
this
.
service
.
checkStatus
()
this
.
service
.
checkStatus
()
.
then
(
res
=>
res
.
json
())
.
then
(
res
=>
res
.
json
())
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
this
.
handleNotification
(
res
);
this
.
mr
.
setData
(
res
);
this
.
mr
.
setData
(
res
);
this
.
setFavicon
();
this
.
setFavicon
();
if
(
cb
)
{
if
(
cb
)
{
cb
.
call
(
null
,
res
);
cb
.
call
(
null
,
res
);
}
}
...
@@ -136,6 +139,15 @@ export default {
...
@@ -136,6 +139,15 @@ export default {
new
Flash
(
'
Something went wrong. Please try again.
'
);
// eslint-disable-line
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
()
{
resumePolling
()
{
this
.
pollingInterval
.
resume
();
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 {
...
@@ -5,6 +5,8 @@ export default class MergeRequestStore {
constructor
(
data
)
{
constructor
(
data
)
{
this
.
sha
=
data
.
diff_head_sha
;
this
.
sha
=
data
.
diff_head_sha
;
this
.
gitlabLogo
=
gon
.
gitlab_logo
;
this
.
setData
(
data
);
this
.
setData
(
data
);
}
}
...
...
lib/gitlab/gon_helper.rb
View file @
b172ef2f
...
@@ -13,6 +13,7 @@ module Gitlab
...
@@ -13,6 +13,7 @@ module Gitlab
gon
.
sentry_dsn
=
current_application_settings
.
clientside_sentry_dsn
if
current_application_settings
.
clientside_sentry_enabled
gon
.
sentry_dsn
=
current_application_settings
.
clientside_sentry_dsn
if
current_application_settings
.
clientside_sentry_enabled
gon
.
gitlab_url
=
Gitlab
.
config
.
gitlab
.
url
gon
.
gitlab_url
=
Gitlab
.
config
.
gitlab
.
url
gon
.
revision
=
Gitlab
::
REVISION
gon
.
revision
=
Gitlab
::
REVISION
gon
.
gitlab_logo
=
ActionController
::
Base
.
helpers
.
asset_path
(
'gitlab_logo.png'
)
if
current_user
if
current_user
gon
.
current_user_id
=
current_user
.
id
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