Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CDN to load azure blob browser lib #2348

Merged
merged 5 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion browser-test/browser-test-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ services:
- 8033:3380

civiform:
image: civiform
image: civiform-dev
restart: always
container_name: civiform-test
links:
Expand Down
4 changes: 2 additions & 2 deletions browser-test/src/dev_file_upload.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('the dev file upload page', () => {
expect(await page.textContent('h1')).toContain('Dev file upload')

await page.setInputFiles('input[type=file]', {
name: 'file.txt',
name: 'my-test-file.txt',
mimeType: 'text/plain',
buffer: Buffer.from('this is test'),
})
Expand All @@ -22,7 +22,7 @@ describe('the dev file upload page', () => {
await waitForPageJsLoad(page)

expect(await page.textContent('h1')).toContain('Dev file upload')
expect(await page.content()).toContain('dev/file.txt')
expect(await page.textContent('table')).toContain('my-test-file.txt')

await endSession(browser)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public Tag renderFileUploadBlockSubmitForms(
return div(formTag, skipForms, buttons)
.withId("azure-upload-form-component")
.with(
footer(viewUtils.makeWebJarsTag(WebJarJsPaths.AZURE_STORAGE_BLOB)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Is it worth creating a separate issue tracking reverting to this path once the Azure issue is fixed upstream? We could then add a TODO against it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

footer(viewUtils.makeAzureBlobStoreScriptTag()),
footer(viewUtils.makeLocalJsTag("azure_upload")));
}

Expand Down
12 changes: 12 additions & 0 deletions universal-application-tool-0.0.1/app/views/ViewUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ public final class ViewUtils {
this.assetsFinder = checkNotNull(assetsFinder);
}

/**
* Generates an HTML script tag for loading the Azure Blob Storage client library from the
* jsdelivr.net CDN. TOOD(https://github.com/seattle-uat/civiform/issues/2349): Stop using this.
*/
public Tag makeAzureBlobStoreScriptTag() {
return script()
.withSrc("https://cdn.jsdelivr.net/npm/@azure/storage-blob@10.5.0")
.withType("text/javascript")
.attr("crossorigin", "anonymous")
.attr("integrity", "sha256-VFdCcG0JBuOTN0p15rwVT5EIuL7bzWMYi4aD6KeDqus=");
}

/**
* Generates an HTML script tag for loading the javascript file found at
* public/javascripts/[filename].js.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import services.cloud.azure.BlobStorageUploadRequest;
import views.HtmlBundle;
import views.ViewUtils;
import views.WebJarJsPaths;

/** Strategy class for creating a file upload form for Azure. */
public class AzureStorageDevViewStrategy implements CloudStorageDevViewStrategy {
Expand All @@ -44,9 +43,8 @@ public ContainerTag getFileUploadForm(
+ " upload request type.");
}
BlobStorageUploadRequest request = (BlobStorageUploadRequest) storageUploadRequest;
bundle.addFooterScripts(
viewUtils.makeWebJarsTag(/* assetsRoute= */ WebJarJsPaths.AZURE_STORAGE_BLOB));
bundle.addFooterScripts(viewUtils.makeLocalJsTag(/* filename= */ "azure_upload"));

bundle.addFooterScripts(viewUtils.makeAzureBlobStoreScriptTag());

ContainerTag formTag =
form()
Expand Down
3 changes: 0 additions & 3 deletions universal-application-tool-0.0.1/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ lazy val excludeTailwindGeneration = Seq(watchSources := {
JsEngineKeys.engineType := JsEngineKeys.EngineType.Node

resolvers += "Shibboleth" at "https://build.shibboleth.net/nexus/content/groups/public"
libraryDependencies ++= Seq(
"org.webjars.npm" % "azure__storage-blob" % "10.5.0"
)
dependencyOverrides ++= Seq(
"com.fasterxml.jackson.core" % "jackson-databind" % "2.13.2.2",
"com.fasterxml.jackson.core" % "jackson-core" % "2.13.2",
Expand Down