6565import org .labkey .api .pipeline .trigger .PipelineTriggerRegistry ;
6666import org .labkey .api .pipeline .trigger .PipelineTriggerType ;
6767import org .labkey .api .reports .report .r .RReport ;
68+ import org .labkey .api .security .SecurityManager ;
69+ import org .labkey .api .security .User ;
70+ import org .labkey .api .security .permissions .InsertPermission ;
6871import org .labkey .api .util .FileUtil ;
6972import org .labkey .api .util .JunitUtil ;
7073import org .labkey .api .util .MemTracker ;
@@ -672,7 +675,7 @@ public PipelineStatusFile.JobStore getJobStore()
672675 }
673676
674677 @ Override
675- public FormSchema getFormSchema (Container container )
678+ public FormSchema getFormSchema (Container container , User user )
676679 {
677680 List <Option <String >> typeOptions = new ArrayList <>();
678681 for (PipelineTriggerType <?> pipelineTriggerType : PipelineTriggerRegistry .get ().getTypes ())
@@ -696,7 +699,13 @@ public FormSchema getFormSchema(Container container)
696699 for (FileAnalysisTaskPipeline task : tasks )
697700 taskOptions .add (new Option <>(task .getId ().toString (), task .getDescription ()));
698701
699- String usernameHelpText = "The file watcher will run as this user in the pipeline. Some tasks may require this user to have admin permissions." ;
702+ List <Option <String >> userOptions = new ArrayList <>(SecurityManager .getUsersWithPermissions (container , Set .of (InsertPermission .class )).stream ()
703+ .map (u -> new Option <>(u .getDisplayName (user ), u .getDisplayName (user )))
704+ .toList ());
705+ // allow empty selection
706+ userOptions .add (new Option <>("" , "" ));
707+
708+ String usernameHelpText = "The file watcher will run as this user in the pipeline. Users in this list have insert permissions for the folder. Some tasks may require this user to have admin permissions." ;
700709 String assayProviderHelpText = "Use this provider for running assay import runs. This will be the name of the assay type eg : General or " +
701710 "the name of a module based assay." ;
702711 String baseHref = "https://www.labkey.org/Documentation/wiki-page.view?name=fileWatchCreate#" ;
@@ -708,7 +717,7 @@ public FormSchema getFormSchema(Container container)
708717 new TextareaField ("description" , "Description" , null , false , "" ),
709718 new SelectField <>("type" , "Type" , null , true , typeDefaultValue , typeOptions ),
710719 new SelectField <>("pipelineId" , "Pipeline Task" , "Select a Pipeline Task" , true , null , taskOptions ),
711- new TextField ("username" , "Run as Username" , null , false , null , usernameHelpText , usernameHref ),
720+ new SelectField ("username" , "Run as Username" , null , false , "" , userOptions , usernameHelpText , usernameHref ),
712721 new TextField ("assay provider" , "Assay Provider" , "General" , false , null , assayProviderHelpText , assayProviderHref ),
713722 new CheckboxField ("enabled" , "Enable this Trigger" , false , true )
714723 );
0 commit comments