Skip to content

Commit debdb26

Browse files
authored
Fix/netdata table column visibillity (#394)
* fix column visibiillity alway present * fix icon color
1 parent 7d19568 commit debdb26

3 files changed

Lines changed: 44 additions & 46 deletions

File tree

src/components/button/IconButton.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const IconButton = ({
4040
flavour={flavour}
4141
disabled={disabled}
4242
icon={icon}
43-
iconColor={isDefaultFlavour ? "iconColor" : iconColor}
43+
iconColor={isDefaultFlavour ? "white" : iconColor}
4444
iconSize={iconSize}
4545
neutral={!isDefaultFlavour}
4646
{...props}

src/components/tableV2/features/bulkActions.js

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const supportedBulkActions = {
1919
download: { icon: "download", confirmation: false, tooltipText: "Download" },
2020
toggleAlarm: { icon: "alarm_off", confirmation: false, tooltipText: "Turn of Alarms" },
2121
userSettings: { icon: "user", confirmation: false, tooltipText: "User Settings" },
22-
addEntry: { icon: "plus", alwaysEnabled: true, flavour: "default" },
22+
addEntry: { icon: "plus", alwaysEnabled: true, flavour: "default", iconColor: "white" },
2323
remove: { icon: "removeNode", confirmation: true, confirmLabel: "Yes", declineLabel: "No" },
2424
columnVisibillity: { icon: "gear", alwaysEnabled: true },
2525
}
@@ -35,7 +35,7 @@ const renderActionWithDropdown = ({
3535
}) => {
3636
if (!actions || !actions.length) return <Box aria-hidden as="span" />
3737
return actions.map(
38-
({ id, icon, handleAction, tooltipText, alwaysEnabled, isDisabled, isVisible }) => {
38+
({ id, icon, handleAction, tooltipText, alwaysEnabled, isDisabled, isVisible, ...rest }) => {
3939
return (
4040
<ActionWithDropdown
4141
key={id}
@@ -50,6 +50,7 @@ const renderActionWithDropdown = ({
5050
selectedRows={selectedRows}
5151
isOpen={isOpen}
5252
onClose={onClose}
53+
{...rest}
5354
/>
5455
)
5556
}
@@ -58,7 +59,7 @@ const renderActionWithDropdown = ({
5859

5960
const makeColumnVisibillityAction = ({ handleAction, visible }) => {
6061
const prepareColumnVisibilityAction = {
61-
id: "columnVisibility",
62+
id: "columnVisibillity",
6263
handleAction,
6364
visible,
6465
icon: "gear",
@@ -75,54 +76,51 @@ const makeBulkActions = ({
7576
selectedRows,
7677
columnVisibilityOptions,
7778
}) => {
78-
const columnVisibility = makeColumnVisibillityAction({ ...columnVisibilityOptions })
79+
const columnVisibillity = makeColumnVisibillityAction({ ...columnVisibilityOptions })
7980
const actionsWithDropdown = renderActionWithDropdown({
80-
actions: [columnVisibility],
81+
actions: [columnVisibillity],
8182
...columnVisibilityOptions,
8283
testPrefix,
8384
table,
8485
selectedRows,
8586
})
8687

87-
const availableBulkActions = Object.keys({ ...bulkActions, columnVisibility }).reduce(
88-
(acc, currentActionKey) => {
89-
const isBulkActionSupported = supportedBulkActions[currentActionKey]
90-
if (!isBulkActionSupported) return acc
91-
const {
92-
icon,
93-
confirmation,
94-
tooltipText,
95-
confirmationTitle,
96-
confirmationMessage,
97-
confirmLabel,
98-
declineLabel,
99-
handleDecline,
100-
actionButtonDirection,
101-
alwaysEnabled,
102-
iconColor,
103-
flavour,
104-
} = supportedBulkActions[currentActionKey]
105-
const currentAction = bulkActions[currentActionKey]
106-
acc.push({
107-
confirmation,
108-
tooltipText,
109-
icon,
110-
id: currentActionKey,
111-
confirmationTitle,
112-
confirmationMessage,
113-
confirmLabel,
114-
declineLabel,
115-
handleDecline,
116-
actionButtonDirection,
117-
alwaysEnabled,
118-
iconColor,
119-
flavour,
120-
...currentAction,
121-
})
122-
return acc
123-
},
124-
[]
125-
)
88+
const availableBulkActions = Object.keys({ ...bulkActions }).reduce((acc, currentActionKey) => {
89+
const isBulkActionSupported = supportedBulkActions[currentActionKey]
90+
if (!isBulkActionSupported) return acc
91+
const {
92+
icon,
93+
confirmation,
94+
tooltipText,
95+
confirmationTitle,
96+
confirmationMessage,
97+
confirmLabel,
98+
declineLabel,
99+
handleDecline,
100+
actionButtonDirection,
101+
alwaysEnabled,
102+
iconColor,
103+
flavour,
104+
} = supportedBulkActions[currentActionKey]
105+
const currentAction = bulkActions[currentActionKey]
106+
acc.push({
107+
confirmation,
108+
tooltipText,
109+
icon,
110+
id: currentActionKey,
111+
confirmationTitle,
112+
confirmationMessage,
113+
confirmLabel,
114+
declineLabel,
115+
handleDecline,
116+
actionButtonDirection,
117+
alwaysEnabled,
118+
iconColor,
119+
flavour,
120+
...currentAction,
121+
})
122+
return acc
123+
}, [])
126124

127125
if (!availableBulkActions || !availableBulkActions.length) return []
128126
const actions = availableBulkActions.map(

src/components/tableV2/netdataTable.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState } from "react"
22
import { storiesOf } from "@storybook/react"
33

4-
import Table from "./base-table"
4+
import Table from "./core/base-table"
55
import NetdataTable from "./netdataTable"
66

77
import Box from "src/components/templates/box"

0 commit comments

Comments
 (0)