From 1c08a33b92f72d77d6c5f1fce916e2cd7c655ff0 Mon Sep 17 00:00:00 2001
From: Christopher Speller <crspeller@gmail.com>
Date: Tue, 21 Jul 2015 16:54:24 -0400
Subject: Fixing file uploads and previews for new /team/ URL structure

---
 web/react/components/view_image.jsx | 5 +++++
 1 file changed, 5 insertions(+)

(limited to 'web/react/components/view_image.jsx')

diff --git a/web/react/components/view_image.jsx b/web/react/components/view_image.jsx
index 2274f3f2e..4675269d5 100644
--- a/web/react/components/view_image.jsx
+++ b/web/react/components/view_image.jsx
@@ -36,6 +36,11 @@ module.exports = React.createClass({
             src = this.props.filenames[id];
         } else {
             var fileInfo = utils.splitFileLocation(this.props.filenames[id]);
+            // This is a temporary patch to fix issue with old files using absolute paths
+            if (fileInfo.path.indexOf("/api/v1/files/get") != -1) {
+                fileInfo.path = fileInfo.path.split("/api/v1/files/get")[1];
+            }
+            fileInfo.path = window.location.origin + "/api/v1/files/get" + fileInfo.path;
             src = fileInfo['path'] + '_preview.jpg';
         }
 
-- 
cgit v1.2.3-1-g7c22


From 2d51e93d8e2b455fc325ab10c0b13fa9a497bb9a Mon Sep 17 00:00:00 2001
From: Christopher Speller <crspeller@gmail.com>
Date: Tue, 21 Jul 2015 18:37:00 -0400
Subject: Fixing image previews

---
 web/react/components/view_image.jsx | 5 +++++
 1 file changed, 5 insertions(+)

(limited to 'web/react/components/view_image.jsx')

diff --git a/web/react/components/view_image.jsx b/web/react/components/view_image.jsx
index 4675269d5..4d5d54e7f 100644
--- a/web/react/components/view_image.jsx
+++ b/web/react/components/view_image.jsx
@@ -144,6 +144,11 @@ module.exports = React.createClass({
                 if (this.props.imgCount > 0) {
                     preview_filename = this.props.filenames[this.state.imgId];
                 } else {
+                    // This is a temporary patch to fix issue with old files using absolute paths
+                    if (info.path.indexOf("/api/v1/files/get") != -1) {
+                        info.path = info.path.split("/api/v1/files/get")[1];
+                    }
+                    info.path = window.location.origin + "/api/v1/files/get" + info.path;
                     preview_filename = info['path'] + '_preview.jpg';
                 }
 
-- 
cgit v1.2.3-1-g7c22


From 5886e695e41a500d80b5121d1b6c5beb4e087780 Mon Sep 17 00:00:00 2001
From: JoramWilander <jwawilander@gmail.com>
Date: Tue, 21 Jul 2015 19:29:40 -0400
Subject: fix click through on the image viewer modal to work with new team
 domain changes

---
 web/react/components/view_image.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'web/react/components/view_image.jsx')

diff --git a/web/react/components/view_image.jsx b/web/react/components/view_image.jsx
index 4d5d54e7f..ac0ecf299 100644
--- a/web/react/components/view_image.jsx
+++ b/web/react/components/view_image.jsx
@@ -155,7 +155,7 @@ module.exports = React.createClass({
                 var imgClass = "hidden";
                 if (this.state.loaded[id] && this.state.imgId == id) imgClass = "";
 
-                img[info['path']] = <a key={info['path']} className={imgClass} href={this.props.filenames[id]} target="_blank"><img ref="image" src={preview_filename}/></a>;
+                img[info['path']] = <a key={info['path']} className={imgClass} href={info.path+"."+info.ext} target="_blank"><img ref="image" src={preview_filename}/></a>;
             }
         }
 
-- 
cgit v1.2.3-1-g7c22


From d58398708ee4c47ba403bc56ee5b14fc0941f797 Mon Sep 17 00:00:00 2001
From: JoramWilander <jwawilander@gmail.com>
Date: Tue, 21 Jul 2015 23:34:20 -0400
Subject: fixed download link in image viewer

---
 web/react/components/view_image.jsx | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

(limited to 'web/react/components/view_image.jsx')

diff --git a/web/react/components/view_image.jsx b/web/react/components/view_image.jsx
index ac0ecf299..c107de4d7 100644
--- a/web/react/components/view_image.jsx
+++ b/web/react/components/view_image.jsx
@@ -37,7 +37,7 @@ module.exports = React.createClass({
         } else {
             var fileInfo = utils.splitFileLocation(this.props.filenames[id]);
             // This is a temporary patch to fix issue with old files using absolute paths
-            if (fileInfo.path.indexOf("/api/v1/files/get") != -1) {
+            if (fileInfo.path.indexOf("/api/v1/files/get") !== -1) {
                 fileInfo.path = fileInfo.path.split("/api/v1/files/get")[1];
             }
             fileInfo.path = window.location.origin + "/api/v1/files/get" + fileInfo.path;
@@ -145,7 +145,7 @@ module.exports = React.createClass({
                     preview_filename = this.props.filenames[this.state.imgId];
                 } else {
                     // This is a temporary patch to fix issue with old files using absolute paths
-                    if (info.path.indexOf("/api/v1/files/get") != -1) {
+                    if (info.path.indexOf("/api/v1/files/get") !== -1) {
                         info.path = info.path.split("/api/v1/files/get")[1];
                     }
                     info.path = window.location.origin + "/api/v1/files/get" + info.path;
@@ -161,6 +161,13 @@ module.exports = React.createClass({
 
         var imgFragment = React.addons.createFragment(img);
 
+        // This is a temporary patch to fix issue with old files using absolute paths
+        var download_link = this.props.filenames[this.state.imgId];
+        if (download_link.indexOf("/api/v1/files/get") !== -1) {
+            download_link = download_link.split("/api/v1/files/get")[1];
+        }
+        download_link = window.location.origin + "/api/v1/files/get" + download_link;
+
         return (
             <div className="modal fade image_modal" ref="modal" id={this.props.modalId} tabIndex="-1" role="dialog" aria-hidden="true">
                 <div className="modal-dialog modal-image">
@@ -178,7 +185,7 @@ module.exports = React.createClass({
                                                 <span className="text"> | </span>
                                             </div>
                                         : "" }
-                                        <a href={this.props.filenames[id]} download={decodeURIComponent(name)} className="text">Download</a>
+                                        <a href={download_link} download={decodeURIComponent(name)} className="text">Download</a>
                                     </div>
                                 </div>
                                 {loading}
-- 
cgit v1.2.3-1-g7c22

