Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change: [M3-8533, M3-8761] - Fix firewall rules table and Replace react-beautiful-dnd with dnd-kit lib #11127

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
bf3ffdf
Fix firewall rules table
pmakode-akamai Oct 15, 2024
b69eccd
Update the comment
pmakode-akamai Oct 16, 2024
8c9623f
Added changeset: Broken firewall rules table
pmakode-akamai Oct 16, 2024
348a09e
Keeping PolicyRow to 2 grids for sm breakpoint
pmakode-akamai Oct 16, 2024
bc08712
Add padding to headers and cells
pmakode-akamai Oct 17, 2024
d595043
Add line height to StyledHeaderItemBox
pmakode-akamai Oct 17, 2024
0aeff7d
Update some styles
pmakode-akamai Oct 17, 2024
0c7364e
Update styles
pmakode-akamai Oct 17, 2024
2184238
Fix broken firewall rules table and replace react-beautiful-dnd with …
pmakode-akamai Oct 18, 2024
2c10fbf
Set cursor style to 'grab' or 'grabbing' based on drag state
pmakode-akamai Oct 18, 2024
3048fb8
isDragging state var pos fix
pmakode-akamai Oct 18, 2024
32ddf50
Add TouchSensor and collisionDetection
pmakode-akamai Oct 19, 2024
d8687a0
Add width to table cells for improved layout
pmakode-akamai Oct 21, 2024
e2f1290
Some cleanup...
pmakode-akamai Oct 21, 2024
a899b40
Update width
pmakode-akamai Oct 21, 2024
62d6694
Fix colors for pending deletion row and clean up styling for rule btn
pmakode-akamai Oct 21, 2024
8cce4e2
Added changeset: Broken firewall rules table
pmakode-akamai Oct 21, 2024
93ce0da
Added changeset: Replace `react-beautiful-dnd` with `dnd-kit` library
pmakode-akamai Oct 21, 2024
5a3bfac
Remove react-beautiful-dnd from the codebase
pmakode-akamai Oct 22, 2024
2aca5f6
Remove react-beautiful-dnd from the codebase
pmakode-akamai Oct 22, 2024
e23f486
Remove initial pos focus on drag end and enable rows to drag over others
pmakode-akamai Oct 22, 2024
b42fa67
Refactoring...
pmakode-akamai Oct 22, 2024
de5bc2e
Update firewall e2e tests
pmakode-akamai Oct 22, 2024
9070268
Adjust label column to prevent text wrapping on mobile and some clean…
pmakode-akamai Oct 22, 2024
6331d56
Improve smoothness of row dragging
pmakode-akamai Oct 23, 2024
01b9913
overflow logic & styling
abailly-akamai Oct 23, 2024
635227e
add missing keyboard sensor
abailly-akamai Oct 23, 2024
6fadcb4
Fix weird scalling with varying row heights and enable drag on navs a…
pmakode-akamai Oct 24, 2024
cbbe3f1
Remove Label col nowrap to keep table inplace on overflow and some ad…
pmakode-akamai Oct 24, 2024
0802cd4
revert overflow issue
abailly-akamai Oct 24, 2024
fba1a42
revert overflow issue
abailly-akamai Oct 24, 2024
fbd98f9
fix sortable via keyboard behavior
abailly-akamai Oct 24, 2024
5727014
Clean up imports
pmakode-akamai Oct 24, 2024
df6d864
Fix scrolling behavior when using keyboard keys
pmakode-akamai Oct 29, 2024
2964689
Add changeset and fix typo
pmakode-akamai Oct 30, 2024
082b9a2
Fix focus reset when dragging elements via keyboard
pmakode-akamai Oct 31, 2024
275706b
Add theme compatible background color focus
pmakode-akamai Nov 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Changed
---

