Skip to content

Commit df2a57d

Browse files
committed
Render file watcher run as field as a dropdown
1 parent fc41c88 commit df2a57d

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

api/src/org/labkey/api/pipeline/PipelineJobService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.labkey.api.data.Container;
2222
import org.labkey.api.formSchema.FormSchema;
2323
import org.labkey.api.pipeline.file.PathMapper;
24+
import org.labkey.api.security.User;
2425
import org.labkey.api.util.QuietCloser;
2526

2627
import java.io.FileNotFoundException;
@@ -192,7 +193,7 @@ enum LocationType
192193
RemoteExecutionEngine
193194
}
194195

195-
FormSchema getFormSchema(Container container);
196+
FormSchema getFormSchema(Container container, User user);
196197

197198
/** @return true if the current instance is the web server, which has access to more resources including the
198199
* primary database, or false if we're on a remote server

pipeline/src/org/labkey/pipeline/api/PipelineJobServiceImpl.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
import org.labkey.api.pipeline.trigger.PipelineTriggerRegistry;
6666
import org.labkey.api.pipeline.trigger.PipelineTriggerType;
6767
import 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;
6871
import org.labkey.api.util.FileUtil;
6972
import org.labkey.api.util.JunitUtil;
7073
import 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
);

pipeline/src/org/labkey/pipeline/createPipelineTrigger.jsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
6060
String uniqueId = "" + UniqueID.getServerSessionScopedUID();
6161
String appId = "create-pipeline-trigger-" + uniqueId;
62-
FormSchema detailsFormSchema = PipelineJobService.get().getFormSchema(getContainer());
62+
FormSchema detailsFormSchema = PipelineJobService.get().getFormSchema(getContainer(), getUser());
6363
Map<String, FormSchema> taskFormSchemas = new HashMap<>();
6464
Map<String, FormSchema> customFieldFormSchemas = new HashMap<>();
6565
Map<String, String> tasksHelpText = new HashMap<>();

0 commit comments

Comments
 (0)