Skip to content

Commit 660ad2d

Browse files
committed
Front end changes for packed workflow support
1 parent 0656251 commit 660ad2d

File tree

7 files changed

+57
-12
lines changed

7 files changed

+57
-12
lines changed

src/main/java/org/commonwl/view/workflow/WorkflowController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ public ModelAndView createWorkflow(@Valid WorkflowForm workflowForm, BindingResu
143143
bindingResult.rejectValue("url", "git.retrievalError");
144144
return new ModelAndView("index");
145145
} catch (WorkflowNotFoundException ex) {
146-
logger.warn("git.pathTraversal " + workflowForm , ex);
147-
bindingResult.rejectValue("url", "git.pathTraversal");
146+
logger.warn("git.notFound " + workflowForm , ex);
147+
bindingResult.rejectValue("url", "git.notFound");
148148
return new ModelAndView("index");
149149
} catch (Exception ex) {
150150
logger.warn("url.parsingError " + workflowForm , ex);
@@ -503,8 +503,8 @@ private ModelAndView getWorkflow(GitDetails gitDetails, RedirectAttributes redir
503503
logger.error("git.retrievalError " + workflowForm, ex);
504504
errors.rejectValue("url", "git.retrievalError", "The workflow could not be retrieved from the Git repository using the details given");
505505
} catch (WorkflowNotFoundException ex) {
506-
logger.warn("git.pathTraversal " + workflowForm, ex);
507-
errors.rejectValue("url", "git.pathTraversal", "The path given did not resolve to a location within the repository");
506+
logger.warn("git.notFound " + workflowForm, ex);
507+
errors.rejectValue("url", "git.notFound", "The workflow could not be found within the repository");
508508
} catch (IOException ex) {
509509
logger.warn("git.parsingError " + workflowForm, ex);
510510
errors.rejectValue("url", "url.parsingError", "The workflow could not be parsed from the given URL");

src/main/resources/messages.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ branch.emptyOrWhitespace = You must provide a branch where the workflow exists
33
path.emptyOrWhitespace = You must provide a path to the workflow within the repository
44

55
git.retrievalError = The workflow could not be retrieved from the Git repository using the details given
6-
git.pathTraversal = The path given did not resolve to a location within the repository
6+
git.notFound = The workflow could not be found within the repository
77
git.sshError = SSH URLs are not supported, please provide a HTTPS URL for the repository or submodules
88

99
url.parsingError = An unexpected error occurred when parsing the workflow
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
/**
21+
* RequireJS configuration with all possible dependencies
22+
*/
23+
requirejs.config({
24+
baseUrl: '/bower_components',
25+
paths: {
26+
'jquery': 'jquery/dist/jquery.min'
27+
}
28+
});
29+
30+
/**
31+
* Redirect with URL escaping for # parameters referring to subworkflows
32+
*/
33+
require(['jquery'],
34+
function ($) {
35+
var hashValue = window.location.hash.substr(1);
36+
$(".filename").each(function() {
37+
var workflowLink = $(this).parent("a").attr("href");
38+
if (workflowLink.endsWith("%23" + hashValue)) {
39+
window.location.replace(workflowLink);
40+
}
41+
});
42+
});

src/main/resources/templates/apidocs.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ <h4>Success 200</h4>
137137
<td>String</td>
138138
<td>Path to the workflow within the repository</td>
139139
</tr>
140+
<tr>
141+
<td>retrievedFrom.packedId</td>
142+
<td>String</td>
143+
<td>The ID of the workflow within the file, if this is a packed CWL file (contains a <a href="http://www.commonwl.org/draft-3/SchemaSalad.html#Document_graph">document graph</a>).</td>
144+
</tr>
140145
<tr>
141146
<td>retrievedFrom.url</td>
142147
<td>URL</td>
@@ -162,11 +167,6 @@ <h4>Success 200</h4>
162167
<td>String</td>
163168
<td>The last commit ID on the branch</td>
164169
</tr>
165-
<tr>
166-
<td>packedWorkflowID</td>
167-
<td>String</td>
168-
<td>The ID of the workflow within the file, if this is a packed CWL file (contains a <a href="http://www.commonwl.org/draft-3/SchemaSalad.html#Document_graph">document graph</a>).</td>
169-
</tr>
170170
<tr>
171171
<td>label</td>
172172
<td>String</td>

src/main/resources/templates/selectworkflow.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ <h1 th:text="'Choose Workflow from ' + ${gitDetails.path}">Choose Workflow</h1>
3939
</div>
4040
<div class="list-group">
4141
<a href="#" class="list-group-item" th:each="workflowOverview : ${workflowOverviews}" th:href="@{${gitDetails.getInternalUrl()} + ${workflowOverview.fileName.replace('#', '%23')}}">
42-
<h4 class="list-group-item-heading" th:text="${workflowOverview.fileName.replaceFirst('^/', '')}">ExampleWorkflow.cwl</h4>
42+
<h4 class="filename list-group-item-heading" th:text="${workflowOverview.fileName.replaceFirst('^/', '')}">ExampleWorkflow.cwl</h4>
4343
<p class="list-group-item-text">
4444
<span th:if="${workflowOverview.label != null}" th:text="${workflowOverview.label}">Label</span>
4545
<i th:if="${workflowOverview.doc != null}" th:text="' - ' + ${workflowOverview.doc}">Doc</i>
@@ -51,5 +51,7 @@ <h4 class="list-group-item-heading" th:text="${workflowOverview.fileName.replace
5151
</div>
5252

5353
<div th:replace="fragments/footer :: copy"></div>
54+
55+
<script src="/bower_components/requirejs/require.js" data-main="/js/selectworkflow.js"></script>
5456
</body>
5557
</html>

src/main/resources/templates/workflow.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ <h2>Steps</h2>
233233
<td th:text="${step.key}">ID</td>
234234
<td>
235235
<div th:if="${step.value.runType != null}">
236-
<a th:if="${step.value.runType.name() == 'WORKFLOW'}" th:href="@{${step.value.run}}" th:text="${step.value.run}" class="subworkflow">workflow.cwl</a>
236+
<a th:if="${step.value.runType.name() == 'WORKFLOW'}" th:href="@{${step.value.run.replace('#', '%23')}}" th:text="${step.value.run}" class="subworkflow">workflow.cwl</a>
237237
<span th:unless="${step.value.runType.name() == 'WORKFLOW'}" th:text="${step.value.run}">cmdlinetool.cwl</span>
238238
(<span th:text="${step.value.runType}">Workflow</span>)
239239
</div>

src/main/resources/templates/workflows.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ <h3>Showing results for "<span th:text="${search}">query</span>" <a href="/workf
7878
</a>
7979
<p th:if="${workflow.retrievedFrom.path != null}">Path: <i th:text="${workflow.retrievedFrom.path}">/path/to/workflow.cwl</i></p>
8080
<p>Branch/Commit ID: <i th:text="${workflow.retrievedFrom.branch}">master</i></p>
81+
<p th:if="${workflow.retrievedFrom.packedId != null}">Packed ID: <i th:text="${workflow.retrievedFrom.packedId}">#main</i></p>
8182
</td>
8283
<td><a th:href="@{${workflow.retrievedFrom.getInternalUrl()}}"><span class="icon-view glyphicon glyphicon-chevron-right"></span></a></td>
8384
</tr>

0 commit comments

Comments
 (0)