Replace `react-beautiful-dnd` with `dnd-kit` library ([#11127](https://github.com/linode/manager/pull/11127))
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11127-fixed-1729515738287.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Fixed
---

Broken firewall rules table ([#11127](https://github.com/linode/manager/pull/11127))
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11127-fixed-1730275015638.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Fixed
---

Table component styling issue for `noOverflow` property ([#11127](https://github.com/linode/manager/pull/11127))
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ describe('update firewall', () => {
// Confirm that the inbound rules are listed on edit page with expected configuration
cy.findByText(inboundRule.label!)
.should('be.visible')
.closest('li')
.closest('tr')
.within(() => {
cy.findByText(inboundRule.protocol).should('be.visible');
cy.findByText(inboundRule.ports!).should('be.visible');
Expand All @@ -237,7 +237,7 @@ describe('update firewall', () => {
// Confirm that the outbound rules are listed on edit page with expected configuration
cy.findByText(outboundRule.label!)
.should('be.visible')
.closest('li')
.closest('tr')
.within(() => {
cy.findByText(outboundRule.protocol).should('be.visible');
cy.findByText(outboundRule.ports!).should('be.visible');
Expand Down
4 changes: 3 additions & 1 deletion packages/manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"url": "https://github.com/Linode/manager.git"
},
"dependencies": {
"@dnd-kit/core": "^6.1.0",
"@dnd-kit/sortable": "^8.0.0",
"@dnd-kit/utilities": "^3.2.2",
pmakode-akamai marked this conversation as resolved.
Show resolved Hide resolved
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@hookform/resolvers": "2.9.11",
Expand Down Expand Up @@ -61,7 +64,6 @@
"qrcode.react": "^0.8.0",
"ramda": "~0.25.0",
"react": "^18.2.0",
"react-beautiful-dnd": "^13.0.0",
"react-csv": "^2.0.3",
"react-dom": "^18.2.0",
"react-dropzone": "~11.2.0",
Expand Down
32 changes: 16 additions & 16 deletions packages/manager/src/components/Table/Table.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ export const StyledTableWrapper = styled('div', {
'spacingTop',
]),
})<TableProps>(({ theme, ...props }) => ({
'& thead': {
'& th': {
'&:first-of-type': {
borderLeft: 'none',
},
'&:last-of-type': {
borderRight: 'none',
},
backgroundColor: theme.bg.tableHeader,
borderBottom: `1px solid ${theme.borderColors.borderTable}`,
borderRight: `1px solid ${theme.borderColors.borderTable}`,
borderTop: `1px solid ${theme.borderColors.borderTable}`,
fontFamily: theme.font.bold,
padding: '10px 15px',
},
},
marginBottom: props.spacingBottom !== undefined ? props.spacingBottom : 0,
marginTop: props.spacingTop !== undefined ? props.spacingTop : 0,
...(!props.noOverflow && {
'& thead': {
'& th': {
'&:first-of-type': {
borderLeft: 'none',
},
'&:last-of-type': {
borderRight: 'none',
},
backgroundColor: theme.bg.tableHeader,
borderBottom: `1px solid ${theme.borderColors.borderTable}`,
borderRight: `1px solid ${theme.borderColors.borderTable}`,
borderTop: `1px solid ${theme.borderColors.borderTable}`,
fontFamily: theme.font.bold,
padding: '10px 15px',
},
},
overflowX: 'auto',
overflowY: 'hidden',
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,29 @@ import type { FirewallRuleTableRowProps } from './FirewallRuleTable';

type StyledFirewallRuleButtonProps = Pick<FirewallRuleTableRowProps, 'status'>;

interface FirewallRuleTableRowPropsWithRuleId
interface FirewallRuleTableRowPropsWithRuleIndex
extends Pick<FirewallRuleTableRowProps, 'disabled' | 'originalIndex'> {
ruleId: number;
ruleIndex: number;
}

interface StyledFirewallRuleBoxProps
extends FirewallRuleTableRowPropsWithRuleId {
interface StyledFirewallRuleTableRowProps
extends FirewallRuleTableRowPropsWithRuleIndex {
status: FirewallRuleTableRowProps['status'];
}

export const sxBox = {
alignItems: 'center',
display: 'flex',
width: '100%',
};

export const sxItemSpacing = {
padding: `0 8px`,
};

export const StyledFirewallRuleBox = styled(Box, {
label: 'StyledFirewallRuleBox',
shouldForwardProp: omittedProps(['originalIndex', 'ruleId']),
})<StyledFirewallRuleBoxProps>(
({ disabled, originalIndex, ruleId, status, theme }) => ({
borderBottom: `1px solid ${theme.borderColors.borderTable}`,
color: theme.textColors.tableStatic,
fontSize: '0.875rem',
margin: 0,
...sxBox,

// Note: Use 'tr' instead of 'TableRow' here for a smoother draggable user experience.
export const StyledTableRow = styled('tr', {
label: 'StyledTableRow',
shouldForwardProp: omittedProps(['originalIndex', 'ruleIndex']),
})<StyledFirewallRuleTableRowProps>(
({ disabled, originalIndex, ruleIndex, status, theme }) => ({
// Conditional styles
// Highlight the row if it's been modified or reordered. ID is the current index,
// Highlight the row if it's been modified or reordered. ruleIndex is the current index,
// so if it doesn't match the original index we know that the rule has been moved.
...(status === 'PENDING_DELETION' || disabled
? {
'& td': { color: '#D2D3D4' },
backgroundColor: 'rgba(247, 247, 247, 0.25)',
}
? { backgroundColor: theme.color.grey7 }
: {}),
...(status === 'MODIFIED' || status === 'NEW' || originalIndex !== ruleId
...(status === 'MODIFIED' || status === 'NEW' || originalIndex !== ruleIndex
? { backgroundColor: theme.bg.lightBlue1 }
: {}),
...(status === 'NOT_MODIFIED' ? { backgroundColor: theme.bg.bgPaper } : {}),
Expand All @@ -59,38 +41,17 @@ export const StyledFirewallRuleBox = styled(Box, {
export const StyledInnerBox = styled(Box, { label: 'StyledInnerBox' })(
({ theme }) => ({
backgroundColor: theme.bg.tableHeader,
color: theme.textColors.tableHeader,
fontFamily: theme.font.bold,
fontSize: '.875rem',
height: '46px',
})
);

export const StyledUlBox = styled(Box, { label: 'StyledUlBox' })(
({ theme }) => ({
alignItems: 'center',
backgroundColor: theme.bg.bgPaper,
borderBottom: `1px solid ${theme.borderColors.borderTable}`,
color: theme.textColors.tableStatic,
display: 'flex',
fontSize: '0.875rem',
justifyContent: 'center',
padding: theme.spacing(1),
width: '100%',
})
);

export const StyledFirewallRuleButton = styled('button', {
label: 'StyledFirewallRuleButton',
})<StyledFirewallRuleButtonProps>(({ status, theme }) => ({
})<StyledFirewallRuleButtonProps>(() => ({
backgroundColor: 'transparent',
border: 'none',
cursor: 'pointer',

// Conditional styles
...(status !== 'PENDING_DELETION'
? { backgroundColor: theme.bg.lightBlue1 }
: {}),
}));

export const StyledFirewallTableButton = styled(Button, {
Expand Down Expand Up @@ -139,11 +100,3 @@ export const StyledDragIndicator = styled(DragIndicator, {
position: 'relative',
top: 2,
}));

export const StyledUl = styled('ul', { label: 'StyledUl' })(({ theme }) => ({
backgroundColor: theme.color.border3,
listStyle: 'none',
margin: 0,
paddingLeft: 0,
width: '100%',
}));
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { firewallRuleToRowData } from './FirewallRuleTable';
import { ExtendedFirewallRule } from './firewallRuleEditor';

import type { ExtendedFirewallRule } from './firewallRuleEditor';

describe('Firewall rule table tests', () => {
describe('firewallRuleToRowData', () => {
Expand Down
Loading