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
99334d4b
Commit
99334d4b
authored
Nov 12, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/broadcast_messages' of /home/git/repositories/gitlab/gitlabhq
parents
0a08c775
3397361f
Changes
21
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
230 additions
and
1 deletion
+230
-1
app/assets/stylesheets/common.scss
app/assets/stylesheets/common.scss
+7
-0
app/assets/stylesheets/gitlab_bootstrap/forms.scss
app/assets/stylesheets/gitlab_bootstrap/forms.scss
+6
-0
app/assets/stylesheets/sections/admin.scss
app/assets/stylesheets/sections/admin.scss
+6
-0
app/controllers/admin/broadcast_messages_controller.rb
app/controllers/admin/broadcast_messages_controller.rb
+32
-0
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+4
-0
app/models/broadcast_message.rb
app/models/broadcast_message.rb
+11
-0
app/views/admin/broadcast_messages/index.html.haml
app/views/admin/broadcast_messages/index.html.haml
+46
-0
app/views/layouts/_broadcast.html.haml
app/views/layouts/_broadcast.html.haml
+4
-0
app/views/layouts/application.html.haml
app/views/layouts/application.html.haml
+1
-0
app/views/layouts/nav/_admin.html.haml
app/views/layouts/nav/_admin.html.haml
+2
-0
app/views/layouts/projects.html.haml
app/views/layouts/projects.html.haml
+1
-0
config/routes.rb
config/routes.rb
+1
-0
db/migrate/20131112114325_create_broadcast_messages.rb
db/migrate/20131112114325_create_broadcast_messages.rb
+12
-0
db/schema.rb
db/schema.rb
+10
-1
features/admin/active_tab.feature
features/admin/active_tab.feature
+5
-0
features/admin/broadcast_messages.feature
features/admin/broadcast_messages.feature
+13
-0
features/steps/admin/admin_active_tab.rb
features/steps/admin/admin_active_tab.rb
+4
-0
features/steps/admin/admin_broadcast_messages.rb
features/steps/admin/admin_broadcast_messages.rb
+27
-0
features/steps/shared/paths.rb
features/steps/shared/paths.rb
+4
-0
spec/factories/broadcast_messages.rb
spec/factories/broadcast_messages.rb
+10
-0
spec/models/broadcast_message_spec.rb
spec/models/broadcast_message_spec.rb
+24
-0
No files found.
app/assets/stylesheets/common.scss
View file @
99334d4b
...
@@ -351,3 +351,10 @@ table {
...
@@ -351,3 +351,10 @@ table {
@extend
.btn-new
;
@extend
.btn-new
;
padding
:
5px
15px
;
padding
:
5px
15px
;
}
}
.broadcast-message
{
padding
:
10px
;
text-align
:
center
;
background
:
#555
;
color
:
#BBB
;
}
app/assets/stylesheets/gitlab_bootstrap/forms.scss
View file @
99334d4b
...
@@ -49,3 +49,9 @@ fieldset legend {
...
@@ -49,3 +49,9 @@ fieldset legend {
font-size
:
16px
;
font-size
:
16px
;
margin-bottom
:
10px
;
margin-bottom
:
10px
;
}
}
.datetime-controls
{
select
{
width
:
100px
;
}
}
app/assets/stylesheets/sections/admin.scss
View file @
99334d4b
...
@@ -21,3 +21,9 @@
...
@@ -21,3 +21,9 @@
.controls
{
margin-left
:
130px
;
}
.controls
{
margin-left
:
130px
;
}
.form-actions
{
padding-left
:
130px
;
background
:
#fff
}
.form-actions
{
padding-left
:
130px
;
background
:
#fff
}
}
}
.broadcast-messages
{
.message
{
line-height
:
2
;
}
}
app/controllers/admin/broadcast_messages_controller.rb
0 → 100644
View file @
99334d4b
class
Admin::BroadcastMessagesController
<
Admin
::
ApplicationController
before_filter
:broadcast_messages
def
index
@broadcast_message
=
BroadcastMessage
.
new
end
def
create
@broadcast_message
=
BroadcastMessage
.
new
(
params
[
:broadcast_message
])
if
@broadcast_message
.
save
redirect_to
admin_broadcast_messages_path
,
notice:
'Broadcast Message was successfully created.'
else
render
:index
end
end
def
destroy
BroadcastMessage
.
find
(
params
[
:id
]).
destroy
respond_to
do
|
format
|
format
.
html
{
redirect_to
:back
}
format
.
js
{
render
nothing:
true
}
end
end
protected
def
broadcast_messages
@broadcast_messages
||=
BroadcastMessage
.
order
(
"starts_at DESC"
).
page
(
params
[
:page
])
end
end
app/helpers/application_helper.rb
View file @
99334d4b
...
@@ -208,4 +208,8 @@ module ApplicationHelper
...
@@ -208,4 +208,8 @@ module ApplicationHelper
line
+=
"..."
if
lines
.
size
>
1
line
+=
"..."
if
lines
.
size
>
1
line
line
end
end
def
broadcast_message
BroadcastMessage
.
current
end
end
end
app/models/broadcast_message.rb
0 → 100644
View file @
99334d4b
class
BroadcastMessage
<
ActiveRecord
::
Base
attr_accessible
:alert_type
,
:ends_at
,
:message
,
:starts_at
validates
:message
,
presence:
true
validates
:starts_at
,
presence:
true
validates
:ends_at
,
presence:
true
def
self
.
current
where
(
"ends_at > :now AND starts_at < :now"
,
now:
Time
.
zone
.
now
).
last
end
end
app/views/admin/broadcast_messages/index.html.haml
0 → 100644
View file @
99334d4b
%h3
.page-title
Broadcast Messages
%p
.light
Broadcast messages displayed for every user and can be used to notify application about scheduled maintenance.
%hr
=
form_for
[
:admin
,
@broadcast_message
]
do
|
f
|
-
if
@broadcast_message
.
errors
.
any?
.alert.alert-error
-
@broadcast_message
.
errors
.
full_messages
.
each
do
|
msg
|
%p
=
msg
.control-group
=
f
.
label
:message
.controls
=
f
.
text_area
:message
,
class:
"input-xxlarge"
,
rows:
2
,
required:
true
.control-group
=
f
.
label
:starts_at
.controls.datetime-controls
=
f
.
datetime_select
:starts_at
.control-group
=
f
.
label
:ends_at
.controls.datetime-controls
=
f
.
datetime_select
:ends_at
.form-actions
=
f
.
submit
"Add broadcast message"
,
class:
"btn btn-create"
-
if
@broadcast_messages
.
any?
%ul
.bordered-list.broadcast-messages
-
@broadcast_messages
.
each
do
|
broadcast_message
|
%li
.pull-right
-
if
broadcast_message
.
starts_at
%strong
#{
broadcast_message
.
starts_at
.
to_s
(
:short
)
}
\...
-
if
broadcast_message
.
ends_at
%strong
#{
broadcast_message
.
ends_at
.
to_s
(
:short
)
}
=
link_to
[
:admin
,
broadcast_message
],
method: :delete
,
remote:
true
,
class:
'remove-row btn btn-tiny'
do
%i
.icon-remove.cred
.message
=
broadcast_message
.
message
=
paginate
@broadcast_messages
app/views/layouts/_broadcast.html.haml
0 → 100644
View file @
99334d4b
-
if
broadcast_message
.
present?
.broadcast-message
%i
.icon-bullhorn
=
broadcast_message
.
message
app/views/layouts/application.html.haml
View file @
99334d4b
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
%html
{
lang:
"en"
}
%html
{
lang:
"en"
}
=
render
"layouts/head"
,
title:
"Dashboard"
=
render
"layouts/head"
,
title:
"Dashboard"
%body
{
class:
"#{app_theme} application"
,
:'data-page'
=>
body_data_page
}
%body
{
class:
"#{app_theme} application"
,
:'data-page'
=>
body_data_page
}
=
render
"layouts/broadcast"
=
render
"layouts/head_panel"
,
title:
"Dashboard"
=
render
"layouts/head_panel"
,
title:
"Dashboard"
=
render
"layouts/flash"
=
render
"layouts/flash"
%nav
.main-nav
%nav
.main-nav
...
...
app/views/layouts/nav/_admin.html.haml
View file @
99334d4b
...
@@ -10,6 +10,8 @@
...
@@ -10,6 +10,8 @@
=
link_to
"Users"
,
admin_users_path
=
link_to
"Users"
,
admin_users_path
=
nav_link
(
controller: :logs
)
do
=
nav_link
(
controller: :logs
)
do
=
link_to
"Logs"
,
admin_logs_path
=
link_to
"Logs"
,
admin_logs_path
=
nav_link
(
controller: :broadcast_messages
)
do
=
link_to
"Messages"
,
admin_broadcast_messages_path
=
nav_link
(
controller: :hooks
)
do
=
nav_link
(
controller: :hooks
)
do
=
link_to
"Hooks"
,
admin_hooks_path
=
link_to
"Hooks"
,
admin_hooks_path
=
nav_link
(
controller: :background_jobs
)
do
=
nav_link
(
controller: :background_jobs
)
do
...
...
app/views/layouts/projects.html.haml
View file @
99334d4b
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
%html
{
lang:
"en"
}
%html
{
lang:
"en"
}
=
render
"layouts/head"
,
title:
@project
.
name_with_namespace
=
render
"layouts/head"
,
title:
@project
.
name_with_namespace
%body
{
class:
"#{app_theme} project"
,
:'data-page'
=>
body_data_page
,
:'data-project-id'
=>
@project
.
id
}
%body
{
class:
"#{app_theme} project"
,
:'data-page'
=>
body_data_page
,
:'data-project-id'
=>
@project
.
id
}
=
render
"layouts/broadcast"
=
render
"layouts/head_panel"
,
title:
project_title
(
@project
)
=
render
"layouts/head_panel"
,
title:
project_title
(
@project
)
=
render
"layouts/init_auto_complete"
=
render
"layouts/init_auto_complete"
=
render
"layouts/flash"
=
render
"layouts/flash"
...
...
config/routes.rb
View file @
99334d4b
...
@@ -86,6 +86,7 @@ Gitlab::Application.routes.draw do
...
@@ -86,6 +86,7 @@ Gitlab::Application.routes.draw do
get
:test
get
:test
end
end
resources
:broadcast_messages
,
only:
[
:index
,
:create
,
:destroy
]
resource
:logs
,
only:
[
:show
]
resource
:logs
,
only:
[
:show
]
resource
:background_jobs
,
controller:
'background_jobs'
,
only:
[
:show
]
resource
:background_jobs
,
controller:
'background_jobs'
,
only:
[
:show
]
resources
:projects
,
constraints:
{
id:
/[a-zA-Z.\/0-9_\-]+/
},
only:
[
:index
,
:show
]
resources
:projects
,
constraints:
{
id:
/[a-zA-Z.\/0-9_\-]+/
},
only:
[
:index
,
:show
]
...
...
db/migrate/20131112114325_create_broadcast_messages.rb
0 → 100644
View file @
99334d4b
class
CreateBroadcastMessages
<
ActiveRecord
::
Migration
def
change
create_table
:broadcast_messages
do
|
t
|
t
.
text
:message
,
null:
false
t
.
datetime
:starts_at
t
.
datetime
:ends_at
t
.
integer
:alert_type
t
.
timestamps
end
end
end
db/schema.rb
View file @
99334d4b
...
@@ -11,7 +11,16 @@
...
@@ -11,7 +11,16 @@
#
#
# It's strongly recommended to check this file into your version control system.
# It's strongly recommended to check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
:version
=>
20131106151520
)
do
ActiveRecord
::
Schema
.
define
(
:version
=>
20131112114325
)
do
create_table
"broadcast_messages"
,
:force
=>
true
do
|
t
|
t
.
text
"message"
,
:null
=>
false
t
.
datetime
"starts_at"
t
.
datetime
"ends_at"
t
.
integer
"alert_type"
t
.
datetime
"created_at"
,
:null
=>
false
t
.
datetime
"updated_at"
,
:null
=>
false
end
create_table
"deploy_keys_projects"
,
:force
=>
true
do
|
t
|
create_table
"deploy_keys_projects"
,
:force
=>
true
do
|
t
|
t
.
integer
"deploy_key_id"
,
:null
=>
false
t
.
integer
"deploy_key_id"
,
:null
=>
false
...
...
features/admin/active_tab.feature
View file @
99334d4b
...
@@ -27,6 +27,11 @@ Feature: Admin active tab
...
@@ -27,6 +27,11 @@ Feature: Admin active tab
Then
the active main tab should be Logs
Then
the active main tab should be Logs
And
no other main tabs should be active
And
no other main tabs should be active
Scenario
:
On Admin Messages
Given
I visit admin messages page
Then
the active main tab should be Messages
And
no other main tabs should be active
Scenario
:
On Admin Hooks
Scenario
:
On Admin Hooks
Given
I visit admin hooks page
Given
I visit admin hooks page
Then
the active main tab should be Hooks
Then
the active main tab should be Hooks
...
...
features/admin/broadcast_messages.feature
0 → 100644
View file @
99334d4b
Feature
:
Admin Broadcast Messages
Background
:
Given
I sign in as an admin
And
application already has admin messages
And
I visit admin messages page
Scenario
:
See broadcast messages list
Then
I should be all broadcast messages
Scenario
:
Create a broadcast message
When
submit form with new broadcast message
Then
I should be redirected to admin messages page
And
I should see newly created broadcast message
features/steps/admin/admin_active_tab.rb
View file @
99334d4b
...
@@ -30,4 +30,8 @@ class AdminActiveTab < Spinach::FeatureSteps
...
@@ -30,4 +30,8 @@ class AdminActiveTab < Spinach::FeatureSteps
Then
'the active main tab should be Resque'
do
Then
'the active main tab should be Resque'
do
ensure_active_main_tab
(
'Background Jobs'
)
ensure_active_main_tab
(
'Background Jobs'
)
end
end
Then
'the active main tab should be Messages'
do
ensure_active_main_tab
(
'Messages'
)
end
end
end
features/steps/admin/admin_broadcast_messages.rb
0 → 100644
View file @
99334d4b
class
Spinach::Features::AdminBroadcastMessages
<
Spinach
::
FeatureSteps
include
SharedAuthentication
include
SharedPaths
include
SharedAdmin
step
'application already has admin messages'
do
FactoryGirl
.
create
(
:broadcast_message
,
message:
"Migration to new server"
)
end
step
'I should be all broadcast messages'
do
page
.
should
have_content
"Migration to new server"
end
step
'submit form with new broadcast message'
do
fill_in
'broadcast_message_message'
,
with:
'Application update from 4:00 CST to 5:00 CST'
select
'2018'
,
from:
"broadcast_message_ends_at_1i"
click_button
"Add broadcast message"
end
step
'I should be redirected to admin messages page'
do
current_path
.
should
==
admin_broadcast_messages_path
end
step
'I should see newly created broadcast message'
do
page
.
should
have_content
'Application update from 4:00 CST to 5:00 CST'
end
end
features/steps/shared/paths.rb
View file @
99334d4b
...
@@ -105,6 +105,10 @@ module SharedPaths
...
@@ -105,6 +105,10 @@ module SharedPaths
visit
admin_logs_path
visit
admin_logs_path
end
end
step
'I visit admin messages page'
do
visit
admin_broadcast_messages_path
end
step
'I visit admin hooks page'
do
step
'I visit admin hooks page'
do
visit
admin_hooks_path
visit
admin_hooks_path
end
end
...
...
spec/factories/broadcast_messages.rb
0 → 100644
View file @
99334d4b
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl
.
define
do
factory
:broadcast_message
do
message
"MyText"
starts_at
"2013-11-12 13:43:25"
ends_at
"2013-11-12 13:43:25"
alert_type
1
end
end
spec/models/broadcast_message_spec.rb
0 → 100644
View file @
99334d4b
require
'spec_helper'
describe
BroadcastMessage
do
subject
{
create
(
:broadcast_message
)
}
it
{
should
be_valid
}
describe
:current
do
it
"should return last message if time match"
do
broadcast_message
=
create
(
:broadcast_message
,
starts_at:
Time
.
now
.
yesterday
,
ends_at:
Time
.
now
.
tomorrow
)
BroadcastMessage
.
current
.
should
==
broadcast_message
end
it
"should return nil if time not come"
do
broadcast_message
=
create
(
:broadcast_message
,
starts_at:
Time
.
now
.
tomorrow
,
ends_at:
Time
.
now
+
2
.
days
)
BroadcastMessage
.
current
.
should
be_nil
end
it
"should return nil if time has passed"
do
broadcast_message
=
create
(
:broadcast_message
,
starts_at:
Time
.
now
-
2
.
days
,
ends_at:
Time
.
now
.
yesterday
)
BroadcastMessage
.
current
.
should
be_nil
end
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