Skip to content

Commit 1c5fd78

Browse files
Merge branch 'dev' into gtfs-spec-changes
2 parents e180c43 + cd4a89a commit 1c5fd78

File tree

2 files changed

+47
-38
lines changed

2 files changed

+47
-38
lines changed

lib/manager/actions/deployments.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import { browserHistory } from 'react-router'
55
import { createAction, type ActionType } from 'redux-actions'
66

77
import { createVoidPayloadAction, secureFetch } from '../../common/actions'
8-
import { receiveProject } from './projects'
9-
import { startJobMonitor } from './status'
108
import fileDownload from '../../common/util/file-download'
11-
129
import type {Deployment, Feed, SummarizedFeedVersion} from '../../types'
1310
import type {dispatchFn, getStateFn} from '../../types/reducers'
1411

12+
import { startJobMonitor } from './status'
13+
import { receiveProject } from './projects'
14+
1515
const DEPLOYMENT_URL = `/api/manager/secure/deployments`
1616

1717
// Deployment Actions
@@ -132,11 +132,28 @@ export function downloadBuildArtifact (deployment: Deployment, filename: ?string
132132
}
133133
}
134134

135+
/**
136+
* Set a suggested file name for the given deployment.
137+
*
138+
* Note: Although a suggested file name is returned in the 'content-disposition' header of the 'download' endpoint,
139+
* it is still needed to set it here because we trigger the "Save As" dialog separately from the actual fetch.
140+
* Also, it is probably simpler to recompute the file name here instead of extracting it from the response.
141+
*
142+
* @param deployment The deployment object from which to derive the zip file name.
143+
* @returns The suggested zip file name ending in ".zip" for the browser "Save As" dialog.
144+
*/
145+
function getDeploymentZipFileName (deployment: Deployment): string {
146+
// Remove all spaces and special chars from deployment name.
147+
const zipBase = deployment.name.replace(/[^a-zA-Z0-9]/g, '')
148+
return `${zipBase}.zip`
149+
}
150+
135151
export function downloadDeployment (deployment: Deployment) {
136152
return function (dispatch: dispatchFn, getState: getStateFn) {
153+
const zipName = getDeploymentZipFileName(deployment)
137154
return dispatch(secureFetch(`${DEPLOYMENT_URL}/${deployment.id}/download`))
138155
.then(response => response.blob())
139-
.then(blob => fileDownload(blob, 'test.zip', 'application/zip'))
156+
.then(blob => fileDownload(blob, zipName, 'application/zip'))
140157
}
141158
}
142159

yarn.lock

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5717,12 +5717,12 @@ fs-extra@^9.0.0:
57175717
jsonfile "^6.0.1"
57185718
universalify "^1.0.0"
57195719

5720-
fs-minipass@^1.2.5:
5721-
version "1.2.6"
5722-
resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.6.tgz#2c5cc30ded81282bfe8a0d7c7c1853ddeb102c07"
5723-
integrity sha512-crhvyXcMejjv3Z5d2Fa9sf5xLYVCF5O1c71QxbVnbLsmYMBEvDAftewesN/HhY03YRoA7zOMxjNGrF5svGaaeQ==
5720+
fs-minipass@^1.2.7:
5721+
version "1.2.7"
5722+
resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.7.tgz#ccff8570841e7fe4265693da88936c55aed7f7c7"
5723+
integrity sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==
57245724
dependencies:
5725-
minipass "^2.2.1"
5725+
minipass "^2.6.0"
57265726

57275727
fs-vacuum@^1.2.10, fs-vacuum@~1.2.10:
57285728
version "1.2.10"
@@ -9107,28 +9107,20 @@ minimist@^1.1.0, minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0, minimist@^1.
91079107
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
91089108
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
91099109

9110-
minipass@^2.2.1, minipass@^2.3.5:
9111-
version "2.3.5"
9112-
resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.3.5.tgz#cacebe492022497f656b0f0f51e2682a9ed2d848"
9113-
integrity sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==
9114-
dependencies:
9115-
safe-buffer "^5.1.2"
9116-
yallist "^3.0.0"
9117-
9118-
minipass@^2.8.6:
9110+
minipass@^2.3.5, minipass@^2.6.0, minipass@^2.9.0:
91199111
version "2.9.0"
91209112
resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.9.0.tgz#e713762e7d3e32fed803115cf93e04bca9fcc9a6"
91219113
integrity sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==
91229114
dependencies:
91239115
safe-buffer "^5.1.2"
91249116
yallist "^3.0.0"
91259117

9126-
minizlib@^1.2.1:
9127-
version "1.2.1"
9128-
resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.2.1.tgz#dd27ea6136243c7c880684e8672bb3a45fd9b614"
9129-
integrity sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==
9118+
minizlib@^1.3.3:
9119+
version "1.3.3"
9120+
resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.3.3.tgz#2290de96818a34c29551c8a8d301216bd65a861d"
9121+
integrity sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==
91309122
dependencies:
9131-
minipass "^2.2.1"
9123+
minipass "^2.9.0"
91329124

91339125
mississippi@^3.0.0:
91349126
version "3.0.0"
@@ -12706,7 +12698,7 @@ [email protected], safe-buffer@~5.1.0, safe-buffer@~5.1.1:
1270612698
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
1270712699
integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==
1270812700

12709-
safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0:
12701+
safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@^5.2.1:
1271012702
version "5.2.1"
1271112703
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6"
1271212704
integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==
@@ -13809,17 +13801,17 @@ tar-stream@~1.1.0:
1380913801
xtend "^4.0.0"
1381013802

1381113803
tar@^4, tar@^4.4.10, tar@^4.4.12, tar@^4.4.13:
13812-
version "4.4.13"
13813-
resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.13.tgz#43b364bc52888d555298637b10d60790254ab525"
13814-
integrity sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA==
13804+
version "4.4.19"
13805+
resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.19.tgz#2e4d7263df26f2b914dee10c825ab132123742f3"
13806+
integrity sha512-a20gEsvHnWe0ygBY8JbxoM4w3SJdhc7ZAuxkLqh+nvNQN2IOt0B5lLgM490X5Hl8FF0dl0tOf2ewFYAlIFgzVA==
1381513807
dependencies:
13816-
chownr "^1.1.1"
13817-
fs-minipass "^1.2.5"
13818-
minipass "^2.8.6"
13819-
minizlib "^1.2.1"
13820-
mkdirp "^0.5.0"
13821-
safe-buffer "^5.1.2"
13822-
yallist "^3.0.3"
13808+
chownr "^1.1.4"
13809+
fs-minipass "^1.2.7"
13810+
minipass "^2.9.0"
13811+
minizlib "^1.3.3"
13812+
mkdirp "^0.5.5"
13813+
safe-buffer "^5.2.1"
13814+
yallist "^3.1.1"
1382313815

1382413816
temp-dir@^2.0.0:
1382513817
version "2.0.0"
@@ -15020,10 +15012,10 @@ yallist@^2.1.2:
1502015012
resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52"
1502115013
integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=
1502215014

15023-
yallist@^3.0.0, yallist@^3.0.2, yallist@^3.0.3:
15024-
version "3.0.3"
15025-
resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.3.tgz#b4b049e314be545e3ce802236d6cd22cd91c3de9"
15026-
integrity sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==
15015+
yallist@^3.0.0, yallist@^3.0.2, yallist@^3.1.1:
15016+
version "3.1.1"
15017+
resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd"
15018+
integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==
1502715019

1502815020
yallist@^4.0.0:
1502915021
version "4.0.0"

0 commit comments

Comments
 (0)