From 3e6c284757ffbb42aef34281567cf1adedd21ae9 Mon Sep 17 00:00:00 2001
From: Clemens <cle1000.cb@gmail.com>
Date: Wed, 27 Jul 2016 17:27:01 +0200
Subject: add contentviews to client

---
 web/src/js/components/ContentView/ViewSelector.jsx | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

(limited to 'web/src/js/components/ContentView/ViewSelector.jsx')

diff --git a/web/src/js/components/ContentView/ViewSelector.jsx b/web/src/js/components/ContentView/ViewSelector.jsx
index 89b36231..c3e1e105 100644
--- a/web/src/js/components/ContentView/ViewSelector.jsx
+++ b/web/src/js/components/ContentView/ViewSelector.jsx
@@ -24,7 +24,7 @@ ViewButton = connect(state => ({
 ViewSelector.propTypes = {
     message: PropTypes.object.isRequired,
 }
-export default function ViewSelector({ message }) {
+function ViewSelector({ message, contentViews }) {
 
     let autoView = ContentViews.ViewAuto.findView(message)
     let autoViewName = (autoView.displayName || autoView.name)
@@ -42,6 +42,15 @@ export default function ViewSelector({ message }) {
                 <ViewButton key={name} name={name}>{name.toLowerCase().replace('view', '')}</ViewButton>
             )}
 
+            {contentViews.map(name =>
+                <ViewButton key={name} name={name}>{name.toLowerCase().replace('view', '')}</ViewButton>
+            )}
+
         </div>
     )
 }
+
+export default connect (
+    state => ({
+        contentViews: state.settings.contentViews
+    }))(ViewSelector)
-- 
cgit v1.2.3


From ad5bebeda0f1da890d8ed94b6096515e03f44a25 Mon Sep 17 00:00:00 2001
From: Clemens <cle1000.cb@gmail.com>
Date: Thu, 28 Jul 2016 17:10:06 +0200
Subject: mitmproxy.contentviews added

---
 web/src/js/components/ContentView/ViewSelector.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'web/src/js/components/ContentView/ViewSelector.jsx')

diff --git a/web/src/js/components/ContentView/ViewSelector.jsx b/web/src/js/components/ContentView/ViewSelector.jsx
index c3e1e105..423cc157 100644
--- a/web/src/js/components/ContentView/ViewSelector.jsx
+++ b/web/src/js/components/ContentView/ViewSelector.jsx
@@ -38,7 +38,7 @@ function ViewSelector({ message, contentViews }) {
             <ViewButton name="ViewAuto">auto: {autoViewName}</ViewButton>
 
             {Object.keys(ContentViews).map(name =>
-                name !== "ViewAuto" &&
+                name !== "ViewAuto" && name !== "ViewServer" && 
                 <ViewButton key={name} name={name}>{name.toLowerCase().replace('view', '')}</ViewButton>
             )}
 
-- 
cgit v1.2.3


From 2807329fb2ce576ae529afd991e3da3d5f81d637 Mon Sep 17 00:00:00 2001
From: Clemens <cle1000.cb@gmail.com>
Date: Thu, 28 Jul 2016 17:28:05 +0200
Subject: add image to mitmproxy.contentview.image

---
 web/src/js/components/ContentView/ViewSelector.jsx | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

(limited to 'web/src/js/components/ContentView/ViewSelector.jsx')

diff --git a/web/src/js/components/ContentView/ViewSelector.jsx b/web/src/js/components/ContentView/ViewSelector.jsx
index 423cc157..e031b51f 100644
--- a/web/src/js/components/ContentView/ViewSelector.jsx
+++ b/web/src/js/components/ContentView/ViewSelector.jsx
@@ -35,10 +35,8 @@ function ViewSelector({ message, contentViews }) {
     return (
         <div className="view-selector btn-group btn-group-xs">
 
-            <ViewButton name="ViewAuto">auto: {autoViewName}</ViewButton>
-
             {Object.keys(ContentViews).map(name =>
-                name !== "ViewAuto" && name !== "ViewServer" && 
+                name === "ViewRaw"  &&
                 <ViewButton key={name} name={name}>{name.toLowerCase().replace('view', '')}</ViewButton>
             )}
 
-- 
cgit v1.2.3


From a56c2ca731ff9c4a22438553dea0e4ecf7a51f1d Mon Sep 17 00:00:00 2001
From: Clemens <cle1000.cb@gmail.com>
Date: Fri, 29 Jul 2016 09:45:15 +0200
Subject: combine clientside and serverside contentviews

---
 web/src/js/components/ContentView/ViewSelector.jsx | 24 ++++++++--------------
 1 file changed, 9 insertions(+), 15 deletions(-)

(limited to 'web/src/js/components/ContentView/ViewSelector.jsx')

diff --git a/web/src/js/components/ContentView/ViewSelector.jsx b/web/src/js/components/ContentView/ViewSelector.jsx
index e031b51f..c5670328 100644
--- a/web/src/js/components/ContentView/ViewSelector.jsx
+++ b/web/src/js/components/ContentView/ViewSelector.jsx
@@ -24,31 +24,25 @@ ViewButton = connect(state => ({
 ViewSelector.propTypes = {
     message: PropTypes.object.isRequired,
 }
-function ViewSelector({ message, contentViews }) {
-
-    let autoView = ContentViews.ViewAuto.findView(message)
-    let autoViewName = (autoView.displayName || autoView.name)
-        .toLowerCase()
-        .replace('view', '')
-        .replace(/ContentLoader\((.+)\)/,"$1")
-
+function ViewSelector({contentViews, isEdit }) {
+    let edit = ContentViews.Edit.displayName
     return (
         <div className="view-selector btn-group btn-group-xs">
 
-            {Object.keys(ContentViews).map(name =>
-                name === "ViewRaw"  &&
-                <ViewButton key={name} name={name}>{name.toLowerCase().replace('view', '')}</ViewButton>
-            )}
-
             {contentViews.map(name =>
-                <ViewButton key={name} name={name}>{name.toLowerCase().replace('view', '')}</ViewButton>
+                <ViewButton key={name} name={name}>{name.toLowerCase().replace('_', ' ')}</ViewButton>
             )}
 
+            {isEdit &&
+                <ViewButton key={edit} name={edit}>{edit.toLowerCase()}</ViewButton>
+            }
+
         </div>
     )
 }
 
 export default connect (
     state => ({
-        contentViews: state.settings.contentViews
+        contentViews: state.settings.contentViews,
+        isEdit: !!state.ui.flow.modifiedFlow,
     }))(ViewSelector)
-- 
cgit v1.2.3


From 34fe391afbe18f89d774137f82620024f697ab6a Mon Sep 17 00:00:00 2001
From: Clemens <cle1000.cb@gmail.com>
Date: Wed, 3 Aug 2016 12:08:10 +0200
Subject: add view all button, add dropdown for contentviews

---
 web/src/js/components/ContentView/ViewSelector.jsx | 92 +++++++++++++++-------
 1 file changed, 63 insertions(+), 29 deletions(-)

(limited to 'web/src/js/components/ContentView/ViewSelector.jsx')

diff --git a/web/src/js/components/ContentView/ViewSelector.jsx b/web/src/js/components/ContentView/ViewSelector.jsx
index c5670328..1959ec1e 100644
--- a/web/src/js/components/ContentView/ViewSelector.jsx
+++ b/web/src/js/components/ContentView/ViewSelector.jsx
@@ -1,48 +1,82 @@
-import React, { PropTypes } from 'react'
+import React, { PropTypes, Component } from 'react'
 import classnames from 'classnames'
 import { connect } from 'react-redux'
 import * as ContentViews from './ContentViews'
-import { setContentView } from "../../ducks/ui/flow";
+import { setContentView, setContentViewSelectorOpen } from "../../ducks/ui/flow";
 
 
-function ViewButton({ name, setContentView, children, activeView }) {
+function ViewItem({ name, setContentView, children }) {
     return (
-        <button
-            onClick={() => setContentView(name)}
-            className={classnames('btn btn-default', { active: name === activeView })}>
-            {children}
-        </button>
+        <li>
+            <a href="#" onClick={() => setContentView(name)}>
+                {children}
+            </a>
+        </li>
     )
 }
-ViewButton = connect(state => ({
-    activeView: state.ui.flow.contentView
-}), {
-    setContentView
-})(ViewButton)
 
 
-ViewSelector.propTypes = {
-    message: PropTypes.object.isRequired,
-}
-function ViewSelector({contentViews, isEdit }) {
-    let edit = ContentViews.Edit.displayName
-    return (
-        <div className="view-selector btn-group btn-group-xs">
+/*ViewSelector.propTypes = {
+    contentViews: PropTypes.array.isRequired,
+    activeView: PropTypes.string.isRequired,
+    isEdit: PropTypes.bool.isRequired,
+    isContentViewSelectorOpen: PropTypes.bool.isRequired,
+    setContentViewSelectorOpen: PropTypes.func.isRequired
+}*/
 
-            {contentViews.map(name =>
-                <ViewButton key={name} name={name}>{name.toLowerCase().replace('_', ' ')}</ViewButton>
-            )}
 
-            {isEdit &&
-                <ViewButton key={edit} name={edit}>{edit.toLowerCase()}</ViewButton>
-            }
+class ViewSelector extends Component {
+      constructor(props, context) {
+        super(props, context)
+        this.close = this.close.bind(this)
+    }
+    close() {
+        this.props.setContentViewSelectorOpen(false)
+        document.removeEventListener('click', this.close)
+    }
 
-        </div>
-    )
+    onDropdown(e){
+        e.preventDefault()
+        this.props.setContentViewSelectorOpen(!this.props.isContentViewSelectorOpen)
+        document.addEventListener('click', this.close)
+    }
+
+    render() {
+        const {contentViews, activeView, isEdit, isContentViewSelectorOpen, setContentViewSelectorOpen, setContentView} = this.props
+        let edit = ContentViews.Edit.displayName
+
+        return (
+            <div className={classnames('dropup pull-left', { open: isContentViewSelectorOpen })}>
+                <a className="btn btn-default btn-xs"
+                   onClick={ e => this.onDropdown(e) }
+                   href="#">
+                    <b>View:</b> {activeView}<span className="caret"></span>
+                </a>
+                <ul className="dropdown-menu" role="menu">
+                    {contentViews.map(name =>
+                        <ViewItem key={name} setContentView={setContentView} name={name}>
+                            {name.toLowerCase().replace('_', ' ')}
+                        </ViewItem>
+                    )}
+                    {isEdit &&
+                    <ViewItem key={edit} setContentView={setContentView} name={edit}>
+                        {edit.toLowerCase()}
+                    </ViewItem>
+                    }
+                </ul>
+            </div>
+        )
+    }
 }
 
 export default connect (
     state => ({
         contentViews: state.settings.contentViews,
+        activeView: state.ui.flow.contentView,
         isEdit: !!state.ui.flow.modifiedFlow,
-    }))(ViewSelector)
+        isContentViewSelectorOpen: state.ui.flow.isContentViewSelectorOpen
+    }), {
+        setContentView,
+        setContentViewSelectorOpen
+    }
+)(ViewSelector)
-- 
cgit v1.2.3


From adfdcc9391ed70202a1b4af65259a89634f36fa0 Mon Sep 17 00:00:00 2001
From: Clemens <cle1000.cb@gmail.com>
Date: Tue, 9 Aug 2016 08:40:24 +0200
Subject: added hints from mhils

---
 web/src/js/components/ContentView/ViewSelector.jsx | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

(limited to 'web/src/js/components/ContentView/ViewSelector.jsx')

diff --git a/web/src/js/components/ContentView/ViewSelector.jsx b/web/src/js/components/ContentView/ViewSelector.jsx
index 1959ec1e..59ec4276 100644
--- a/web/src/js/components/ContentView/ViewSelector.jsx
+++ b/web/src/js/components/ContentView/ViewSelector.jsx
@@ -2,8 +2,7 @@ import React, { PropTypes, Component } from 'react'
 import classnames from 'classnames'
 import { connect } from 'react-redux'
 import * as ContentViews from './ContentViews'
-import { setContentView, setContentViewSelectorOpen } from "../../ducks/ui/flow";
-
+import { setContentView } from "../../ducks/ui/flow";
 
 function ViewItem({ name, setContentView, children }) {
     return (
@@ -29,24 +28,25 @@ class ViewSelector extends Component {
       constructor(props, context) {
         super(props, context)
         this.close = this.close.bind(this)
+        this.state = {open: false}
     }
     close() {
-        this.props.setContentViewSelectorOpen(false)
+        this.setState({open: false})
         document.removeEventListener('click', this.close)
     }
 
     onDropdown(e){
         e.preventDefault()
-        this.props.setContentViewSelectorOpen(!this.props.isContentViewSelectorOpen)
+        this.setState({open: !this.state.open})
         document.addEventListener('click', this.close)
     }
 
     render() {
-        const {contentViews, activeView, isEdit, isContentViewSelectorOpen, setContentViewSelectorOpen, setContentView} = this.props
+        const {contentViews, activeView, isEdit, setContentView} = this.props
         let edit = ContentViews.Edit.displayName
 
         return (
-            <div className={classnames('dropup pull-left', { open: isContentViewSelectorOpen })}>
+            <div className={classnames('dropup pull-left', { open: this.state.open })}>
                 <a className="btn btn-default btn-xs"
                    onClick={ e => this.onDropdown(e) }
                    href="#">
@@ -74,9 +74,7 @@ export default connect (
         contentViews: state.settings.contentViews,
         activeView: state.ui.flow.contentView,
         isEdit: !!state.ui.flow.modifiedFlow,
-        isContentViewSelectorOpen: state.ui.flow.isContentViewSelectorOpen
     }), {
         setContentView,
-        setContentViewSelectorOpen
     }
 )(ViewSelector)
-- 
cgit v1.2.3

