From 0cde29e56d7425889efbd7cd6f9100d8e744a720 Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Wed, 25 Sep 2019 17:54:46 -0400 Subject: [PATCH] re #168, get asset deletion route to work, update options dropdown on asset list --- client/modules/IDE/components/AssetList.jsx | 3 ++- client/styles/components/_asset-list.scss | 4 ++++ server/controllers/aws.controller.js | 8 +++++++- server/controllers/user.controller.js | 2 +- server/routes/aws.routes.js | 2 +- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/client/modules/IDE/components/AssetList.jsx b/client/modules/IDE/components/AssetList.jsx index 491dc2b5..58d3909c 100644 --- a/client/modules/IDE/components/AssetList.jsx +++ b/client/modules/IDE/components/AssetList.jsx @@ -28,7 +28,7 @@ class AssetListRowBase extends React.Component { this.setState({ isFocused: false }); setTimeout(() => { if (!this.state.isFocused) { - this.closeAll(); + this.closeOptions(); } }, 200); } @@ -109,6 +109,7 @@ class AssetListRowBase extends React.Component { target="_blank" onBlur={this.onBlurComponent} onFocus={this.onFocusComponent} + className="asset-table__action-option" > Open in New Tab diff --git a/client/styles/components/_asset-list.scss b/client/styles/components/_asset-list.scss index 7cee736e..0a34f343 100644 --- a/client/styles/components/_asset-list.scss +++ b/client/styles/components/_asset-list.scss @@ -93,3 +93,7 @@ top: 63%; right: calc(100% - 26px); } + +.asset-table__action-option { + font-size: #{12 / $base-font-size}rem; +} diff --git a/server/controllers/aws.controller.js b/server/controllers/aws.controller.js index e8744959..b4976a50 100644 --- a/server/controllers/aws.controller.js +++ b/server/controllers/aws.controller.js @@ -60,7 +60,13 @@ export function deleteObjectsFromS3(keyList, callback) { } export function deleteObjectFromS3(req, res) { - const objectKey = req.params.object_key; + const { object_key, user_id } = req.params; + let objectKey; + if (user_id) { + objectKey = `${user_id}/${object_key}` + } else { + objectKey = object_key; + } deleteObjectsFromS3([objectKey], () => { res.json({ success: true }); }); diff --git a/server/controllers/user.controller.js b/server/controllers/user.controller.js index 3ffdb026..d326e373 100644 --- a/server/controllers/user.controller.js +++ b/server/controllers/user.controller.js @@ -18,7 +18,7 @@ export function userResponse(user) { apiKeys: user.apiKeys, verified: user.verified, id: user._id, - totalSize: req.user.totalSize + totalSize: user.totalSize }; } diff --git a/server/routes/aws.routes.js b/server/routes/aws.routes.js index f73e4fa4..19401d61 100644 --- a/server/routes/aws.routes.js +++ b/server/routes/aws.routes.js @@ -6,7 +6,7 @@ const router = new Router(); router.post('/S3/sign', isAuthenticated, AWSController.signS3); router.post('/S3/copy', isAuthenticated, AWSController.copyObjectInS3); -router.delete('/S3/:object_key', isAuthenticated, AWSController.deleteObjectFromS3); +router.delete('/S3/:user_id?/:object_key', isAuthenticated, AWSController.deleteObjectFromS3); router.get('/S3/objects', AWSController.listObjectsInS3ForUserRequestHandler); export default router;