11package org .labkey .nextflow ;
22
3- import lombok .Data ;
43import lombok .Getter ;
54import lombok .Setter ;
65import org .apache .commons .lang3 .StringUtils ;
98import org .labkey .api .action .ApiSimpleResponse ;
109import org .labkey .api .action .FormViewAction ;
1110import org .labkey .api .action .MutatingApiAction ;
12- import org .labkey .api .action .SimpleViewAction ;
1311import org .labkey .api .action .SpringActionController ;
1412import org .labkey .api .admin .AdminUrls ;
1513import org .labkey .api .data .PropertyManager ;
2220import org .labkey .api .security .AdminConsoleAction ;
2321import org .labkey .api .security .RequiresPermission ;
2422import org .labkey .api .security .permissions .AdminOperationsPermission ;
25- import org .labkey .api .security .permissions .InsertPermission ;
2623import org .labkey .api .security .permissions .ReadPermission ;
2724import org .labkey .api .security .permissions .SiteAdminPermission ;
2825import org .labkey .api .util .Button ;
3431import org .labkey .api .util .URLHelper ;
3532import org .labkey .api .util .element .Select ;
3633import org .labkey .api .util .logging .LogHelper ;
37- import org .labkey .api .view .ActionURL ;
3834import org .labkey .api .view .HtmlView ;
3935import org .labkey .api .view .JspView ;
4036import org .labkey .api .view .NavTree ;
4541import org .springframework .validation .Errors ;
4642import org .springframework .web .servlet .ModelAndView ;
4743
48- import javax .swing .text .html .FormView ;
49-
5044import java .io .File ;
51- import java .nio .file .Paths ;
5245import java .util .Arrays ;
5346import java .util .List ;
5447
6053import static org .labkey .api .util .DOM .Attribute .value ;
6154import static org .labkey .api .util .DOM .DIV ;
6255import static org .labkey .api .util .DOM .INPUT ;
63- import static org .labkey .api .util .DOM .LI ;
6456import static org .labkey .api .util .DOM .LK .FORM ;
6557import static org .labkey .api .util .DOM .UL ;
6658import static org .labkey .api .util .DOM .at ;
@@ -78,32 +70,6 @@ public NextFlowController()
7870 setActionResolver (_actionResolver );
7971 }
8072
81- @ RequiresPermission (ReadPermission .class )
82- public static class BeginAction extends SimpleViewAction <Object >
83- {
84- @ Override
85- public ModelAndView getView (Object o , BindException errors )
86- {
87- boolean enabled = NextFlowManager .get ().isEnabled (getContainer ());
88- return new HtmlView ("NextFlow" ,
89- DIV (
90- DIV ("NextFlow integration is " + (enabled ? "enabled" : "disabled" ) + " in this " + (getContainer ().isProject () ? "project" : "folder" ) + "." ),
91- DIV (
92- getContainer ().hasPermission (getUser (), SiteAdminPermission .class ) ?
93- new Button .ButtonBuilder ("Enable/Disable" ).href (new ActionURL (NextFlowEnableAction .class , getContainer ())).build () : null ,
94- " " ,
95- enabled && getContainer ().hasPermission (getUser (), InsertPermission .class ) ?
96- new Button .ButtonBuilder ("Run NextFlow Analysis" ).href (new ActionURL (NextFlowRunAction .class , getContainer ())).build () : null )));
97- }
98-
99- @ Override
100- public void addNavTrail (NavTree root )
101- {
102- root .addChild ("NextFlow" );
103- }
104- }
105-
106-
10773 @ RequiresPermission (SiteAdminPermission .class )
10874 public static class DeleteNextFlowConfigurationAction extends MutatingApiAction <Object >
10975 {
@@ -215,8 +181,8 @@ public void setEnabled(Boolean enabled)
215181 }
216182 }
217183
218- @ RequiresPermission (SiteAdminPermission .class )
219- public static class NextFlowEnableAction extends FormViewAction <EnabledForm >
184+ @ RequiresPermission (ReadPermission .class )
185+ public static class BeginAction extends FormViewAction <EnabledForm >
220186 {
221187 @ Override
222188 public void validateCommand (EnabledForm target , Errors errors )
@@ -227,21 +193,30 @@ public void validateCommand(EnabledForm target, Errors errors)
227193 @ Override
228194 public ModelAndView getView (EnabledForm form , boolean reshow , BindException errors )
229195 {
230- Boolean status = NextFlowManager .get ().getEnabledState (getContainer ());
231- boolean inheritedStatus = NextFlowManager .get ().isEnabled (getContainer ().getParent ());
232-
233- return new HtmlView ("Enable/Disable NextFlow" ,
234- FORM (at (method , "POST" ),
235- DIV (INPUT (at (type , "radio" , name , "enabled" , value , Boolean .TRUE .toString (), (status == Boolean .TRUE ? checked : null ), null )),
236- "Enabled" ),
237- DIV (INPUT (at (type , "radio" , name , "enabled" , value , Boolean .FALSE .toString (), (status == Boolean .FALSE ? checked : null ), null )),
238- "Disabled" ),
239- DIV (INPUT (at (type , "radio" , name , "enabled" , value , "" , (status == null ? checked : null ), null )),
240- getContainer ().isRoot () ?
241- "Unset" :
242- "Inherited from " + getContainer ().getParent ().getPath () + " (currently " + (inheritedStatus ? "enabled" : "disabled" ) + ")" ),
243- new Button .ButtonBuilder ("Save" ).submit (true ).build (), " " ,
244- new Button .ButtonBuilder ("Cancel" ).href (getContainer ().getStartURL (getUser ())).build ()));
196+ if (getUser ().hasSiteAdminPermission ())
197+ {
198+ Boolean status = NextFlowManager .get ().getEnabledState (getContainer ());
199+ boolean inheritedStatus = NextFlowManager .get ().isEnabled (getContainer ().getParent ());
200+
201+ return new HtmlView ("Enable or Disable NextFlow" ,
202+ FORM (at (method , "POST" ),
203+ DIV (INPUT (at (type , "radio" , name , "enabled" , value , Boolean .TRUE .toString (), (status == Boolean .TRUE ? checked : null ), null )),
204+ "Enabled" ),
205+ DIV (INPUT (at (type , "radio" , name , "enabled" , value , Boolean .FALSE .toString (), (status == Boolean .FALSE ? checked : null ), null )),
206+ "Disabled" ),
207+ DIV (INPUT (at (type , "radio" , name , "enabled" , value , "" , (status == null ? checked : null ), null )),
208+ getContainer ().isRoot () ?
209+ "Unset" :
210+ "Inherited from " + getContainer ().getParent ().getPath () + " (currently " + (inheritedStatus ? "enabled" : "disabled" ) + ")" ),
211+ new Button .ButtonBuilder ("Save" ).submit (true ).build (), " " ,
212+ new Button .ButtonBuilder ("Cancel" ).href (getContainer ().getStartURL (getUser ())).build ()));
213+ }
214+ else
215+ {
216+ return new HtmlView ("NextFlow Integration Status" ,
217+ DIV ("NextFlow integration is " + (NextFlowManager .get ().isEnabled (getContainer ()) ? "enabled" : "disabled" ) + " in this " + (getContainer ().isProject () ? "project" : "folder" ) + "." )
218+ );
219+ }
245220 }
246221
247222 @ Override
@@ -254,7 +229,7 @@ public boolean handlePost(EnabledForm form, BindException errors)
254229 @ Override
255230 public void addNavTrail (NavTree root )
256231 {
257- root .addChild ("Enable/Disable NextFlow" );
232+ root .addChild ("NextFlow Integration Status " );
258233 }
259234
260235 @ Override
0 commit comments