summary refs log tree commit diff
path: root/synapse_topology/view
diff options
context:
space:
mode:
authorJorik Schellekens <joriks@matrix.org>2019-08-09 17:53:58 +0100
committerJorik Schellekens <joriks@matrix.org>2019-08-28 15:59:53 +0100
commit7e8f993a843fb8692015cb4d0ffe4b4c750956a1 (patch)
treeb6d2434aeb0fa7c85d76b0790b25df91639d30b1 /synapse_topology/view
parentClean up debug statements (diff)
downloadsynapse-7e8f993a843fb8692015cb4d0ffe4b4c750956a1.tar.xz
Some refactoring
Diffstat (limited to 'synapse_topology/view')
-rw-r--r--synapse_topology/view/webui/js/components/UI.jsx10
-rw-r--r--synapse_topology/view/webui/js/reducers/base-config-reducer.js (renamed from synapse_topology/view/webui/js/reducers/reducer-base-config.js)0
-rw-r--r--synapse_topology/view/webui/js/reducers/config-ui-reducer.js (renamed from synapse_topology/view/webui/js/reducers/reducer-advanced-config-ui.js)0
-rw-r--r--synapse_topology/view/webui/js/reducers/index.js9
-rw-r--r--synapse_topology/view/webui/js/reducers/reducer-base-config-ui.js106
-rw-r--r--synapse_topology/view/webui/js/reducers/reducer-ui.js39
-rw-r--r--synapse_topology/view/webui/js/reducers/setup-ui-reducer.js110
-rw-r--r--synapse_topology/view/webui/js/reducers/state.js9
-rw-r--r--synapse_topology/view/webui/js/reducers/ui-reducer.js39
9 files changed, 168 insertions, 154 deletions
diff --git a/synapse_topology/view/webui/js/components/UI.jsx b/synapse_topology/view/webui/js/components/UI.jsx
index 169ef1a779..33afbd1536 100644
--- a/synapse_topology/view/webui/js/components/UI.jsx
+++ b/synapse_topology/view/webui/js/components/UI.jsx
@@ -42,8 +42,7 @@ import ReverseProxySampleConfig from '../containers/ReverseProxySampleConfig';
 import DelegationSampleConfig from '../containers/DelegationSampleConfig';
 import Database from '../containers/Database';
 
