From fc50dba8475f612da18bbed0c14996a6a57cc6e3 Mon Sep 17 00:00:00 2001 From: "Ilya Ig. Petrov" Date: Mon, 22 May 2017 15:11:42 -0700 Subject: [PATCH] Add ProxyEditor view on tables --- .../pages/options/src/components/InfoLi.js | 2 +- .../pages/options/src/components/Main.js | 8 +- .../pages/options/src/components/ModList.js | 2 +- .../options/src/components/ProxyEditor.js | 170 ++++++++++++++++-- .../src/components/ProxyEditor.js_textarea | 44 +++++ 5 files changed, 207 insertions(+), 19 deletions(-) create mode 100644 extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ProxyEditor.js_textarea diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/InfoLi.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/InfoLi.js index 17bc2db..4bd4884 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/InfoLi.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/InfoLi.js @@ -135,7 +135,7 @@ export default function getInfoLi() {
) : (props.conf.url - ? () + ? () : ( ) // Affects vertical align of flexbox items. ) } diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/Main.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/Main.js index fc3fc78..1ee7f10 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/Main.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/Main.js @@ -62,8 +62,10 @@ export default function getMain(theState) { } - handleModCheck(that, {targetConf, targetIndex}) { + handleModCheck(that, {targetConf, targetIndex, targetChildren}) { + console.log('CHHHH', targetChildren); + window.foo = targetChildren const oldCats = that.state.catToOrderedMods; const newCats = Object.keys(that.state.catToOrderedMods).reduce((acc, cat) => { @@ -72,7 +74,7 @@ export default function getMain(theState) { } else { acc[cat] = oldCats[cat].map( (conf, index) => targetIndex === index - ? Object.assign({}, conf, {value: !conf.value}) + ? Object.assign({}, conf, {value: !targetConf.value}) : conf ); } @@ -123,7 +125,7 @@ export default function getMain(theState) { Object.assign({}, props, { orderedConfigs: this.state.catToOrderedMods['ownProxies'], childrenOfMod: { - customProxyStringRaw: createElement(ProxyEditor), + customProxyStringRaw: createElement(ProxyEditor, props), }, }, modsHandlers) ), diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ModList.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ModList.js index 3716be0..79bc159 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ModList.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ModList.js @@ -16,7 +16,7 @@ export default function getModList(theState) { type='checkbox' checked={conf.value} key={index} - onClick={() => props.onClick({targetConf: conf, targetIndex: index})} + onClick={() => props.onClick({targetConf: conf, targetIndex: index, targetChildren: props.childrenOfMod})} > {props.childrenOfMod && props.childrenOfMod[conf.key]} ) diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ProxyEditor.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ProxyEditor.js index 55517e9..f46b65c 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ProxyEditor.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ProxyEditor.js @@ -1,34 +1,176 @@ -import Inferno from 'inferno'; +import Inferno, {linkEvent} from 'inferno'; +import Component from 'inferno-component'; import css from 'csjs-inject'; export default function getProxyEditor(theState) { const scopedCss = css` - .texty { + table.editor { + border-collapse: collapse; + /*border-style: hidden;*/ width: 100%; - max-width: 38.5em; /* ~418px, layout breaks if more */ - height: 7em; - margin-top: 0.3em; - font-size: 0.9em; + margin: 0.5em 0; + background-color: #f3f5f6; + } + + table.editor ::-webkit-input-placeholder { + color: #c9c9c9; + } + + table.editor td, table.editor th { + border: 1px solid #ccc; + text-align: left; + } + table.editor th { + padding: 0 0.6em; + } + + table.editor input, + table.editor select, + table.editor select:hover { + border: none; + background: inherit !important; + } + table.editor select, + table.editor select:hover { + -webkit-appearance: menulist !important; + box-shadow: none !important; + } + table.editor input { + width: 100%; + } + + table.editor button { + min-width: 0; + min-height: 0; + width: 100%; + padding: 0; + border: none; + } + table.editor button.add { + font-weight: 800; + } + table.editor button.export { + padding-right: 2px; + } + /* LAST COLUMN */ + table.editor th:nth-last-child(1), + table.editor td:nth-last-child(1) { + height: 100%; + /*border: 0;*/ + padding: 0; + text-align: center; + } + table.editor td:nth-last-child(2) { + /*border-right: 0; + /* FOR PORT */ + padding: 0; + } + .laftPadded { + padding-left: 2px; + } + .noPad { + padding: 0; + } + + textarea.textarea { + width: 100% !important; + min-height: 100%; + height: 6em; + border-width: 1px 0 0 0; } `; const uiRaw = 'ui-proxy-string-raw'; - return function ProxyEditor(props) { + return class ProxyEditor extends Component { - return (