File tree Expand file tree Collapse file tree 5 files changed +62
-18
lines changed Expand file tree Collapse file tree 5 files changed +62
-18
lines changed Original file line number Diff line number Diff line change 25
25
</div >
26
26
<div id =" navbar_menu" class =" navbar-menu" >
27
27
<div class =" navbar-start" >
28
- {% for item in main_nav %}
29
- {% set selected = is_current_path(item .route ) %}
30
- <a class =" navbar-item{% if item .class %} {{ item .class }}{% endif %}{% if selected %} is-active{% endif %}" href =" {{ path_for(item .route ) }}" {% if selected %} aria-current =" page" {% endif %}>{{ item .name }}</a >
31
- {% endfor %}
28
+ <div class =" navbar-item has-dropdown is-hoverable" >
29
+ <a class =" navbar-link" >Projects</a >
30
+
31
+ <div class =" navbar-dropdown" >
32
+ <div class =" navbar-item" ><strong >Favourites</strong ></div >
33
+ {% set faves = current_favourites() %}
34
+ {% if 0 < faves | length %}
35
+ {% for fave in faves %}
36
+ <a class =" navbar-item" href =" {{ path_for(' project.view' , { key : fave .key }) }}" >
37
+ {{ fave .name }}
38
+ </a >
39
+ {% endfor %}
40
+ {% else %}
41
+ <div class =" navbar-item" ><p >Click the star icon on the project list or<br /> project view to set your favourites</p ></div >
42
+ {% endif %}
43
+ <hr class =" navbar-divider" >
44
+ <a class =" navbar-item" href =" {{ path_for(' project.index' ) }}" >
45
+ All Projects
46
+ </a >
47
+ </div >
48
+ </div >
49
+
50
+ <a class =" navbar-item" href =" {{ path_for(' project.add' ) }}" >Add Project</a >
32
51
</div >
33
52
34
53
<div class =" navbar-end" >
35
- <div class =" navbar-item has-dropdown" >
54
+ <div class =" navbar-item has-dropdown is-hoverable " >
36
55
<a class =" navbar-link" >
37
56
{{ security .name }}
38
57
</a >
Original file line number Diff line number Diff line change @@ -233,6 +233,9 @@ public function deploy(
233
233
Router::pathFor ('project.index ' )
234
234
);
235
235
}
236
+ if (!$ project ->isDeployable ()) {
237
+ throw new RuntimeException ('Project is not deployable at the moment ' );
238
+ }
236
239
$ input = $ request ->getParsedBodyParam ('project ' , []);
237
240
$ type = 'branch ' ;
238
241
$ branch = (!isset ($ input ['branch ' ]) || empty ($ input ['branch ' ])) ? $ project ->branch : $ input ['branch ' ];
Original file line number Diff line number Diff line change @@ -19,12 +19,16 @@ class ProjectFinder extends Finder
19
19
* @return array
20
20
* @author Ronan Chilvers <ronan@d3r.com>
21
21
*/
22
- public function all ()
22
+ public function all (array $ ids = null )
23
23
{
24
- return $ this ->select ()
24
+ $ select = $ this ->select ()
25
25
->orderBy (Project::prefix ('last_deployment ' ), 'desc ' )
26
26
->orderBy (Project::prefix ('repository ' ), 'asc ' )
27
- ->execute ();
27
+ ;
28
+ if (is_array ($ ids )) {
29
+ $ select ->where (Project::primaryKey (), 'IN ' , $ ids );
30
+ }
31
+ return $ select ->execute ();
28
32
}
29
33
30
34
/**
Original file line number Diff line number Diff line change @@ -88,16 +88,6 @@ public function register(Container $container)
88
88
'session ' => $ c ->get ('session ' ),
89
89
'request ' => $ c ->get ('request ' ),
90
90
'security ' => $ c ->get (Manager::class),
91
- 'main_nav ' => [
92
- [
93
- 'name ' => 'Project List ' ,
94
- 'route ' => 'project.index ' ,
95
- ],
96
- [
97
- 'name ' => 'Add Project ' ,
98
- 'route ' => 'project.add ' ,
99
- ],
100
- ],
101
91
'php ' => [
102
92
'version ' => phpversion (),
103
93
],
Original file line number Diff line number Diff line change 2
2
3
3
namespace App \Twig ;
4
4
5
+ use App \Facades \Security ;
5
6
use App \Model \Project ;
6
7
use App \Provider \Factory ;
7
8
use App \Security \Manager ;
8
9
use Carbon \Carbon ;
9
10
use Ronanchilvers \Foundation \Traits \Optionable ;
11
+ use Ronanchilvers \Orm \Orm ;
10
12
use Ronanchilvers \Utility \Str ;
11
13
use Twig \Extension \AbstractExtension ;
12
14
use Twig \Markup ;
@@ -69,6 +71,10 @@ public function getFunctions()
69
71
'sha_link ' ,
70
72
[$ this , 'shaLink ' ]
71
73
),
74
+ new TwigFunction (
75
+ 'current_favourites ' ,
76
+ [$ this , 'getCurrentFavourites ' ]
77
+ ),
72
78
];
73
79
}
74
80
@@ -199,4 +205,26 @@ public function humanDate(Carbon $carbon = null)
199
205
200
206
return $ carbon ->diffForHumans (['parts ' => 2 ]);
201
207
}
208
+
209
+ /**
210
+ * Get the favourite projects for the current user
211
+ *
212
+ * @return []
213
+ * @author Ronan Chilvers <ronan@d3r.com>
214
+ */
215
+ public function getCurrentFavourites ()
216
+ {
217
+ $ user = Security::user ();
218
+ $ userFavourites = $ user ->preference (
219
+ 'favourites ' ,
220
+ []
221
+ );
222
+ if (empty ($ userFavourites )) {
223
+ return [];
224
+ }
225
+
226
+ return Orm::finder (Project::class)->all (
227
+ $ userFavourites
228
+ );
229
+ }
202
230
}
You can’t perform that action at this time.
0 commit comments