-export default ({ active_ui, dispatch }) => {
-  console.log(`switching to ui ${active_ui}`)
+const block_mapping = block_const => {
   switch (active_ui) {
     case LOADING_UI:
       return <Loading />
@@ -80,4 +79,11 @@ export default ({ active_ui, dispatch }) => {
     default:
       return <h1>how did i get here?</h1>
   }
+}
+
+export default ({ active_ui_blocks, dispatch }) => {
+  console.log(`switching to ui ${active_ui_blocks}`);
+  <WalkThrough>
+    {active_ui_blocks.map(block_mapping)}
+  </WalkThrough>
 }
\ No newline at end of file
diff --git a/synapse_topology/view/webui/js/reducers/reducer-base-config.js b/synapse_topology/view/webui/js/reducers/base-config-reducer.js
index 60f4117a16..60f4117a16 100644
--- a/synapse_topology/view/webui/js/reducers/reducer-base-config.js
+++ b/synapse_topology/view/webui/js/reducers/base-config-reducer.js
diff --git a/synapse_topology/view/webui/js/reducers/reducer-advanced-config-ui.js b/synapse_topology/view/webui/js/reducers/config-ui-reducer.js
index d7db584c77..d7db584c77 100644
--- a/synapse_topology/view/webui/js/reducers/reducer-advanced-config-ui.js
+++ b/synapse_topology/view/webui/js/reducers/config-ui-reducer.js
diff --git a/synapse_topology/view/webui/js/reducers/index.js b/synapse_topology/view/webui/js/reducers/index.js
index 83a10a598a..d2b09ad0bc 100644
--- a/synapse_topology/view/webui/js/reducers/index.js
+++ b/synapse_topology/view/webui/js/reducers/index.js
@@ -1,10 +1,9 @@
-import { combineReducers } from 'redux';
-import ui from './reducer-ui';
-import base_config from './reducer-base-config';
-import { get_server_setup } from '../api';
+import ui from './ui-reducer';
+import base_config_reducer from './base-config-reducer';
+
 import { LOADING_UI } from './ui_constants';
 
 export default (state = { ui: { active_ui: LOADING_UI }, base_config: {} }, action) => ({
   ui: ui(state, action),
-  base_config: base_config(state.base_config, action)
+  base_config: base_config_reducer(state.base_config, action)
 });
\ No newline at end of file
diff --git a/synapse_topology/view/webui/js/reducers/reducer-base-config-ui.js b/synapse_topology/view/webui/js/reducers/reducer-base-config-ui.js
deleted file mode 100644
index 424328de03..0000000000
--- a/synapse_topology/view/webui/js/reducers/reducer-base-config-ui.js
+++ /dev/null
@@ -1,106 +0,0 @@
-import { ADVANCE_UI, BACK_UI, BASE_CONFIG_CHECKED } from '../actions/types';
-
-import {
-  BASE_INTRO_UI,
-  SERVER_NAME_UI,
-  STATS_REPORT_UI,
-  KEY_EXPORT_UI,
-  DELEGATION_OPTIONS_UI,
-  DELEGATION_SERVER_NAME_UI,
-  WELL_KNOWN_UI,
-  DNS_UI,
-  TLS_UI,
-  REVERSE_PROXY_UI,
-  PORT_SELECTION_UI,
-  REVERSE_PROXY_TEMPLATE_UI,
-  TLS_CERTPATH_UI,
-  DELEGATION_PORT_SELECTION_UI,
-  DELEGATION_TEMPLATE_UI,
-  DATABASE_UI,
-} from './ui_constants';
-
-import {
-  DELEGATION_TYPES, TLS_TYPES
-} from '../actions/constants';
-
-export default ({ ui, base_config }, action) => {
-  switch (action.type) {
-    case BASE_CONFIG_CHECKED:
-      return BASE_INTRO_UI;
-    case ADVANCE_UI:
-      switch (ui.active_ui) {
-        case BASE_INTRO_UI:
-          return SERVER_NAME_UI;
-        case SERVER_NAME_UI:
-          return STATS_REPORT_UI;
-        case STATS_REPORT_UI:
-          return KEY_EXPORT_UI;
-        case KEY_EXPORT_UI:
-          return DELEGATION_OPTIONS_UI;
-        case DELEGATION_OPTIONS_UI:
-          switch (action.option) {
-            // TODO: figure these out
-            case DELEGATION_TYPES.DNS:
-              return DELEGATION_SERVER_NAME_UI;
-            case DELEGATION_TYPES.WELL_KNOWN:
-              return DELEGATION_SERVER_NAME_UI;
-            case DELEGATION_TYPES.LOCAL:
-              return TLS_UI;
-          }
-        case DELEGATION_SERVER_NAME_UI:
-          return DELEGATION_PORT_SELECTION_UI;
-        case DELEGATION_PORT_SELECTION_UI:
-          return TLS_UI;
-        case TLS_UI:
-          switch (action.option) {
-            case TLS_TYPES.ACME:
-              return PORT_SELECTION_UI;
-            case TLS_TYPES.TLS:
-              return TLS_CERTPATH_UI;
-            case TLS_TYPES.NONE:
-              return PORT_SELECTION_UI;
-            case TLS_TYPES.REVERSE_PROXY:
-              return REVERSE_PROXY_UI;
-          }
-        case REVERSE_PROXY_UI:
-          return PORT_SELECTION_UI;
-        case TLS_CERTPATH_UI:
-          return PORT_SELECTION_UI;
-        case PORT_SELECTION_UI:
-          return base_config.tls == TLS_TYPES.REVERSE_PROXY ?
-            REVERSE_PROXY_TEMPLATE_UI :
-            base_config.delegation_type != DELEGATION_TYPES.LOCAL ?
-              DELEGATION_TEMPLATE_UI :
-              DATABASE_UI;
-        case REVERSE_PROXY_TEMPLATE_UI:
-          return base_config.delegation_type != DELEGATION_TYPES.LOCAL ?
-            DELEGATION_TEMPLATE_UI :
-            DATABASE_UI;
-        case DELEGATION_TEMPLATE_UI:
-          return DATABASE_UI;
-        case WELL_KNOWN_UI:
-        case DNS_UI:
-        default:
-          return BASE_INTRO_UI;
-      }
-
-    // TODO: Think about how back should work..
-    case BACK_UI:
-      switch (ui.active_ui) {
-        case STATS_REPORT_UI:
-          return SERVER_NAME_UI;
-        case KEY_EXPORT_UI:
-          return STATS_REPORT_UI;
-        case DELEGATION_OPTIONS_UI:
-          return KEY_EXPORT_UI;
-        case WELL_KNOWN_UI:
-          return DELEGATION_OPTIONS_UI;
-        case DNS_UI:
-          return WELL_KNOWN_UI;
-        default:
-          BASE_INTRO_UI;
-      }
-    default:
-      return ui.active_ui;
-  }
-}
diff --git a/synapse_topology/view/webui/js/reducers/reducer-ui.js b/synapse_topology/view/webui/js/reducers/reducer-ui.js
deleted file mode 100644
index 20421e956e..0000000000
--- a/synapse_topology/view/webui/js/reducers/reducer-ui.js
+++ /dev/null
@@ -1,39 +0,0 @@
-import base_config_ui from './reducer-base-config-ui';
-import advanced_config_ui from './reducer-advanced-config-ui';
-import { LOADING_UI, ERROR_UI } from './ui_constants';
-import { BASE_CONFIG_CHECKED, FAIL } from '../actions/types';
-
-
-export default (state, action) => {
-  console.log(state)
-  console.log(action)
-  switch (action.type) {
-    case FAIL:
-      return {
-        ...state.ui,
-        active_ui: ERROR_UI
-      }
-    case BASE_CONFIG_CHECKED:
-      if (action.base_config_done) {
-        return {
-          base_config_done: true,
-          active_ui: advanced_config_ui(state, action),
-        }
-      } else {
-        return {
-          base_config_done: false,
-          active_ui: base_config_ui(state, action),
-        }
-      }
-    default:
-      const newstate = { ...state.ui };
-      if ('base_config_done' in state.ui) {
-        if (state.ui.base_config_done) {
-          newstate.active_ui = advanced_ui(state, action);
-        } else {
-          newstate.active_ui = base_config_ui(state, action);
-        }
-      }
-      return newstate;
-  }
-}
diff --git a/synapse_topology/view/webui/js/reducers/setup-ui-reducer.js b/synapse_topology/view/webui/js/reducers/setup-ui-reducer.js
new file mode 100644
index 0000000000..f3d6ee3d53
--- /dev/null
+++ b/synapse_topology/view/webui/js/reducers/setup-ui-reducer.js
@@ -0,0 +1,110 @@
+import { ADVANCE_UI, BACK_UI, BASE_CONFIG_CHECKED } from '../actions/types';
+
+import {
+  BASE_INTRO_UI,
+  SERVER_NAME_UI,
+  STATS_REPORT_UI,
+  KEY_EXPORT_UI,
+  DELEGATION_OPTIONS_UI,
+  DELEGATION_SERVER_NAME_UI,
+  WELL_KNOWN_UI,
+  DNS_UI,
+  TLS_UI,
+  REVERSE_PROXY_UI,
+  PORT_SELECTION_UI,
+  REVERSE_PROXY_TEMPLATE_UI,
+  TLS_CERTPATH_UI,
+  DELEGATION_PORT_SELECTION_UI,
+  DELEGATION_TEMPLATE_UI,
+  DATABASE_UI,
+} from './ui_constants';
+
+import {
+  DELEGATION_TYPES, TLS_TYPES
+} from '../actions/constants';
+
+const forward_mapping = (current_ui, action) => {
+  switch (current_ui) {
+    case BASE_INTRO_UI:
+      return SERVER_NAME_UI;
+    case SERVER_NAME_UI:
+      return STATS_REPORT_UI;
+    case STATS_REPORT_UI:
+      return KEY_EXPORT_UI;
+    case KEY_EXPORT_UI:
+      return DELEGATION_OPTIONS_UI;
+    case DELEGATION_OPTIONS_UI:
+      switch (action.option) {
+        // TODO: figure these out
+        case DELEGATION_TYPES.DNS:
+          return DELEGATION_SERVER_NAME_UI;
+        case DELEGATION_TYPES.WELL_KNOWN:
+          return DELEGATION_SERVER_NAME_UI;
+        case DELEGATION_TYPES.LOCAL:
+          return TLS_UI;
+      }
+    case DELEGATION_SERVER_NAME_UI:
+      return DELEGATION_PORT_SELECTION_UI;
+    case DELEGATION_PORT_SELECTION_UI:
+      return TLS_UI;
+    case TLS_UI:
+      switch (action.option) {
+        case TLS_TYPES.ACME:
+          return PORT_SELECTION_UI;
+        case TLS_TYPES.TLS:
+          return TLS_CERTPATH_UI;
+        case TLS_TYPES.NONE:
+          return PORT_SELECTION_UI;
+        case TLS_TYPES.REVERSE_PROXY:
+          return REVERSE_PROXY_UI;
+      }
+    case REVERSE_PROXY_UI:
+      return PORT_SELECTION_UI;
+    case TLS_CERTPATH_UI:
+      return PORT_SELECTION_UI;
+    case PORT_SELECTION_UI:
+      return base_config.tls == TLS_TYPES.REVERSE_PROXY ?
+        REVERSE_PROXY_TEMPLATE_UI :
+        base_config.delegation_type != DELEGATION_TYPES.LOCAL ?
+          DELEGATION_TEMPLATE_UI :
+          DATABASE_UI;
+    case REVERSE_PROXY_TEMPLATE_UI:
+      return base_config.delegation_type != DELEGATION_TYPES.LOCAL ?
+        DELEGATION_TEMPLATE_UI :
+        DATABASE_UI;
+    case DELEGATION_TEMPLATE_UI:
+      return DATABASE_UI;
+    case WELL_KNOWN_UI:
+    case DNS_UI:
+    default:
+      return BASE_INTRO_UI;
+  }
+}
+
+export default ({ ui, base_config }, action) => {
+  switch (action.type) {
+    case BASE_CONFIG_CHECKED:
+      return [BASE_INTRO_UI];
+    case ADVANCE_UI:
+
+
+    // TODO: Think about how back should work..
+    case BACK_UI:
+      switch (ui.active_ui) {
+        case STATS_REPORT_UI:
+          return SERVER_NAME_UI;
+        case KEY_EXPORT_UI:
+          return STATS_REPORT_UI;
+        case DELEGATION_OPTIONS_UI:
+          return KEY_EXPORT_UI;
+        case WELL_KNOWN_UI:
+          return DELEGATION_OPTIONS_UI;
+        case DNS_UI:
+          return WELL_KNOWN_UI;
+        default:
+          BASE_INTRO_UI;
+      }
+    default:
+      return ui.active_ui;
+  }
+}
diff --git a/synapse_topology/view/webui/js/reducers/state.js b/synapse_topology/view/webui/js/reducers/state.js
index 83f344640b..7f52863652 100644
--- a/synapse_topology/view/webui/js/reducers/state.js
+++ b/synapse_topology/view/webui/js/reducers/state.js
@@ -1,7 +1,12 @@
 const state = {
   ui: {
-    base_config_done: true,
-    active_ui
+    setup_done: true,
+  },
+  setup_ui: {
+    active_blocks: ["block1"],
+  },
+  config_ui: {
+
   },
   base_config: {
     servername: "server_name",
diff --git a/synapse_topology/view/webui/js/reducers/ui-reducer.js b/synapse_topology/view/webui/js/reducers/ui-reducer.js
new file mode 100644
index 0000000000..ac5ef2d7b6
--- /dev/null
+++ b/synapse_topology/view/webui/js/reducers/ui-reducer.js
@@ -0,0 +1,39 @@
+import setup_ui_reducer from './setup-ui-reducer';
+import config_ui_reducer from './config-ui-reducer';
+import { LOADING_UI, ERROR_UI } from './ui_constants';
+import { BASE_CONFIG_CHECKED, FAIL } from '../actions/types';
+
+
+export default (state, action) => {
+  console.log(state)
+  console.log(action)
+  switch (action.type) {
+    case FAIL:
+      return {
+        ...state.ui,
+        active_ui: ERROR_UI
+      }
+    case BASE_CONFIG_CHECKED:
+      if (action.setup_done) {
+        return {
+          setup_done: true,
+          config_ui: config_ui_reducer(state, action),
+        }
+      } else {
+        return {
+          setup_done: false,
+          setup_ui: setup_ui_reducer(state, action),
+        }
+      }
+    default:
+      const newstate = { ...state.ui };
+      if ('setup_done' in state.ui) {
+        if (state.ui.setup_done) {
+          newstate.config_ui = config_ui_reducer(state, action);
+        } else {
+          newstate.setup_ui = setup_ui_reducer(state, action);
+        }
+      }
+      return newstate;
+  }
+}