From 844bb1f6e7a693b352f164421399578c4901300b Mon Sep 17 00:00:00 2001 From: Robin K Wilson Date: Mon, 9 Aug 2021 11:53:15 -0700 Subject: [PATCH 01/10] included base_assets_path --- admin/src/react-components/fields.js | 8 ++++++-- admin/webpack.config.js | 3 ++- src/utils/phoenix-utils.js | 13 +++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/admin/src/react-components/fields.js b/admin/src/react-components/fields.js index 4257f0b379..f59d47ef5b 100644 --- a/admin/src/react-components/fields.js +++ b/admin/src/react-components/fields.js @@ -2,7 +2,7 @@ import React from "react"; import PropTypes from "prop-types"; import { withStyles } from "@material-ui/core/styles"; import LaunchIcon from "@material-ui/icons/Launch"; -import { getReticulumFetchUrl } from "hubs/src/utils/phoenix-utils"; +import { getReticulumFetchUrl, getAssetFetchUrl } from "hubs/src/utils/phoenix-utils"; import { ReferenceField } from "react-admin"; const styles = { @@ -39,11 +39,15 @@ ConditionalReferenceField.propTypes = { }; const OwnedFileImageInternal = withStyles(styles)(({ record = {}, aspect = "wide", classes }) => { - const src = getReticulumFetchUrl(`/files/${record.owned_file_uuid}`); + const src = getAssetFetchUrl(`/files/${record.owned_file_uuid}`); return ; }); export const OwnedFileImage = withStyles(styles)(({ basePath, record, source, aspect, classes, defaultImage }) => { + console.log(basePath); + console.log(source); + console.log(defaultImage); + return ( { ITA_SERVER: process.env.ITA_SERVER, RETICULUM_SERVER: process.env.RETICULUM_SERVER, CORS_PROXY_SERVER: process.env.CORS_PROXY_SERVER, - POSTGREST_SERVER: process.env.POSTGREST_SERVER + POSTGREST_SERVER: process.env.POSTGREST_SERVER, + BASE_ASSETS_PATH: process.env.BASE_ASSETS_PATH }) }) ] diff --git a/src/utils/phoenix-utils.js b/src/utils/phoenix-utils.js index 113a1b4117..c76e86dabc 100644 --- a/src/utils/phoenix-utils.js +++ b/src/utils/phoenix-utils.js @@ -45,6 +45,8 @@ let reticulumMeta = null; let invalidatedReticulumMetaThisSession = false; export function getReticulumFetchUrl(path, absolute = false, host = null, port = null) { + console.log(configs); + if (host || hasReticulumServer()) { return `https://${host || configs.RETICULUM_SERVER}${port ? `:${port}` : ""}${path}`; } else if (absolute) { @@ -55,6 +57,17 @@ export function getReticulumFetchUrl(path, absolute = false, host = null, port = } } +export function getAssetFetchUrl(path, absolute = false, host = null, port = null) { + if (host || hasReticulumServer()) { + return `https://${host || configs.BASE_ASSETS_PATH}${port ? `:${port}` : ""}${path}`; + } else if (absolute) { + resolverLink.href = path; + return resolverLink.href; + } else { + return path; + } +} + export async function getReticulumMeta() { if (!reticulumMeta) { // Initially look up version based upon page, avoiding round-trip, otherwise fetch. From 764553f8a503e5ae0913518adf01c29e05f79373 Mon Sep 17 00:00:00 2001 From: Robin K Wilson Date: Fri, 20 Aug 2021 11:27:22 -0700 Subject: [PATCH 02/10] added uploads host --- Jenkinsfile | 3 +++ scripts/hab-build-and-push.sh | 2 ++ src/utils/configs.js | 3 ++- webpack.config.js | 4 +++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b6471bfbc0..2f4e9c8974 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -34,6 +34,8 @@ pipeline { def disableDeploy = env.DISABLE_DEPLOY def showQAPromoteCommand = env.SHOW_QA_PROMOTE_COMMAND def qaBuildsSlackChannel = env.QA_BUILDS_SLACK_CHANNEL + def qaBuildsSlackChannel = env.QA_BUILDS_SLACK_CHANNEL + def uploadsHost = env.UPLOADS_HOST def habCommand = ( "/bin/bash scripts/hab-build-and-push.sh " @@ -49,6 +51,7 @@ pipeline { + "\\\"${buildNumber}\\\" " + "\\\"${gitCommit}\\\" " + "\\\"${disableDeploy}\\\" " + + "\\\"${uploadsHost}\\\" " ) runCommand(habCommand) diff --git a/scripts/hab-build-and-push.sh b/scripts/hab-build-and-push.sh index af16746f93..3b7f014753 100755 --- a/scripts/hab-build-and-push.sh +++ b/scripts/hab-build-and-push.sh @@ -12,6 +12,7 @@ export GA_TRACKING_ID=$9 export BUILD_NUMBER=${10} export GIT_COMMIT=${11} export DISABLE_DEPLOY=${12} +export UPLOADS_HOST=${13} export BUILD_VERSION="${BUILD_NUMBER} (${GIT_COMMIT})" # Build the package, upload it, and start the service so we deploy to staging target. @@ -53,6 +54,7 @@ cors_proxy_server = $CORS_PROXY_SERVER non_cors_proxy_domains = $NON_CORS_PROXY_DOMAINS sentry_dsn = $SENTRY_DSN ga_tracking_id = $GA_TRACKING_ID +uploads_host = $UPLOADS_HOST [deploy] type = "$DEPLOY_TYPE" diff --git a/src/utils/configs.js b/src/utils/configs.js index 5c7342c229..c7c7d646b9 100644 --- a/src/utils/configs.js +++ b/src/utils/configs.js @@ -16,7 +16,8 @@ let isAdmin = false; "SENTRY_DSN", "GA_TRACKING_ID", "SHORTLINK_DOMAIN", - "BASE_ASSETS_PATH" + "BASE_ASSETS_PATH", + "UPLOADS_HOST" ].forEach(x => { const el = document.querySelector(`meta[name='env:${x.toLowerCase()}']`); configs[x] = el ? el.getAttribute("content") : process.env[x]; diff --git a/webpack.config.js b/webpack.config.js index c656813cb5..a7aa942b50 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -229,7 +229,8 @@ module.exports = async (env, argv) => { BASE_ASSETS_PATH: "https://hubs.local:8080/", RETICULUM_SERVER: "hubs.local:4000", POSTGREST_SERVER: "", - ITA_SERVER: "" + ITA_SERVER: "", + UPLOADS_HOST: "https://hubs.local:4000" }); } } @@ -643,6 +644,7 @@ module.exports = async (env, argv) => { SENTRY_DSN: process.env.SENTRY_DSN, GA_TRACKING_ID: process.env.GA_TRACKING_ID, POSTGREST_SERVER: process.env.POSTGREST_SERVER, + UPLOADS_HOST: process.env.UPLOADS_HOST, APP_CONFIG: appConfig }) }) From 5a7f00c97764547520d5f2c5a260ad4305653178 Mon Sep 17 00:00:00 2001 From: Robin K Wilson Date: Fri, 20 Aug 2021 11:48:49 -0700 Subject: [PATCH 03/10] added getAssetsFetchUrl() to admin images --- admin/src/react-components/fields.js | 4 ++-- src/utils/phoenix-utils.js | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/admin/src/react-components/fields.js b/admin/src/react-components/fields.js index 4257f0b379..bfa645301f 100644 --- a/admin/src/react-components/fields.js +++ b/admin/src/react-components/fields.js @@ -2,7 +2,7 @@ import React from "react"; import PropTypes from "prop-types"; import { withStyles } from "@material-ui/core/styles"; import LaunchIcon from "@material-ui/icons/Launch"; -import { getReticulumFetchUrl } from "hubs/src/utils/phoenix-utils"; +import { getReticulumFetchUrl, getAssetsFetchUrl } from "hubs/src/utils/phoenix-utils"; import { ReferenceField } from "react-admin"; const styles = { @@ -39,7 +39,7 @@ ConditionalReferenceField.propTypes = { }; const OwnedFileImageInternal = withStyles(styles)(({ record = {}, aspect = "wide", classes }) => { - const src = getReticulumFetchUrl(`/files/${record.owned_file_uuid}`); + const src = getAssetsFetchUrl(`/files/${record.owned_file_uuid}`); return ; }); diff --git a/src/utils/phoenix-utils.js b/src/utils/phoenix-utils.js index 113a1b4117..bd7ba2bb50 100644 --- a/src/utils/phoenix-utils.js +++ b/src/utils/phoenix-utils.js @@ -55,6 +55,17 @@ export function getReticulumFetchUrl(path, absolute = false, host = null, port = } } +export function getAssetsFetchUrl(path, absolute = false, host = null, port = null) { + if (configs.UPLOADS_HOST || host || hasReticulumServer()) { + return `https://${configs.UPLOADS_HOST || host}${port ? `:${port}` : ""}${path}`; + } else if (absolute) { + resolverLink.href = path; + return resolverLink.href; + } else { + return path; + } +} + export async function getReticulumMeta() { if (!reticulumMeta) { // Initially look up version based upon page, avoiding round-trip, otherwise fetch. From 4e183ba73c7f00d595e8fd1d0ea532180287f8ef Mon Sep 17 00:00:00 2001 From: Robin K Wilson Date: Fri, 20 Aug 2021 12:43:11 -0700 Subject: [PATCH 04/10] added console.logs --- src/utils/phoenix-utils.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/utils/phoenix-utils.js b/src/utils/phoenix-utils.js index 4c1c4c9cd9..e60de85ca5 100644 --- a/src/utils/phoenix-utils.js +++ b/src/utils/phoenix-utils.js @@ -46,7 +46,7 @@ let invalidatedReticulumMetaThisSession = false; export function getReticulumFetchUrl(path, absolute = false, host = null, port = null) { console.log(configs); - + console.log("Inside getReticulumFetchUrl()"); if (host || hasReticulumServer()) { return `https://${host || configs.RETICULUM_SERVER}${port ? `:${port}` : ""}${path}`; } else if (absolute) { @@ -58,12 +58,18 @@ export function getReticulumFetchUrl(path, absolute = false, host = null, port = } export function getAssetsFetchUrl(path, absolute = false, host = null, port = null) { + console.log("Inside getAssetsFetchUrl()"); + console.log("UPLOADS_HOST"); + console.log(configs.UPLOADS_HOST); if (configs.UPLOADS_HOST || host || hasReticulumServer()) { - return `https://${configs.UPLOADS_HOST || host}${port ? `:${port}` : ""}${path}`; + console.log("getAssetsFetchUrl 1"); + return `https://${configs.UPLOADS_HOST}${port ? `:${port}` : ""}${path}`; } else if (absolute) { + console.log("getAssetsFetchUrl 2"); resolverLink.href = path; return resolverLink.href; } else { + console.log("getAssetsFetchUrl 3"); return path; } } From d9bf62971eb6200838c30064d3d4f950cbca41ed Mon Sep 17 00:00:00 2001 From: Robin K Wilson Date: Fri, 20 Aug 2021 13:02:56 -0700 Subject: [PATCH 05/10] fixed error in jenkins build --- Jenkinsfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2f4e9c8974..cfb35d5fb8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -34,7 +34,6 @@ pipeline { def disableDeploy = env.DISABLE_DEPLOY def showQAPromoteCommand = env.SHOW_QA_PROMOTE_COMMAND def qaBuildsSlackChannel = env.QA_BUILDS_SLACK_CHANNEL - def qaBuildsSlackChannel = env.QA_BUILDS_SLACK_CHANNEL def uploadsHost = env.UPLOADS_HOST def habCommand = ( From 227c43798ee28e582f8665a3a4054648bba71eaf Mon Sep 17 00:00:00 2001 From: Robin K Wilson Date: Fri, 20 Aug 2021 13:30:38 -0700 Subject: [PATCH 06/10] added console.log to test dev build --- admin/src/react-components/fields.js | 1 + 1 file changed, 1 insertion(+) diff --git a/admin/src/react-components/fields.js b/admin/src/react-components/fields.js index 84bba12077..70e0255bab 100644 --- a/admin/src/react-components/fields.js +++ b/admin/src/react-components/fields.js @@ -68,6 +68,7 @@ OwnedFileImage.propTypes = { }; function OwnedFileDownloadFieldInternal({ fileName, record, source }) { + console.log("OwnedFileDownloadFieldInternal()"); return ( Date: Fri, 20 Aug 2021 18:19:49 -0700 Subject: [PATCH 07/10] ternary for using UPLOADS_HOST --- src/utils/phoenix-utils.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/utils/phoenix-utils.js b/src/utils/phoenix-utils.js index e60de85ca5..1b0b444c2e 100644 --- a/src/utils/phoenix-utils.js +++ b/src/utils/phoenix-utils.js @@ -61,17 +61,10 @@ export function getAssetsFetchUrl(path, absolute = false, host = null, port = nu console.log("Inside getAssetsFetchUrl()"); console.log("UPLOADS_HOST"); console.log(configs.UPLOADS_HOST); - if (configs.UPLOADS_HOST || host || hasReticulumServer()) { - console.log("getAssetsFetchUrl 1"); - return `https://${configs.UPLOADS_HOST}${port ? `:${port}` : ""}${path}`; - } else if (absolute) { - console.log("getAssetsFetchUrl 2"); - resolverLink.href = path; - return resolverLink.href; - } else { - console.log("getAssetsFetchUrl 3"); - return path; - } + console.log(typeof configs.UPLOADS_HOST); + return configs.UPLOADS_HOST + ? `https://${configs.UPLOADS_HOST}${port ? `:${port}` : ""}${path}` + : getReticulumFetchUrl(path, absolute, host, port); } export async function getReticulumMeta() { From 3b0cdf9ab7887cfb9a4cf46548d8fdc1b1f03521 Mon Sep 17 00:00:00 2001 From: Robin K Wilson Date: Mon, 23 Aug 2021 10:40:27 -0700 Subject: [PATCH 08/10] removing console.logs --- admin/src/react-components/fields.js | 5 ----- src/utils/phoenix-utils.js | 6 ------ 2 files changed, 11 deletions(-) diff --git a/admin/src/react-components/fields.js b/admin/src/react-components/fields.js index 70e0255bab..c8422868a7 100644 --- a/admin/src/react-components/fields.js +++ b/admin/src/react-components/fields.js @@ -44,10 +44,6 @@ const OwnedFileImageInternal = withStyles(styles)(({ record = {}, aspect = "wide }); export const OwnedFileImage = withStyles(styles)(({ basePath, record, source, aspect, classes, defaultImage }) => { - console.log(basePath); - console.log(source); - console.log(defaultImage); - return ( Date: Mon, 23 Aug 2021 11:04:21 -0700 Subject: [PATCH 09/10] removed unnecessary BASE_ASSETS_PATH and added UPLOADS_HOST --- admin/webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/webpack.config.js b/admin/webpack.config.js index c3cdeeda1f..ccf6e4d0bd 100644 --- a/admin/webpack.config.js +++ b/admin/webpack.config.js @@ -225,7 +225,7 @@ module.exports = (env, argv) => { RETICULUM_SERVER: process.env.RETICULUM_SERVER, CORS_PROXY_SERVER: process.env.CORS_PROXY_SERVER, POSTGREST_SERVER: process.env.POSTGREST_SERVER, - BASE_ASSETS_PATH: process.env.BASE_ASSETS_PATH + UPLOADS_HOST: process.env.UPLOADS_HOST }) }) ] From 104a7151f1d8a81b4e16fb74aa1d8428712d6150 Mon Sep 17 00:00:00 2001 From: Robin K Wilson Date: Mon, 23 Aug 2021 11:15:21 -0700 Subject: [PATCH 10/10] rename to getUploadsUrl --- admin/src/react-components/fields.js | 6 +++--- src/utils/phoenix-utils.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/admin/src/react-components/fields.js b/admin/src/react-components/fields.js index c8422868a7..a5d033f52f 100644 --- a/admin/src/react-components/fields.js +++ b/admin/src/react-components/fields.js @@ -2,7 +2,7 @@ import React from "react"; import PropTypes from "prop-types"; import { withStyles } from "@material-ui/core/styles"; import LaunchIcon from "@material-ui/icons/Launch"; -import { getReticulumFetchUrl, getAssetsFetchUrl } from "hubs/src/utils/phoenix-utils"; +import { getReticulumFetchUrl, getUploadsUrl } from "hubs/src/utils/phoenix-utils"; import { ReferenceField } from "react-admin"; const styles = { @@ -39,7 +39,7 @@ ConditionalReferenceField.propTypes = { }; const OwnedFileImageInternal = withStyles(styles)(({ record = {}, aspect = "wide", classes }) => { - const src = getAssetsFetchUrl(`/files/${record.owned_file_uuid}`); + const src = getUploadsUrl(`/files/${record.owned_file_uuid}`); return ; }); @@ -67,7 +67,7 @@ function OwnedFileDownloadFieldInternal({ fileName, record, source }) { return ( diff --git a/src/utils/phoenix-utils.js b/src/utils/phoenix-utils.js index ff709155f0..818e4eb115 100644 --- a/src/utils/phoenix-utils.js +++ b/src/utils/phoenix-utils.js @@ -55,7 +55,7 @@ export function getReticulumFetchUrl(path, absolute = false, host = null, port = } } -export function getAssetsFetchUrl(path, absolute = false, host = null, port = null) { +export function getUploadsUrl(path, absolute = false, host = null, port = null) { return configs.UPLOADS_HOST ? `https://${configs.UPLOADS_HOST}${port ? `:${port}` : ""}${path}` : getReticulumFetchUrl(path, absolute, host, port);