@@ -77,7 +77,7 @@ type TableProps row =
7777 , filterLabel :: Nullable String
7878 , sortBy :: Nullable ColumnName
7979 , style :: R.CSS
80- , getLink :: row -> URL
80+ , getLink :: Nullable ( row -> URL )
8181 , renderCell :: row -> JSX
8282 , sticky :: Boolean
8383 }
@@ -310,7 +310,9 @@ table = make component
310310 where
311311 selected = fromMaybe self.state.selected (toMaybe self.props.selected)
312312
313- primaryColumn = toMaybe self.props.primaryColumn
313+ primaryColumn = cleanUpNullables <$> toMaybe self.props.primaryColumn
314+ where
315+ cleanUpNullables x = x { getLink = toMaybe x.getLink }
314316
315317 renderTableHead columns tableRef =
316318 element (R .unsafeCreateDOMComponent " thead" )
@@ -472,7 +474,7 @@ type TableRowProps row col_ pcol_ =
472474 { name :: ColumnName
473475 , renderCell :: row -> JSX
474476 , style :: R.CSS
475- , getLink :: row -> URL
477+ , getLink :: Maybe ( row -> URL )
476478 , sticky :: Boolean
477479 | pcol_
478480 }
@@ -502,14 +504,16 @@ tableRow = make tableRowComponent { initialState: unit, shouldUpdate, render }
502504 R .tr
503505 { className: joinWith " "
504506 $ guard (tableProps.selectable && isSelected) [ " active" ]
505- <> guard (isJust tableProps.primaryColumn) [ " active-row" ]
507+ <> guard (isJust $ _.getLink =<< tableProps.primaryColumn) [ " active-row" ]
506508 , onClick:
507509 case tableProps.primaryColumn of
508- Nothing -> Events .handler_ (pure unit)
509- Just col -> Events .handler syntheticEvent \event -> do
510- s <- hasWindowSelection
511- when (not s) $
512- runEffectFn1 tableProps.onNavigate (col.getLink row)
510+ Just { getLink: Just getLink } ->
511+ Events .handler syntheticEvent \event -> do
512+ s <- hasWindowSelection
513+ when (not s) $
514+ runEffectFn1 tableProps.onNavigate (getLink row)
515+ _ ->
516+ Events .handler_ (pure unit)
513517 , children:
514518 [ if not tableProps.selectable
515519 then empty
@@ -554,11 +558,16 @@ tableRow = make tableRowComponent { initialState: unit, shouldUpdate, render }
554558 , style: col.style
555559 , " data-required" : true
556560 , children:
557- Link .link Link .defaults
558- { href = col.getLink row
559- , navigate = Just (runEffectFn1 onNavigate (col.getLink row))
560- , text = col.renderCell row
561- }
561+ case col.getLink of
562+ Nothing ->
563+ col.renderCell row
564+ Just getLink ->
565+ Link .link Link .defaults
566+ { href = getLink row
567+ , navigate = Just (runEffectFn1 onNavigate (getLink row))
568+ , text = col.renderCell row
569+ , className = Just " primary-cell-link"
570+ }
562571 }
563572
564573 renderBodyRowCell row col =
@@ -707,7 +716,7 @@ styles = jss
707716 , textOverflow: " ellipsis"
708717 , backgroundColor: cssStringHSLA colors.white
709718
710- , " &.primary-cell a" :
719+ , " &.primary-cell a.lumi.primary-cell-link " :
711720 { color: cssStringHSLA colors.primary
712721 }
713722 }
0 commit comments