houston-core 0.8.4 → 0.9.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (225) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/Gemfile.lock +72 -78
  4. data/app/assets/javascripts/houston/app/models/role.coffee +4 -0
  5. data/app/assets/javascripts/houston/app/views/nested_resources.coffee +44 -0
  6. data/app/assets/javascripts/houston/app/views/team_roles_view.coffee +10 -0
  7. data/app/assets/javascripts/houston/application.js +3 -1
  8. data/app/assets/javascripts/houston/core/ajax_helpers.coffee +26 -0
  9. data/app/assets/javascripts/houston/core/app.coffee +0 -45
  10. data/app/assets/javascripts/houston/core/errors.coffee +1 -12
  11. data/app/assets/javascripts/houston/core/handlebars_helpers.coffee +8 -70
  12. data/app/assets/javascripts/houston/core/jquery_extensions.coffee +0 -138
  13. data/app/assets/javascripts/houston/core/timeline_helpers.coffee +44 -0
  14. data/app/assets/javascripts/houston/core/uploader_helpers.coffee +99 -0
  15. data/app/assets/javascripts/houston/vendor.js +26 -9
  16. data/app/assets/stylesheets/houston/application/actions.scss +22 -0
  17. data/app/assets/stylesheets/houston/application/navigation.scss +2 -2
  18. data/app/assets/stylesheets/houston/application/{freight_train.css.scss → nested_resources.scss} +1 -0
  19. data/app/assets/stylesheets/houston/core/alerts.scss +0 -4
  20. data/app/assets/stylesheets/houston/core/timeline.scss +204 -0
  21. data/app/assets/templates/houston/teams/roles/index.hbs +1 -0
  22. data/app/assets/templates/houston/teams/roles/show.hbs +19 -0
  23. data/app/channels/events_channel.rb +1 -1
  24. data/app/concerns/houston/props.rb +3 -2
  25. data/app/controllers/actions_controller.rb +8 -3
  26. data/app/controllers/application_controller.rb +9 -12
  27. data/app/controllers/authorizations_controller.rb +41 -14
  28. data/app/controllers/errors_controller.rb +3 -3
  29. data/app/controllers/project_follows_controller.rb +23 -0
  30. data/app/controllers/project_options_controller.rb +1 -1
  31. data/app/controllers/user_options_controller.rb +1 -1
  32. data/app/helpers/actions_helper.rb +12 -0
  33. data/app/helpers/application_helper.rb +0 -10
  34. data/app/helpers/layout_helper.rb +20 -0
  35. data/app/helpers/markdown_helper.rb +2 -10
  36. data/app/helpers/navigation_helper.rb +5 -5
  37. data/app/helpers/project_helper.rb +6 -0
  38. data/app/helpers/url_helper.rb +4 -4
  39. data/app/helpers/view_extensions_helper.rb +20 -0
  40. data/app/models/action.rb +61 -44
  41. data/app/models/authorization.rb +55 -10
  42. data/app/models/follow.rb +6 -0
  43. data/app/models/persistent_trigger.rb +11 -1
  44. data/app/models/project.rb +5 -27
  45. data/app/models/user.rb +15 -59
  46. data/app/presenters/project_presenter.rb +2 -2
  47. data/app/views/actions/_actions.html.erb +8 -5
  48. data/app/views/actions/index.html.erb +1 -1
  49. data/app/views/actions/running.html.erb +9 -15
  50. data/app/views/actions/show.html.erb +6 -3
  51. data/app/views/actions/unqueued.html.erb +41 -0
  52. data/app/views/authorizations/_form.html.erb +28 -16
  53. data/app/views/authorizations/index.html.erb +9 -4
  54. data/app/views/{oauth/providers/edit.html.erb → authorizations/oauth2_callback.html.erb} +3 -2
  55. data/app/views/devise/sessions/new.html.erb +0 -8
  56. data/app/views/errors/index.html.erb +9 -5
  57. data/app/views/layouts/_navigation.html.erb +9 -0
  58. data/app/views/layouts/application.html.erb +11 -6
  59. data/app/views/layouts/dashboard.html.erb +9 -0
  60. data/app/views/projects/_form.html.erb +7 -18
  61. data/app/views/projects/_header.html.erb +2 -6
  62. data/app/views/projects/index.html.erb +4 -4
  63. data/app/views/teams/_form.html.erb +7 -17
  64. data/app/views/teams/index.html.erb +1 -1
  65. data/app/views/users/_form.html.erb +1 -38
  66. data/config/application.rb +8 -5
  67. data/config/initializers/devise.rb +0 -14
  68. data/config/initializers/secret_token.rb +8 -13
  69. data/config/routes.rb +12 -28
  70. data/db/migrate/20130706141443_drop_deprecated_project_roles.rb +5 -1
  71. data/db/migrate/20170118005958_remove_antecedents_from_versions_of_tickets.rb +1 -1
  72. data/db/migrate/20170130011016_drop_users_environments_subscribed_to.rb +9 -0
  73. data/db/migrate/20170205004452_drop_settings.rb +12 -0
  74. data/db/migrate/20170206002030_drop_extension_hstore.rb +9 -0
  75. data/db/migrate/20170206002732_drop_legacy_columns_from_users.rb +10 -0
  76. data/db/migrate/20170209022159_rename_projects_color_to_color_name.rb +5 -0
  77. data/db/migrate/20170213001453_change_providers_from_models_to_extensions.rb +27 -0
  78. data/db/migrate/20170215012012_add_props_to_authorizations.rb +5 -0
  79. data/db/migrate/20170216041034_add_user_to_persistent_triggers.rb +5 -0
  80. data/db/migrate/20170226201504_create_follows.rb +20 -0
  81. data/db/migrate/20170301014051_drop_name_from_authorizations.rb +9 -0
  82. data/db/migrate/20170307032041_add_created_at_to_actions.rb +11 -0
  83. data/db/migrate/20170307035755_allow_actions_started_at_to_be_null.rb +5 -0
  84. data/db/migrate/20170310024505_replace_authorizations_provider_name_with_type.rb +12 -0
  85. data/db/migrate/20170329030329_drop_consumer_tokens.rb +9 -0
  86. data/db/structure.sql +187 -212
  87. data/houston-core.gemspec +10 -13
  88. data/lib/houston/boot.rb +1 -4
  89. data/lib/houston/boot/actions.rb +24 -21
  90. data/lib/houston/boot/configuration.rb +46 -113
  91. data/lib/houston/boot/extensions.rb +54 -341
  92. data/lib/houston/boot/extensions/deprecated.rb +194 -0
  93. data/lib/houston/boot/extensions/dsl.rb +99 -0
  94. data/lib/houston/boot/extensions/events.rb +81 -0
  95. data/lib/houston/boot/extensions/features.rb +42 -0
  96. data/lib/houston/boot/extensions/layout.rb +70 -0
  97. data/lib/houston/boot/extensions/navigation.rb +42 -0
  98. data/lib/houston/boot/extensions/oauth.rb +62 -0
  99. data/lib/houston/boot/extensions/serializers.rb +29 -0
  100. data/lib/houston/boot/extensions/view.rb +34 -0
  101. data/lib/houston/boot/observer.rb +10 -5
  102. data/{app/models/oauth → lib/houston/boot}/provider.rb +7 -5
  103. data/lib/houston/boot/running_as.rb +0 -5
  104. data/lib/houston/boot/serializer.rb +12 -6
  105. data/lib/houston/boot/{active_record_serializer.rb → serializers/active_record_serializer.rb} +0 -2
  106. data/lib/houston/boot/{readonly_hash_serializer.rb → serializers/readonly_hash_serializer.rb} +0 -2
  107. data/lib/houston/boot/timer.rb +10 -0
  108. data/lib/houston/boot/triggers.rb +27 -8
  109. data/lib/houston/version.rb +1 -1
  110. data/templates/new-instance/.gitignore +0 -4
  111. data/templates/new-instance/config/main.rb +8 -10
  112. data/templates/new-module/test/dummy/houston.rb +1 -0
  113. data/test/acceptance/layout_test.rb +58 -0
  114. data/test/acceptance/updating_props_test.rb +72 -0
  115. data/test/support/config.rb +1 -0
  116. data/test/unit/extensions/events_extension_test.rb +33 -0
  117. data/test/unit/extensions/layout_extension_test.rb +74 -0
  118. data/test/unit/extensions/navigation_extension_test.rb +62 -0
  119. data/test/unit/extensions/oauth_extension_test.rb +91 -0
  120. data/test/unit/extensions/project_features_extension_test.rb +79 -0
  121. data/test/unit/extensions/serializers_extension_test.rb +47 -0
  122. data/test/unit/extensions/view_extension_test.rb +98 -0
  123. data/test/unit/models/actions_test.rb +11 -5
  124. data/test/unit/models/configuration_test.rb +0 -8
  125. data/test/unit/models/observer_test.rb +16 -0
  126. data/test/unit/models/persistent_trigger_test.rb +29 -2
  127. data/test/unit/models/serializer_test.rb +6 -0
  128. data/test/unit/models/timer_test.rb +88 -0
  129. metadata +87 -168
  130. data/app/assets/font/octicons.eot +0 -0
  131. data/app/assets/font/octicons.svg +0 -198
  132. data/app/assets/font/octicons.ttf +0 -0
  133. data/app/assets/font/octicons.woff +0 -0
  134. data/app/assets/font/roboto-black-webfont.eot +0 -0
  135. data/app/assets/font/roboto-black-webfont.svg +0 -675
  136. data/app/assets/font/roboto-black-webfont.ttf +0 -0
  137. data/app/assets/font/roboto-black-webfont.woff +0 -0
  138. data/app/assets/font/roboto-blackitalic-webfont.eot +0 -0
  139. data/app/assets/font/roboto-blackitalic-webfont.svg +0 -677
  140. data/app/assets/font/roboto-blackitalic-webfont.ttf +0 -0
  141. data/app/assets/font/roboto-blackitalic-webfont.woff +0 -0
  142. data/app/assets/font/roboto-bold-webfont.eot +0 -0
  143. data/app/assets/font/roboto-bold-webfont.svg +0 -675
  144. data/app/assets/font/roboto-bold-webfont.ttf +0 -0
  145. data/app/assets/font/roboto-bold-webfont.woff +0 -0
  146. data/app/assets/font/roboto-bolditalic-webfont.eot +0 -0
  147. data/app/assets/font/roboto-bolditalic-webfont.svg +0 -677
  148. data/app/assets/font/roboto-bolditalic-webfont.ttf +0 -0
  149. data/app/assets/font/roboto-bolditalic-webfont.woff +0 -0
  150. data/app/assets/font/roboto-italic-webfont.eot +0 -0
  151. data/app/assets/font/roboto-italic-webfont.svg +0 -668
  152. data/app/assets/font/roboto-italic-webfont.ttf +0 -0
  153. data/app/assets/font/roboto-italic-webfont.woff +0 -0
  154. data/app/assets/font/roboto-light-webfont.eot +0 -0
  155. data/app/assets/font/roboto-light-webfont.svg +0 -666
  156. data/app/assets/font/roboto-light-webfont.ttf +0 -0
  157. data/app/assets/font/roboto-light-webfont.woff +0 -0
  158. data/app/assets/font/roboto-lightitalic-webfont.eot +0 -0
  159. data/app/assets/font/roboto-lightitalic-webfont.svg +0 -668
  160. data/app/assets/font/roboto-lightitalic-webfont.ttf +0 -0
  161. data/app/assets/font/roboto-lightitalic-webfont.woff +0 -0
  162. data/app/assets/font/roboto-medium-webfont.eot +0 -0
  163. data/app/assets/font/roboto-medium-webfont.svg +0 -675
  164. data/app/assets/font/roboto-medium-webfont.ttf +0 -0
  165. data/app/assets/font/roboto-medium-webfont.woff +0 -0
  166. data/app/assets/font/roboto-mediumitalic-webfont.eot +0 -0
  167. data/app/assets/font/roboto-mediumitalic-webfont.svg +0 -677
  168. data/app/assets/font/roboto-mediumitalic-webfont.ttf +0 -0
  169. data/app/assets/font/roboto-mediumitalic-webfont.woff +0 -0
  170. data/app/assets/font/roboto-regular-webfont.eot +0 -0
  171. data/app/assets/font/roboto-regular-webfont.svg +0 -666
  172. data/app/assets/font/roboto-regular-webfont.ttf +0 -0
  173. data/app/assets/font/roboto-regular-webfont.woff +0 -0
  174. data/app/assets/font/roboto-thin-webfont.eot +0 -0
  175. data/app/assets/font/roboto-thin-webfont.svg +0 -666
  176. data/app/assets/font/roboto-thin-webfont.ttf +0 -0
  177. data/app/assets/font/roboto-thin-webfont.woff +0 -0
  178. data/app/assets/font/roboto-thinitalic-webfont.eot +0 -0
  179. data/app/assets/font/roboto-thinitalic-webfont.svg +0 -668
  180. data/app/assets/font/roboto-thinitalic-webfont.ttf +0 -0
  181. data/app/assets/font/roboto-thinitalic-webfont.woff +0 -0
  182. data/app/assets/images/bug-fixed-128.png +0 -0
  183. data/app/assets/images/bug-fixed-32.png +0 -0
  184. data/app/assets/images/bug-fixed-48.png +0 -0
  185. data/app/assets/images/bug-new-128.png +0 -0
  186. data/app/assets/images/bug-new-32.png +0 -0
  187. data/app/assets/images/bug-new-48.png +0 -0
  188. data/app/assets/images/bug-open-32.png +0 -0
  189. data/app/assets/images/bug-zero-128.png +0 -0
  190. data/app/assets/images/bug-zero-48.png +0 -0
  191. data/app/assets/images/drag-grip.png +0 -0
  192. data/app/assets/javascripts/houston/core/burndown_chart.coffee +0 -111
  193. data/app/assets/javascripts/houston/core/stacked_area_graph.coffee +0 -113
  194. data/app/assets/javascripts/houston/core/stacked_bar_graph.coffee +0 -108
  195. data/app/assets/stylesheets/houston/application/project_tiles.scss +0 -26
  196. data/app/assets/stylesheets/houston/application/tips.scss +0 -5
  197. data/app/assets/stylesheets/houston/core/octicons-icons.scss +0 -221
  198. data/app/assets/stylesheets/houston/core/octicons.scss.erb +0 -9
  199. data/app/assets/stylesheets/houston/core/roboto.scss.erb +0 -131
  200. data/app/concerns/historical_weekly_stats.rb +0 -15
  201. data/app/concerns/nosync.rb +0 -21
  202. data/app/controllers/oauth/providers_controller.rb +0 -45
  203. data/app/controllers/project_roles_controller.rb +0 -22
  204. data/app/controllers/settings_controller.rb +0 -14
  205. data/app/controllers/tester_bar_controller.rb +0 -12
  206. data/app/controllers/user_credentials_controller.rb +0 -24
  207. data/app/models/role.rb +0 -33
  208. data/app/models/setting.rb +0 -10
  209. data/app/models/settings.rb +0 -38
  210. data/app/models/slackdown.rb +0 -23
  211. data/app/models/user_credentials.rb +0 -27
  212. data/app/views/errors/_actions.html.erb +0 -17
  213. data/app/views/layouts/_tester_bar.html.erb +0 -6
  214. data/app/views/layouts/minimal.html.erb +0 -50
  215. data/app/views/layouts/naked.html.erb +0 -47
  216. data/app/views/layouts/naked_dashboard.html.erb +0 -50
  217. data/app/views/oauth/providers/_form.html.erb +0 -54
  218. data/app/views/oauth/providers/index.html.erb +0 -41
  219. data/app/views/oauth/providers/new.html.erb +0 -7
  220. data/config/initializers/add_navigation_renderers.rb +0 -5
  221. data/config/initializers/vestal_versions.rb +0 -9
  222. data/db/migrate/20130519163615_create_user_credentials.rb +0 -18
  223. data/lib/houston/boot/events.rb +0 -10
  224. data/lib/tasks/keypair.rake +0 -17
  225. data/vendor/assets/javascripts/jquery.pjax.js +0 -817
