Commit 18aab30e authored by Fabien Maniere's avatar Fabien Maniere

Merge branch 'feature-flags-hide' into 'dev'

Feature flags hide

See merge request !511
parents 3f014a95 b3fad287
Pipeline #7626 passed with stages
in 23 minutes and 2 seconds
......@@ -49,7 +49,7 @@ bundle.js
/dist/bundle.min.js*
# IDE specific
.idea/
.vscode/
.parcel-cache/
.vscode
dist/dev/bundle
dist/dev
.parcel-cache
......@@ -21,6 +21,7 @@
"test": "spago test",
"dev": "concurrently \"npm run watch\" \"npm run serve\" ",
"serve": "npx parcel serve --dist-dir ./dist/dev/bundle ./dist/dev/index.html",
"format-ps": "purs-tidy format-in-place src",
"prepare": "husky"
},
"dependencies": {
......
......@@ -22,6 +22,7 @@ import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T
import Gargantext.Hooks.UseFeatureFlag as Feature
type Props =
( nodeId :: ID
......@@ -107,7 +108,23 @@ layoutCpt = here.component "layout" cpt
[ editionBlock
{ nodeId }
]
, Feature.hide
{ keys: [ "expert" ]
, render: viewCodeSectionButton boxes corpusCodeRoute
}
, H.div
{ className: "node-layout__folders corpus-layout__folders" }
[ FV.folderView
{ nodeId
, session
}
]
]
viewCodeSectionButton :: Record AppStore.Store -> (Unit -> Effect GR.AppRoute) -> R.Element
viewCodeSectionButton boxes corpusCodeRoute =
H.div
{ className: "node-layout__code-section corpus-layout__code-section" }
[ tileMenu
{ boxes
......@@ -129,14 +146,6 @@ layoutCpt = here.component "layout" cpt
]
]
]
, H.div
{ className: "node-layout__folders corpus-layout__folders" }
[ FV.folderView
{ nodeId
, session
}
]
]
onExpandTableEditionChange :: T.Change Boolean -> Effect Unit
onExpandTableEditionChange { new } = do
......
......@@ -86,43 +86,6 @@ derive instance Generic DocumentV3 _
derive instance Newtype DocumentV3 _
derive newtype instance JSON.ReadForeign DocumentV3
derive newtype instance JSON.WriteForeign DocumentV3
instance Show DocumentV3 where
show = genericShow
defaultNodeDocumentV3 :: NodePoly DocumentV3
defaultNodeDocumentV3 =
NodePoly
{ id: 0
, typename: 0
, userId: 0
, parentId: Just 0
, name: "Default name"
, date: "Default date"
, hyperdata: defaultDocumentV3
}
defaultDocumentV3 :: DocumentV3
defaultDocumentV3 =
DocumentV3
{ abstract: Nothing
, authors: Nothing
--, error : Nothing
, language_iso2: Nothing
, language_iso3: Nothing
, language_name: Nothing
, publication_date: Nothing
, publication_day: Nothing
, publication_hour: Nothing
, publication_minute: Nothing
, publication_month: Nothing
, publication_second: Nothing
, publication_year: Nothing
, realdate_full_: Nothing
, source: Nothing
, statuses: Nothing
, title: Nothing
}
newtype Document =
Document
{ abstract :: Maybe String
......
......@@ -23,6 +23,7 @@ import Gargantext.Components.ListSelection as ListSelection
import Gargantext.Components.ListSelection.Types as ListSelection
import Gargantext.Config.Utils (handleRESTError)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.UseFeatureFlag as Feature
import Gargantext.Sessions (Session(..))
import Gargantext.Types (FrontendError)
import Gargantext.Types as GT
......@@ -324,7 +325,16 @@ dataFieldNavCpt = here.component "dataFieldNav" cpt
pure $ R.fragment
[ H.div { className: "text-primary text-bold p-1" } [ H.text "Search options:" ]
, H.div { className: "nav nav-tabs" } ((liItem search') <$> dataFields)
, Feature.feature
{ keys: [ "expert" ]
, render: \shouldRender ->
let
viewTabs d = H.div { className: "nav nav-tabs" } ((liItem search') <$> d)
in
if shouldRender then viewTabs dataFields
-- This hides the web tab in search
else viewTabs $ A.filter (\i -> i /= Web) dataFields
}
, H.div { className: "center p-1" }
[ H.text $ doc datafield
]
......@@ -673,7 +683,7 @@ datafieldInputCpt = here.component "datafieldInput" cpt
else
H.div {} []
, H.div {} [ searchIframes { iframeRef, search } [] ]
, Feature.hide { keys: [ "expert" ], render: H.div {} [ searchIframes { iframeRef, search } [] ] }
]
type SearchInputProps =
......@@ -741,11 +751,12 @@ submitButtonComponent = here.component "submitButton" cpt
cpt { errors, onSearch, search, selection, session } _ = do
search' <- T.useLive T.unequal search
selection' <- T.useLive T.unequal selection
{ datafield } <- T.read search
pure $
H.button
{ className: "btn btn-primary"
{ className: "btn btn-primary " <> if datafield == External Empty then "disabled" else ""
, "type": "button"
, "disabled": if datafield == External Empty then "true" else "false"
, on: { click: doSearch onSearch errors session selection' search' }
, style: { width: "100%" }
}
......
......@@ -17,6 +17,7 @@ import Gargantext.Components.PhyloExplorer.API as Phylo
import Gargantext.Components.PhyloExplorer.Config.ConfigForm as PhyloForm
import Gargantext.Components.PhyloExplorer.ConfigFormParser as PhyloHook
import Gargantext.Config.REST (AffRESTError)
import Gargantext.Hooks.UseFeatureFlag as Feature
import Gargantext.Routes as GR
import Gargantext.Sessions (Session, post)
import Gargantext.Types (ID, NodeType(..))
......@@ -263,15 +264,24 @@ updateNodeListCpt = here.component "updateNodeList" cpt
, iconName: "reload-with-settings"
, textTitle: "Update terms"
}
[ Tools.formChoiceSafe
{ items: [ Basic, Advanced, WithModel ]
[ Feature.feature
{ keys: [ "expert" ]
, render: \shouldRender ->
if shouldRender then viewUpdateTermsOptions methodList' methodList [ Basic, Advanced, WithModel ]
else viewUpdateTermsOptions methodList' methodList [ Basic ]
}
]
viewUpdateTermsOptions :: forall box11 t13. Show t13 => T.Write box11 t13 => t13 -> box11 -> Array t13 -> R.Element
viewUpdateTermsOptions methodList' methodList items =
Tools.formChoiceSafe
{ items: items
, default: methodList'
, callback: \val -> T.write_ val methodList
, print: show
, label: "Update with:"
}
[]
]
updateTexts :: R2.Component UpdateProps
updateTexts = R.createElement updateTextsCpt
......
......@@ -92,7 +92,7 @@ actionWriteNodesDocumentsWithLangsCpt = here.component "actionWriteNodesDocument
[ H.div
{ className: "form-group__label" }
[ B.label_ $
"Please select the language of your current Notes:"
"Select the language of your current Notes:"
]
, H.div
{ className: "form-group__field" }
......@@ -111,7 +111,7 @@ actionWriteNodesDocumentsWithLangsCpt = here.component "actionWriteNodesDocument
[ H.div
{ className: "form-group__label" }
[ B.label_ $
"Please set the document size you require:"
"Choose the length of the context window:"
]
, H.div
{ className: "form-group__field" }
......@@ -130,7 +130,7 @@ actionWriteNodesDocumentsWithLangsCpt = here.component "actionWriteNodesDocument
[ H.div
{ className: "form-group__label" }
[ B.label_ $
"Please choose the list of terms to use:"
"Choose the list of terms to use:"
]
, H.div
{ className: "form-group__field" }
......
......@@ -23,6 +23,7 @@ import Reactix as R
import Reactix.DOM.HTML as H
import Record.Extra as RX
import Toestand as T
import Gargantext.Hooks.UseFeatureFlag as Feature
here :: R2.Here
here = R2.here "Gargantext.Components.Forest.Tree.Node.Tools"
......@@ -280,7 +281,7 @@ formChoiceSafeCpt = here.component "formChoiceSafe" cpt
cpt { items, default, callback, print, label } _ = do
pure $ case items of
[] -> H.div {} []
[ n ] -> formButton { item: n, callback, print } []
-- [ n ] -> formButton { item: n, callback, print } []
_ -> formChoice { items, default, callback, print, label } []
type FormChoiceProps item m =
......@@ -304,14 +305,23 @@ formChoiceCpt = here.component "formChoice" cpt
cpt { items, callback, default, print, label } _ = do
pure $ H.div { className: "form-group" }
[ H.label {} [ H.text label ]
, R2.select
, Feature.feature
{ keys: [ "expert" ]
, render: \shouldRender ->
if shouldRender then viewSelectNodeOptions $ map option items
else viewSelectNodeOptions $ map option (A.filter (\i -> print i `A.notElem` [ "Visio", "Annuaire" ]) items)
}
]
where
viewSelectNodeOptions options =
R2.select
{ className: "form-control with-icon-font"
, defaultValue: show default
, on: { change }
} $ map option items
]
} $ options
where
change e = callback $ fromMaybe default $ reader $ R.unsafeEventValue e
option opt = H.option { value: show opt } [ H.text $ print opt ]
......
......@@ -25,6 +25,7 @@ import Gargantext.Components.App.Store as AppStore
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (ButtonVariant(..), Elevation(..), Variant(..))
import Gargantext.Components.GraphExplorer.Sidebar.ContactList (contactListWrapper)
import Gargantext.Hooks.UseFeatureFlag as Feature
import Gargantext.Components.GraphExplorer.Sidebar.DocList (docListWrapper)
import Gargantext.Components.GraphExplorer.Sidebar.Legend as Legend
import Gargantext.Components.GraphExplorer.Store as GraphStore
......@@ -101,13 +102,23 @@ sidebarCpt = here.component "sidebar" cpt
, callback: closeCallback
, className: "graph-sidebar__close"
}
,
-- Menu
B.tabs
, Feature.feature
{ keys: [ "expert" ]
, render: \shouldRender ->
if shouldRender then B.tabs
{ value: sideTab'
, list: sideTabs
, callback: flip T.write_ sideTab
}
else B.tabs
{ value: sideTab'
, list: [ GET.SideTabLegend, GET.SideTabData ]
, callback: flip T.write_ sideTab
}
}
, case sideTab' of
GET.SideTabLegend -> sideTabLegend props
GET.SideTabData -> sideTabData props
......
......@@ -39,6 +39,7 @@ import Gargantext.Components.Bootstrap.Types (Elevation(..), Position(..), Toolt
import Gargantext.Components.Data.Landing (BlockText(..), BlockTexts(..), Button(..), LandingData(..))
import Gargantext.Components.FolderView as FV
import Gargantext.Components.Lang (LandingLang(..))
import Gargantext.Hooks.UseFeatureFlag as Feature
import Gargantext.Components.Lang.Landing.EnUS as En
import Gargantext.Components.Lang.Landing.FrFR as Fr
import Gargantext.Config as Config
......@@ -138,7 +139,7 @@ homeLayoutCpt = here.component "homeLayout" cpt
]
-- @TODO
-- H.div { className: "home-research-form" } []
, blocksRandomText' landingData
, Feature.hide { keys: [ "expert" ], render: blocksRandomText' landingData }
, B.wad
[ "mt-8" ]
[ license
......
module Gargantext.Components.TopBar (component) where
import Gargantext.Prelude
import Affjax.RequestBody (document)
import Data.Foldable (intercalate)
import Data.Maybe (Maybe(..), isJust, fromMaybe)
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect.Console (log)
import Gargantext.Components.App.Store as AppStore
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (ButtonVariant(..), Variant(..))
import Gargantext.Components.Themes (themeSwitcher, allThemes)
import Gargantext.Prelude
import Gargantext.Components.Themes as Themes
import Gargantext.Hooks.FirstEffect (useFirstEffect')
import Gargantext.Hooks.UseFeatureFlag as Feature
import Gargantext.Sessions.Types (update)
import Gargantext.Types (Handed(..), defaultCacheParams)
import Gargantext.Utils (setter, (?))
import Gargantext.Utils.Reactix as R2
import Reactix (Hooks)
import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T
import Web.HTML (window)
import Web.HTML.Location (host, protocol)
import Web.HTML.Window as Window
here :: R2.Here
here = R2.here "Gargantext.Components.TopBar"
......@@ -31,9 +44,15 @@ componentCpt = here.component "main" cpt
} <- AppStore.use
showTree' <- R2.useLive' showTree
(windowLocation /\ updateWindowLocation) <- R.useState' Nothing
-- | Effects
-- |
useFirstEffect' $ do
l <- window >>= Window.location >>= host
protocol <- window >>= Window.location >>= protocol
let url = protocol <> "//" <> l
updateWindowLocation (\_prev -> Just url)
-- | Behaviors
-- |
......@@ -53,8 +72,29 @@ componentCpt = here.component "main" cpt
, role: "navigation"
}
[ logo
, divDropdownLeft {} []
, H.li
, viewSideBar showTree' onTreeToggleClick
, viewChangeLayoutSide
, viewInfoMenu { location: windowLocation } []
, Feature.hide
{ keys: [ "expert" ]
, render: viewQuestionMark
}
, Feature.hide
{ keys: [ "expert" ]
, render: viewThemeSelector theme
}
, H.div
{ id: "portal-topbar"
, className: "ml-1 w-100 h-100"
}
[]
]
viewChangeLayoutSide :: R.Element
viewChangeLayoutSide =
H.li
{ title: "If you are Left Handed you can change\n"
<> "the interface by clicking on me. Click\n"
<> "again to come back to previous state."
......@@ -63,20 +103,11 @@ componentCpt = here.component "main" cpt
[ handedChooser
{}
]
, H.li
{ title: "Hello! Looking for the tree?\n"
<> "Just watch on the other side!\n"
<> "Click on the hand again to see it back."
, className: "nav-item main-topbar__help-button"
}
[ H.a
{ className: "nav-link navbar-text" }
[ H.span
{ className: "fa fa-question-circle-o" }
[]
]
]
, H.li { className: "nav-item" }
viewSideBar :: Boolean -> (Unit -> Effect Unit) -> R.Element
viewSideBar showTree' onTreeToggleClick =
H.li { className: "nav-item" }
[ B.button
{ variant: showTree'
? ButtonVariant Light
......@@ -92,14 +123,12 @@ componentCpt = here.component "main" cpt
{ name: "sidebar"
, className: ""
}
-- ,
-- if showTree'
-- then H.text $ nbsp 1 <> "Hide Tree"
-- else H.text $ nbsp 1 <> "Show Tree"
]
]
, H.li
viewThemeSelector :: T.Box Themes.Theme -> R.Element
viewThemeSelector theme =
H.li
{ className: "nav-item main-topbar__theme-switcher" }
[ themeSwitcher
{ theme
......@@ -108,31 +137,25 @@ componentCpt = here.component "main" cpt
[]
]
{- ,
H.li { className: "nav-item main-topbar__lang-switcher" }
[ langSwitcher
{ lang
, langs: allFeLangs
} []
]-}
{- , B.button
{ variant: showTree' ?
ButtonVariant Light $
OutlinedButtonVariant Light
, callback: onTreeToggleClick
, className: "main-topbar__tree-switcher"
}
[
if showTree'
then H.text "Hide Tree"
else H.text "Show Tree"
]-}
, H.div
{ id: "portal-topbar"
, className: "ml-1 w-100 h-100"
empty :: R.Element
empty =
H.text ""
viewQuestionMark :: R.Element
viewQuestionMark =
H.li
{ title: "Hello! Looking for the tree?\n"
<> "Just watch on the other side!\n"
<> "Click on the hand again to see it back."
, className: "nav-item main-topbar__help-button"
}
[ H.a
{ className: "nav-link navbar-text" }
[ H.span
{ className: "fa fa-question-circle-o" }
[]
]
]
-- SB.searchBar {session, databases: allDatabases}
......@@ -154,28 +177,28 @@ logo =
src = "images/logoSmall.png"
title = "Back to home"
divDropdownLeft :: R2.Component ()
divDropdownLeft = R.createElement divDropdownLeftCpt
viewInfoMenu :: R2.Component (location :: Maybe String)
viewInfoMenu = R.createElement viewInfoMenu'
divDropdownLeftCpt :: R.Component ()
divDropdownLeftCpt = here.component "divDropdownLeft" cpt
viewInfoMenu' :: R.Component (location :: Maybe String)
viewInfoMenu' = here.component "divDropdownLeft" cpt
where
cpt {} _ = do
cpt { location } _ = do
show <- T.useBox false
pure $ H.li { className: "nav-item dropdown" }
[ menuButton { element: menuElement, show } []
, menuElements { elements, show } []
, menuElements { elements: elements location, show } []
]
menuElement = LiNav
{ title: "GarganText"
, href: "#"
, icon: "fa fa-navicon"
, text: "GarganText"
, icon: "fa fa-question-circle-o"
, text: "infos"
}
elements =
elements location =
[ [ LiNav
{ title: "User documentation"
, href: "https://write.frame.gargantext.org/s/649a6d7e1db3b365d6d0b1430d9700cc0bb4fdb1348dd1040a94c95f98979abe"
......@@ -228,7 +251,13 @@ divDropdownLeftCpt = here.component "divDropdownLeft" cpt
-}
, LiNav
{ title: "API documentation"
, href: "https://cnrs.gargantext.org/swagger-ui"
, href: case location of
Just l ->
l <> "/swagger-ui"
Nothing ->
"https://cnrs.gargantext.org/swagger-ui"
, icon: "fa fa-code-fork"
, text: "API documentation"
}
......
......@@ -53,6 +53,13 @@ feature = R2.renderLeaf "" $
render shouldRender
)
hide = R2.renderLeaf "" $
( \{ keys, render } _ -> do
shouldRender <- useFeatureFlag keys
pure $
if shouldRender then render else H.text ""
)
hideBehind :: forall a. Array String -> R2.Component a -> R2.Component a
hideBehind keys cpt = R2.renderComponent "" \props children -> do
shouldRender <- useFeatureFlag keys
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment