Skip to content

Commit

Permalink
Merge branch 'develop' into UIP-45-add-text-only-output
Browse files Browse the repository at this point in the history
  • Loading branch information
briehl committed Jul 16, 2024
2 parents 34cda5e + 949dac9 commit d0d493c
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 46 deletions.
8 changes: 4 additions & 4 deletions .github/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@master
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
Expand All @@ -25,15 +25,15 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@master
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3
uses: github/codeql-action/autobuild@master

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -47,4 +47,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@master
10 changes: 5 additions & 5 deletions .github/workflows/build_and_push_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
name: Check out GitHub Repo
with:
ref: "${{ github.event.pull_request.head.sha }}"
uses: actions/checkout@v4
uses: actions/checkout@main
-
name: Set up environment
run: |
Expand All @@ -42,17 +42,17 @@ jobs:
run: echo "date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@master
-
name: Log in to the Container registry
uses: docker/login-action@v3
uses: docker/login-action@master
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_TOKEN }}
-
name: Build narrative image
uses: docker/build-push-action@v5
uses: docker/build-push-action@master
with:
context: .
file: ./Dockerfile
Expand All @@ -67,7 +67,7 @@ jobs:
TAG='${{ github.ref }}'
-
name: Build version image
uses: docker/build-push-action@v5
uses: docker/build-push-action@master
if: ${{ github.base_ref }} == 'main' || ${{ github.base_ref }} == 'develop'
with:
context: .
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:
steps:
-
name: Log in to the Container registry
uses: docker/login-action@v3
uses: docker/login-action@master
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_TOKEN }}
-
name: Repo checkout
uses: actions/checkout@v4
uses: actions/checkout@master
-
name: Set up environment
run: |
Expand All @@ -48,7 +48,7 @@ jobs:
run: docker pull ${{ env.APP_IMAGE_TAG }}
-
name: Use Node JS 20
uses: actions/setup-node@v4
uses: actions/setup-node@master
with:
node-version: 20
-
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tag_latest_image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
- name: Check out GitHub Repo
with:
ref: "${{ github.event.pull_request.head.sha }}"
uses: actions/checkout@v4
uses: actions/checkout@master
-
name: Log in to the Container registry
uses: docker/login-action@v3
uses: docker/login-action@master
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:
steps:
-
name: Log in to the Container registry
uses: docker/login-action@v3
uses: docker/login-action@master
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_TOKEN }}
-
name: Repo checkout
uses: actions/checkout@v4
uses: actions/checkout@master
-
name: Set up environment
run: |
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
continue-on-error: true
-
name: Use Node JS 20
uses: actions/setup-node@v4
uses: actions/setup-node@main
with:
node-version: 20
-
Expand All @@ -76,7 +76,7 @@ jobs:
-
name: Send to Codecov
id: send_to_codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@main
continue-on-error: true
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ define([
Events,
OutputWidget
) => {
'use strict';
return KBWidget({
name: 'kbaseReportView',
version: '1.0.0',
Expand Down Expand Up @@ -86,26 +85,15 @@ define([
},

/**
* This builds a link to the data_import_export service for downloading some file from
* This builds a link to the Blobstore service for downloading some file from
* a shock node. This gets used for downloading files referenced from the report object.
* If the given url is not really a shock node, this returns null.
* @param {string} shockUrl - the URL to the shock node containing some file to fetch
* @param {string} name - the name of the file to download
*/
importExportLink: function (shockUrl, name) {
importExportLink: function (shockUrl) {
const m = shockUrl.match(/\/node\/(.+)$/);
if (m) {
const query = {
id: m[1],
wszip: 0,
name: name,
};
const queryString = Object.keys(query)
.map((key) => {
return [key, query[key]].map(encodeURIComponent).join('=');
})
.join('&');
return Config.url('data_import_export') + '/download?' + queryString;
return `${Config.url('blobstore')}/node/${m[1]}?download`;
}
return null;
},
Expand Down Expand Up @@ -479,25 +467,24 @@ define([

const downloadIframeId = 'file-download-' + new UUID(4).format();
const linkList = ul(
fileLinks.map((link, idx) => {
fileLinks.map((link) => {
const linkText = link.name || link.URL;
const dlLink = this.importExportLink(link.URL);
return li(
a(
{
id: events.addEvent({
type: 'click',
handler: () => {
const dlLink = this.importExportLink(
link.URL,
link.name || 'download-' + idx
);
handler: (e) => {
e.preventDefault();
ui.getElement(downloadIframeId).setAttribute('src', dlLink);
},
}),
class: this.baseCssClass + '__download_button',
type: 'button',
ariaLabel: `download file ${linkText}`,
download: 'download',
href: dlLink,
},
linkText
)
Expand Down
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions test/unit/spec/function_output/kbaseReportView-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ define([
'narrativeConfig',
'testUtil',
], (ReportView, Jupyter, $, Mocks, Config, TestUtil) => {
'use strict';
const FAKE_SERV_URL = 'https://ci.kbase.us/report_serv';
const REPORT_REF = '1/2/3';

Expand Down Expand Up @@ -330,10 +329,8 @@ define([
badUrl = 'https://ci.kbase.us/not/a/shock/url';
expect(reportWidget.importExportLink(badUrl, name)).toBeNull();
const result = reportWidget.importExportLink(goodUrl, name);
expect(result).toMatch(new RegExp('^' + Config.url('data_import_export')));
expect(result).toContain('wszip=0');
expect(result).toContain('name=some_file.txt');
expect(result).toContain('id=' + shockNode);
expect(result).toMatch(new RegExp('^' + Config.url('blobstore')));
expect(result).toContain('/node/' + shockNode + '?download');
});

it('should respond to errors by rendering an error string', async function () {
Expand Down Expand Up @@ -416,7 +413,7 @@ define([
const fileInfo = REPORT_OBJ.file_links[0];
const fileUrlParts = fileInfo.URL.split('/');
const fileNode = fileUrlParts[fileUrlParts.length - 1];
const expectedUrl = `${Config.url('data_import_export')}/download?id=${fileNode}&wszip=0&name=${fileInfo.name}`;
const expectedUrl = `${Config.url('blobstore')}/node/${fileNode}?download`;
expect(dlIframe.getAttribute('src')).toEqual(expectedUrl);
});
});
Expand Down

0 comments on commit d0d493c

Please sign in to comment.