From e592afb1a7005512128d1ce0bab9f177f6a9dd33 Mon Sep 17 00:00:00 2001
From: Nicolas Pouillard <nicolas.pouillard@gmail.com>
Date: Thu, 13 Dec 2018 13:45:50 +0100
Subject: [PATCH] [GRAPH] Missing file

---
 src/Gargantext/Pages/Corpus/Graph/Tabs.purs | 53 +++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 src/Gargantext/Pages/Corpus/Graph/Tabs.purs

diff --git a/src/Gargantext/Pages/Corpus/Graph/Tabs.purs b/src/Gargantext/Pages/Corpus/Graph/Tabs.purs
new file mode 100644
index 00000000..26caf701
--- /dev/null
+++ b/src/Gargantext/Pages/Corpus/Graph/Tabs.purs
@@ -0,0 +1,53 @@
+module Gargantext.Pages.Corpus.Graph.Tabs where
+
+import Prelude hiding (div)
+import Data.Lens (view)
+import Data.List (fromFoldable)
+import Data.Tuple (Tuple(..))
+import Gargantext.Config (TabType(..), TabSubType(..))
+import Gargantext.Components.GraphExplorer.Types (GraphSideCorpus(..))
+import Gargantext.Components.DocsTable as DT
+import Gargantext.Components.Tab as Tab
+import React (ReactElement, ReactClass, Children, createElement)
+import Thermite ( Spec, PerformAction, Render, _performAction, _render
+                , hideState, noState, cmapProps, simpleSpec, createClass
+                )
+
+type Props = { sides :: Array GraphSideCorpus }
+
+tabsElt :: Props -> ReactElement
+tabsElt props = createElement tabsClass props []
+
+-- TODO no need for Children here
+tabsClass :: ReactClass { sides :: Array GraphSideCorpus, children :: Children }
+tabsClass = createClass "GraphTabs" pureTabs (const {})
+
+pureTabs :: Spec {} Props Void
+pureTabs = hideState (const {activeTab: 0}) statefulTabs
+
+tab :: forall props state. GraphSideCorpus -> Tuple String (Spec state props Tab.Action)
+tab (GraphSideCorpus {corpusId: nodeId, corpusLabel}) =
+  Tuple corpusLabel $
+    cmapProps (const {nodeId, chart, tabType: TabCorpus TabDocs, totalRecords: 4736}) $
+      noState DT.docViewSpec
+  where
+    -- TODO totalRecords: probably need to insert a corpusLoader.
+    chart = mempty
+
+statefulTabs :: Spec Tab.State Props Tab.Action
+statefulTabs =
+  withProps (\{sides} -> Tab.tabs identity identity $ fromFoldable $ tab <$> sides)
+
+-- TODO move to Thermite
+-- | This function captures the props of the `Spec` as a function argument.
+withProps
+  :: forall state props action
+   . (props -> Spec state props action)
+  -> Spec state props action
+withProps f = simpleSpec performAction render
+  where
+    performAction :: PerformAction state props action
+    performAction a p st = view _performAction (f p) a p st
+
+    render :: Render state props action
+    render k p st = view _render (f p) k p st
-- 
2.21.0