Skip to content

Commit

Permalink
fix: sw-2353 export extension, tar to zip
Browse files Browse the repository at this point in the history
* docs, add dotenv params, descriptions
* dotenv, add params for mime type, extension
* helpers, pass dotenv params
* platformServices, apply params type, extension
  • Loading branch information
cdcabrera committed Aug 1, 2024
1 parent 7908293 commit 6174c6b
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 48 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ REACT_APP_AJAX_POLL_INTERVAL=5000
REACT_APP_SELECTOR_CACHE=120000

REACT_APP_CONFIG_EXPORT_EXPIRE=86400000
REACT_APP_CONFIG_EXPORT_FILE_EXT=zip
REACT_APP_CONFIG_EXPORT_FILE_TYPE=application/gzip
REACT_APP_CONFIG_EXPORT_FILENAME=swatch_report_{0}
REACT_APP_CONFIG_EXPORT_SERVICE_NAME_PREFIX=swatch

Expand Down
94 changes: 50 additions & 44 deletions CONTRIBUTING.md

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion src/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ Download the debug log file.
* [~REVIEW_MODE](#Helpers.module_General..REVIEW_MODE) : <code>boolean</code>
* [~TEST_MODE](#Helpers.module_General..TEST_MODE) : <code>boolean</code>
* [~CONFIG_EXPORT_EXPIRE](#Helpers.module_General..CONFIG_EXPORT_EXPIRE) : <code>string</code>
* [~CONFIG_EXPORT_FILE_EXT](#Helpers.module_General..CONFIG_EXPORT_FILE_EXT) : <code>string</code>
* [~CONFIG_EXPORT_FILE_TYPE](#Helpers.module_General..CONFIG_EXPORT_FILE_TYPE) : <code>string</code>
* [~CONFIG_EXPORT_FILENAME](#Helpers.module_General..CONFIG_EXPORT_FILENAME) : <code>string</code>
* [~CONFIG_EXPORT_SERVICE_NAME_PREFIX](#Helpers.module_General..CONFIG_EXPORT_SERVICE_NAME_PREFIX) : <code>string</code>
* [~UI_DEPLOY_PATH_PREFIX](#Helpers.module_General..UI_DEPLOY_PATH_PREFIX) : <code>string</code>
Expand Down Expand Up @@ -432,11 +434,23 @@ Associated with running unit tests. See dotenv config files for activation.
### General~CONFIG\_EXPORT\_EXPIRE : <code>string</code>
CONFIG export download file expiration.

**Kind**: inner constant of [<code>General</code>](#Helpers.module_General)
<a name="Helpers.module_General..CONFIG_EXPORT_FILE_EXT"></a>

### General~CONFIG\_EXPORT\_FILE\_EXT : <code>string</code>
CONFIG export download file extension.

**Kind**: inner constant of [<code>General</code>](#Helpers.module_General)
<a name="Helpers.module_General..CONFIG_EXPORT_FILE_TYPE"></a>

### General~CONFIG\_EXPORT\_FILE\_TYPE : <code>string</code>
CONFIG export download file mime type.

**Kind**: inner constant of [<code>General</code>](#Helpers.module_General)
<a name="Helpers.module_General..CONFIG_EXPORT_FILENAME"></a>

### General~CONFIG\_EXPORT\_FILENAME : <code>string</code>
CONFIG export download file name. Extension is handled at the service level.
CONFIG export download file name.

**Kind**: inner constant of [<code>General</code>](#Helpers.module_General)
<a name="Helpers.module_General..CONFIG_EXPORT_SERVICE_NAME_PREFIX"></a>
Expand Down
6 changes: 6 additions & 0 deletions src/common/__tests__/__snapshots__/helpers.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ exports[`Helpers should expose a window object: limited window object 1`] = `
{
"CONFIG_EXPORT_EXPIRE": "86400000",
"CONFIG_EXPORT_FILENAME": "swatch_report_{0}",
"CONFIG_EXPORT_FILE_EXT": "zip",
"CONFIG_EXPORT_FILE_TYPE": "application/gzip",
"CONFIG_EXPORT_SERVICE_NAME_PREFIX": "swatch",
"DEV_MODE": false,
"PROD_MODE": false,
Expand Down Expand Up @@ -60,6 +62,8 @@ exports[`Helpers should expose a window object: window object 1`] = `
{
"CONFIG_EXPORT_EXPIRE": "86400000",
"CONFIG_EXPORT_FILENAME": "swatch_report_{0}",
"CONFIG_EXPORT_FILE_EXT": "zip",
"CONFIG_EXPORT_FILE_TYPE": "application/gzip",
"CONFIG_EXPORT_SERVICE_NAME_PREFIX": "swatch",
"DEV_MODE": false,
"PROD_MODE": false,
Expand Down Expand Up @@ -122,6 +126,8 @@ exports[`Helpers should have specific functions: helpers 1`] = `
{
"CONFIG_EXPORT_EXPIRE": "86400000",
"CONFIG_EXPORT_FILENAME": "swatch_report_{0}",
"CONFIG_EXPORT_FILE_EXT": "zip",
"CONFIG_EXPORT_FILE_TYPE": "application/gzip",
"CONFIG_EXPORT_SERVICE_NAME_PREFIX": "swatch",
"DEV_MODE": false,
"PROD_MODE": false,
Expand Down
18 changes: 17 additions & 1 deletion src/common/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,21 @@ const TEST_MODE = process.env.REACT_APP_ENV === 'test';
const CONFIG_EXPORT_EXPIRE = process.env.REACT_APP_CONFIG_EXPORT_EXPIRE;

/**
* CONFIG export download file name. Extension is handled at the service level.
* CONFIG export download file extension.
*
* @type {string}
*/
const CONFIG_EXPORT_FILE_EXT = process.env.REACT_APP_CONFIG_EXPORT_FILE_EXT;

/**
* CONFIG export download file mime type.
*
* @type {string}
*/
const CONFIG_EXPORT_FILE_TYPE = process.env.REACT_APP_CONFIG_EXPORT_FILE_TYPE;

/**
* CONFIG export download file name.
*
* @type {string}
*/
Expand Down Expand Up @@ -485,6 +499,8 @@ const helpers = {
REVIEW_MODE,
TEST_MODE,
CONFIG_EXPORT_EXPIRE,
CONFIG_EXPORT_FILE_EXT,
CONFIG_EXPORT_FILE_TYPE,
CONFIG_EXPORT_FILENAME,
CONFIG_EXPORT_SERVICE_NAME_PREFIX,
UI_DEPLOY_PATH_PREFIX,
Expand Down
4 changes: 2 additions & 2 deletions src/services/platform/platformServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ const getExport = (id, options = {}) => {
cancel = true,
cancelId,
fileName = `swatch_report_${id}`,
fileType = 'application/gzip'
fileType = helpers.CONFIG_EXPORT_FILE_TYPE
} = options;
return axiosServiceCall({
url: `${process.env.REACT_APP_SERVICES_PLATFORM_EXPORT}/${id}`,
Expand All @@ -364,7 +364,7 @@ const getExport = (id, options = {}) => {
(helpers.TEST_MODE && success.data) ||
downloadHelpers.downloadData({
data: success.data,
fileName: `${fileName}.tar.gz`,
fileName: `${fileName}.${helpers.CONFIG_EXPORT_FILE_EXT}`,
fileType
})
)
Expand Down

0 comments on commit 6174c6b

Please sign in to comment.