@@ -8,6 +8,28 @@ td.action-reliability {
8
8
  padding-right: 16px !important;
9
9
  }
10
10
 
11
+ .action-errors {
12
+ .action-duration { display: none; }
13
+ .action-started { display: none; }
14
+ .action-finished { display: none; }
15
+ }
16
+ .action-show {
17
+ .action-name { display: none; }
18
+ }
19
+ .action-running {
20
+ .action-created { display: none; }
21
+ .action-finished { display: none; }
22
+ .action-succeeded { display: none; }
23
+ .action-exception { display: none; }
24
+ }
25
+ .action-unqueued {
26
+ .action-started { display: none; }
27
+ .action-finished { display: none; }
28
+ .action-duration { display: none; }
29
+ .action-succeeded { display: none; }
30
+ .action-exception { display: none; }
31
+ }
32
+
11
33
  .action-params {
12
34
  pre {
13
35
  border: none;
@@ -222,7 +222,7 @@ $current-project-active-bg: #222;
222
222
  font-size: 2em;
223
223
 
224
224
 
225
- a.btn { color: white ;}
225
+ a.btn { font-weight: normal; }
226
226
 
227
227
  .buttons { float: right; }
228
228
 
@@ -249,6 +249,6 @@ body {
249
249
  padding-top: $navbar-height + $project-navbar-height
250
250
  }
251
251
 
252
- #body {
252
+ .project-banner + #body {
253
253
  padding-top: 105px;
254
254
  }
@@ -16,6 +16,7 @@
16
16
  }
17
17
  }
18
18
  }
19
+
19
20
  .nested.editor.headings div {
20
21
  padding-top: 5px;
21
22
  margin-top: 0;
@@ -1,7 +1,3 @@
1
- html.tester-bar {
2
- .alertify-logs { bottom: 52px; }
3
- }
4
-
5
1
  .alertify-log {
6
2
  background: rgba(9, 151, 196, 0.75);
7
3
  text-shadow: none;
@@ -0,0 +1,204 @@
1
+ $lightGray: #eee;
2
+
3
+ .timeline {
4
+
5
+ .timeline-date {
6
+ width: 38px;
7
+ font-size: 0.75em;
8
+ text-align: right;
9
+ border-right: 2px solid $lightGray;
10
+ padding-right: 12px;
11
+ padding-top: 0.5em;
12
+ padding-bottom: 0.5em;
13
+ line-height: 1em;
14
+ position: relative;
15
+ color: #888;
16
+
17
+ &::after {
18
+ content: '.';
19
+ width: 8px;
20
+ height: 2px;
21
+ background: $lightGray;
22
+ display: block;
23
+ color: transparent;
24
+ position: absolute;
25
+ right: 0;
26
+ top: 1.25em;
27
+ }
28
+
29
+ .weekday { display: block; }
30
+ .year { display: none; }
31
+ }
32
+
33
+ .timeline-date-gap {
34
+ margin-left: 50px;
35
+ padding-left: 12px;
36
+ border-left: dashed 2px $lightGray;
37
+ height: 48px;
38
+ }
39
+
40
+ .timeline-event {
41
+ margin-left: 50px;
42
+ padding: 4px 4px 4px 70px;
43
+ border-left: solid 2px $lightGray;
44
+ position: relative;
45
+ font-size: 0.92em;
46
+ text-indent: -57px;
47
+ line-height: 1.25em;
48
+
49
+ .timeline-event-time {
50
+ font-size: 10px;
51
+ text-align: right;
52
+ line-height: 1em;
53
+ position: absolute;
54
+ left: -14px;
55
+ top: 10px;
56
+ color: $lightGray;
57
+ }
58
+
59
+ a {
60
+ color: #333;
61
+ font-weight: 300;
62
+
63
+ &:hover {
64
+ text-decoration: none;
65
+ background: #EDF9FF;
66
+ }
67
+
68
+ b { font-weight: 400; }
69
+ }
70
+
71
+ .ticket-number a { color: #0088cc !important; }
72
+
73
+ .bubble {
74
+ border-radius: 13px;
75
+ width: 13px;
76
+ height: 13px;
77
+ position: relative;
78
+ top: 2px;
79
+ text-indent: 0;
80
+ margin: 0 4px;
81
+ }
82
+
83
+ .timeline-event-type {
84
+ color: white;
85
+ font-size: 9px;
86
+ display: inline-block;
87
+ width: 12px;
88
+ text-indent: 0;
89
+ position: absolute;
90
+ top: 2px;
91
+ left: 1px;
92
+ text-align: center;
93
+ }
94
+
95
+ &::after {
96
+ content: '.';
97
+ width: 7px;
98
+ height: 7px;
99
+ border-radius: 7px;
100
+ border: solid 2px $lightGray;
101
+ display: block;
102
+ background: white;
103
+ color: transparent;
104
+ position: absolute;
105
+ left: -6px;
106
+ top: 10px;
107
+ }
108
+
109
+ &::before {
110
+ content: '.';
111
+ width: 12px;
112
+ height: 2px;
113
+ background: $lightGray;
114
+ display: block;
115
+ color: transparent;
116
+ position: absolute;
117
+ left: 0;
118
+ top: 14px;
119
+ }
120
+
121
+ &.timeline-event-audit {
122
+ padding-left: 37px;
123
+
124
+ em {
125
+ background: #ffd;
126
+ font-style: normal;
127
+ }
128
+ }
129
+
130
+ &.timeline-event-release,
131
+ &.timeline-event-ticket-created,
132
+ &.timeline-event-ticket-closed {
133
+ padding-right: 100px;
134
+ }
135
+
136
+ &.timeline-event-release {
137
+ font-size: 1.10em;
138
+
139
+ a { font-weight: 400;
140
+ b { font-weight: 700; }
141
+ }
142
+
143
+ .bubble {
144
+ width: 21px;
145
+ height: 21px;
146
+ left: -4px;
147
+ border-radius: 21px;
148
+ top: 6px;
149
+ margin-right: -4px;
150
+ }
151
+
152
+ .timeline-event-type {
153
+ font-size: 15px;
154
+ left: 2px;
155
+ top: 3px;
156
+ }
157
+
158
+ .timeline-event-time {
159
+ top: 14px;
160
+ }
161
+
162
+ &::before { top: 19px; width: 8px; }
163
+ &::after { top: 15px; }
164
+ }
165
+
166
+ .timeline-event-actor {
167
+ width: 20px;
168
+ display: inline-block;
169
+ text-indent: 0;
170
+ margin: 0 4px;
171
+ position: relative;
172
+ top: -1px;
173
+ }
174
+
175
+ .commit-range {
176
+ display: block;
177
+ position: absolute;
178
+ top: 11px;
179
+ right: 0;
180
+ text-indent: 0;
181
+ font-size: 10px;
182
+ letter-spacing: 1px;
183
+
184
+ a { color: #0088cc !important; }
185
+ }
186
+
187
+ .ticket-resolution {
188
+ font-size: 0.88em;
189
+ font-weight: 700;
190
+ color: #aaa;
191
+
192
+ &::after { content: ':'; }
193
+ }
194
+
195
+ .ticket-number {
196
+ display: block;
197
+ position: absolute;
198
+ top: 4px;
199
+ right: 0;
200
+ text-indent: 0;
201
+ font-size: 0.88em;
202
+ }
203
+ }
204
+ }
@@ -0,0 +1 @@
1
+ <ol id="roles"></ol>
@@ -0,0 +1,19 @@
1
+ <input data-attr="id" type="hidden" value="{{id}}" name="team[roles_attributes][{{index}}][id]">
2
+
3
+ <input data-attr="_destroy" type="hidden" value="{{#if destroyed}}1{{else}}0{{/if}}" attr="team[roles_attributes][{{index}}][_destroy]" name="team[roles_attributes][{{index}}][_destroy]">
4
+
5
+ <select name="team[roles_attributes][{{index}}][user_id]">
6
+ {{#each options.users}}
7
+ <option {{#ifEql id ../userId}}selected{{/ifEql}} value="{{id}}">{{name}}</option>
8
+ {{/each}}
9
+ </select>
10
+
11
+ {{#each options.roles}}
12
+ <label style="display: inline-block">
13
+ <input type="checkbox" name="team[roles_attributes][{{../index}}][roles][]" {{#ifIn this ../roles}}checked{{/ifIn}} value="{{this}}">
14
+ {{this}}
15
+ </label>
16
+ {{/each}}
17
+
18
+ <span class="delete-nested"><a class="delete-link delete-button delete-nested-link" href="#" title="Delete">Delete</a></span>
19
+ <span class="add-nested"><a class="add-link add-nested-link" href="#" title="Add">Add</a></span>
@@ -10,7 +10,7 @@ class EventsChannel < ApplicationCable::Channel
10
10
  events = params[:events] if params.key?(:events)
11
11
 
12
12
  events.each do |event|
13
- unless Houston.registered_event?(event)
13
+ unless Houston.events.registered?(event)
14
14
  Rails.logger.info "\e[31m[subscriber] \e[1m#{event}\e[0;31m is not a registered event\e[0m"
15
15
  next
16
16
  end
@@ -15,9 +15,10 @@ module Houston
15
15
 
16
16
 
17
17
  module ClassMethods
18
- def with_prop(prop_name, value)
18
+ def with_prop(prop_name, *args)
19
19
  Houston::Props.valid_prop_name!(prop_name)
20
- where(["props->>? = ?", prop_name, value.to_s])
20
+ return where(["props ? :key", { key: prop_name }]) if args.empty?
21
+ where(["props->>? = ?", prop_name, args.first.to_s])
21
22
  end
22
23
 
23
24
  def find_by_prop(prop_name, value)
@@ -29,13 +29,18 @@ class ActionsController < ApplicationController
29
29
  authorize! :read, Action
30
30
  @action_name = params[:slug]
31
31
  @actions = Action.where(name: @action_name).preload(:error).limit(50)
32
- @actions = @actions.where(Action.arel_table[:started_at].lt(params[:before])) if params[:before]
32
+ @actions = @actions.where(Action.arel_table[:created_at].lt(params[:before])) if params[:before]
33
33
  render partial: "actions/actions" if request.xhr?
34
34
  end
35
35
 
36
36
  def running
37
37
  authorize! :read, Action
38
- @actions = Action.where(finished_at: nil)
38
+ @actions = Action.running
39
+ end
40
+
41
+ def unqueued
42
+ authorize! :read, Action
43
+ @actions = Action.unqueued
39
44
  end
40
45
 
41
46
  def run
@@ -48,7 +53,7 @@ class ActionsController < ApplicationController
48
53
  authorize! :run, Action
49
54
  action = Action.find(params[:id])
50
55
  action.retry!
51
- redirect_to "/actions/#{action.name}", notice: "#{action.name} is running"
56
+ redirect_to :back
52
57
  end
53
58
 
54
59
  end
@@ -26,18 +26,6 @@ class ApplicationController < ActionController::Base
26
26
  end
27
27
  end
28
28
 
29
- rescue_from UserCredentials::MissingCredentials do
30
- head 401, "X-Credentials" => "Missing Credentials"
31
- end
32
-
33
- rescue_from UserCredentials::InvalidCredentials do
34
- head 401, "X-Credentials" => "Invalid Credentials"
35
- end
36
-
37
- rescue_from UserCredentials::InsufficientPermissions do |exception|
38
- render plain: exception.message, status: 401
39
- end
40
-
41
29
  rescue_from ActiveRecord::RecordNotFound do
42
30
  render file: Houston.root.join("public/404"), layout: false
43
31
  end
@@ -139,6 +127,15 @@ class ApplicationController < ActionController::Base
139
127
 
140
128
 
141
129
 
130
+ def oauth_authorize!(klass, scope:, redirect_to: nil)
131
+ authorization = klass.for(current_user).find_or_create_by!(scope: scope)
132
+ raise ArgumentError, "authorization already exists" if authorization.granted?
133
+ session["#{authorization.id}_granted_redirect_url"] = redirect_to if redirect_to
134
+ redirect_to authorization.url
135
+ end
136
+
137
+
138
+
142
139
  def no_cache
143
140
  response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
144
141
  response.headers["Pragma"] = "no-cache"
@@ -1,9 +1,18 @@
1
1
  class AuthorizationsController < ApplicationController
2
+ before_action :authenticate_user!
3
+ before_action :find_authorization, only: [:edit, :update, :destroy, :grant, :granted]
2
4
 
3
5
  def index
4
6
  @title = "Authorizations"
5
- authorize! :read, Authorization
6
- @authorizations = Authorization.all
7
+ authorize! :read, :all_authorizations
8
+ @authorizations = Authorization.all.preload(:user)
9
+ end
10
+
11
+ def mine
12
+ @title = "My Authorizations"
13
+ authorize! :create, Authorization
14
+ @authorizations = current_user.authorizations
15
+ render action: :index
7
16
  end
8
17
 
9
18
  def new
@@ -13,49 +22,67 @@ class AuthorizationsController < ApplicationController
13
22
  end
14
23
 
15
24
  def create
16
- @authorization = Authorization.new(params[:authorization])
25
+ @authorization = current_user.authorizations.build(params[:authorization])
17
26
  authorize! :create, @authorization
18
27
 
19
28
  if @authorization.save
20
- redirect_to authorizations_path
29
+ redirect_to my_authorizations_path
21
30
  else
22
- render action: :new
31
+ render action: :new, error: @authorization.errors.full_messages.to_sentence
23
32
  end
24
33
  end
25
34
 
26
35
  def edit
27
36
  @title = "Edit Authorization"
28
- @authorization = Authorization.find params[:id]
29
- authorize! :update, Authorization
37
+ authorize! :update, @authorization
30
38
  end
31
39
 
32
40
  def update
33
- @authorization = Authorization.find params[:id]
34
- authorize! :update, Authorization
41
+ authorize! :update, @authorization
35
42
 
36
43
  if @authorization.update_attributes(params[:authorization])
37
- redirect_to authorizations_path
44
+ redirect_to my_authorizations_path
38
45
  else
39
46
  render action: :new
40
47
  end
41
48
  end
42
49
 
50
+ def destroy
51
+ authorize! :destroy, @authorization
52
+
53
+ @authorization.destroy
54
+ redirect_to my_authorizations_path, notice: "Authorization to #{@authorization.provider.name} revoked"
55
+ end
56
+
43
57
  def grant
44
- @authorization = Authorization.find(params[:id])
45
58
  if @authorization.granted?
46
59
  redirect_to authorizations_url, notice: "Already Granted"
47
60
  else
48
- puts "\e[96;4m#{@authorization.authorize_url}\e[0m"
49
61
  redirect_to @authorization.authorize_url
50
62
  end
51
63
  end
52
64
 
53
65
  def oauth2_callback
54
- authorization = Authorization.set_access_token! params
55
- redirect_to authorization_granted_url(authorization)
66
+ if params.key?(:code) && params.key?(:state)
67
+ authorization = Authorization.set_access_token! params
68
+ redirect_to authorization_granted_url(authorization)
69
+ else
70
+ @error = params.fetch(:error, "An unknown error occurred")
71
+ end
56
72
  end
57
73
 
58
74
  def granted
75
+ redirect_to session[granted_redirect] if session.key?(granted_redirect)
76
+ end
77
+
78
+ private
79
+
80
+ def granted_redirect
81
+ "#{@authorization.id}_granted_redirect_url"
82
+ end
83
+
84
+ def find_authorization
85
+ @authorization = Authorization.find(params[:id])
59
86
  end
60
87
 
61
88
  end