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

feat: added column freeze and unfreeze functionality to table widget #18757

Merged
merged 62 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
cf4ab0d
feat: added column freeze and unfreeze functionality to table widget
keyurparalkar Dec 7, 2022
d5a7286
chore: resolved merge conflicts
keyurparalkar Dec 7, 2022
0490545
fix: addressed review comments
keyurparalkar Dec 9, 2022
62ccbe5
fix: added sticky behaviour on virtualization
keyurparalkar Dec 11, 2022
5f21cff
fix:
keyurparalkar Dec 11, 2022
2482a74
design system version updated
albinAppsmith Dec 15, 2022
34dfa7f
fix: addressed review comments
keyurparalkar Dec 15, 2022
c32243f
DS package version updated
albinAppsmith Dec 16, 2022
e527e92
fix: address review comments
keyurparalkar Dec 19, 2022
5befba8
fix: change the default sticky value to blank string
keyurparalkar Dec 19, 2022
ab57889
chore: removed unused imports
keyurparalkar Dec 19, 2022
72726b9
chore: removed unnecessary comments
keyurparalkar Dec 20, 2022
9029fe4
refactor:
keyurparalkar Dec 20, 2022
2578403
refactor: removed unused leftOrder and rightOrder metaproperties
keyurparalkar Dec 21, 2022
255b91c
fix: addressed review comments
keyurparalkar Dec 22, 2022
cb4997f
chore: resolved conflicts
keyurparalkar Dec 23, 2022
85bd5e3
Ds version update
albinAppsmith Dec 26, 2022
206c4b8
fix: bg color issue and column unfreezing logic
keyurparalkar Dec 26, 2022
aec5d09
fix: background color for sticky columns
keyurparalkar Dec 26, 2022
1082ac0
fix:
keyurparalkar Dec 26, 2022
d895ae6
ds package updated
albinAppsmith Jan 5, 2023
1ca031d
fix: addressed review callouts
keyurparalkar Jan 5, 2023
263c8bd
fix: removed unused import
keyurparalkar Jan 5, 2023
e2dc3d6
chore: merged conflicts
keyurparalkar Jan 5, 2023
09e9e9d
ds version update
albinAppsmith Jan 9, 2023
27cd90f
fix: changed variable name
keyurparalkar Jan 9, 2023
90e8bf5
fix:
keyurparalkar Jan 10, 2023
3b2c62c
fix:
keyurparalkar Jan 12, 2023
d3a0bcb
fix:
keyurparalkar Jan 15, 2023
70b083c
fix: removed unused imports
keyurparalkar Jan 15, 2023
8528318
fix:
keyurparalkar Jan 24, 2023
7922baf
Merge branch 'release' into feat/feat-table-sticky-columns
keyurparalkar Jan 24, 2023
daef34f
fix: addressed minor fixes
keyurparalkar Jan 24, 2023
f8f7694
Merge branch 'release' into feat/feat-table-sticky-columns
keyurparalkar Jan 24, 2023
80be4eb
DS version updated
albinAppsmith Jan 24, 2023
9ed9214
Merge branch 'release' into feat/feat-table-sticky-columns
keyurparalkar Jan 25, 2023
7864cf6
fix: build issues
keyurparalkar Jan 25, 2023
513d0b1
updated DS package
albinAppsmith Jan 25, 2023
f21b6be
fix: added unfreeze minus icon in property pane
keyurparalkar Jan 25, 2023
aea9723
fix: failing cypress and column width issue on empty cells
keyurparalkar Jan 27, 2023
098cf6d
fix:
keyurparalkar Jan 30, 2023
6dd4485
fix: addressed review callouts
keyurparalkar Jan 30, 2023
e8edc52
fix:
keyurparalkar Feb 1, 2023
48aad05
Merge branch 'release' into feat/feat-table-sticky-columns
keyurparalkar Feb 1, 2023
2aae332
fix: addressed QA callouts
keyurparalkar Feb 7, 2023
6812c64
fix: addressed review callouts
keyurparalkar Feb 7, 2023
92c7f4e
Merge branch 'release' into feat/feat-table-sticky-columns
keyurparalkar Feb 7, 2023
a893584
Merge branch 'release' into feat/feat-table-sticky-columns
Aishwarya-U-R Feb 8, 2023
58d9787
fix: renamed function
keyurparalkar Feb 8, 2023
c45b5c9
fix:
keyurparalkar Feb 9, 2023
928a61f
Merge branch 'release' into feat/feat-table-sticky-columns
keyurparalkar Feb 10, 2023
ae0e705
fix: removed console statement from widget command
keyurparalkar Feb 10, 2023
33ba1de
chore: updated design-system package that consists of draggable list …
keyurparalkar Feb 10, 2023
6f4942d
fix: cypress failures
keyurparalkar Feb 10, 2023
6ae9bf2
Merge branch 'release' into feat/feat-table-sticky-columns
keyurparalkar Feb 11, 2023
b3e21f5
fix: added wait timer in cypress test
keyurparalkar Feb 11, 2023
ae2ce47
fix: add wait in cypress test
keyurparalkar Feb 13, 2023
4fde51b
Merge branch 'release' into feat/feat-table-sticky-columns
keyurparalkar Feb 13, 2023
9f96e6c
test: check if element is in view
keyurparalkar Feb 14, 2023
2c4aa6c
test: change disabled color test
keyurparalkar Feb 14, 2023
0b5b255
Merge branch 'release' into feat/feat-table-sticky-columns
keyurparalkar Feb 14, 2023
bc3e931
Merge branch 'release' into feat/feat-table-sticky-columns
Aishwarya-U-R Feb 14, 2023
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
Expand Up @@ -3,33 +3,35 @@ const widgetsPage = require("../../../../../locators/Widgets.json");
const dsl = require("../../../../../fixtures/tabsWidgetReset.json");
const publishPage = require("../../../../../locators/publishWidgetspage.json");

describe("Tabs widget on change of selection navigation usecases", function () {
before(() => {
cy.addDsl(dsl);
});
describe("Tabs widget on change of selection navigation usecases", function() {
before(() => {
cy.addDsl(dsl);
});

it("1.On change of tab selection Navigate to a URL", function () {
cy.openPropertyPane("tabswidget");
cy.get(".code-highlight")
.children()
.contains("No action")
.last()
.click({ force: true })
.selectOnClickOption("Navigate to");
cy.wait(5000);
cy.get("#switcher--url").click({ force: true });
cy.testCodeMirrorWithIndex("www.appsmith.com", 1);
cy.wait(5000);
});

it("2.Publish the app and validate the navigation change on tab selection.", function () {
cy.PublishtheApp();
cy.wait(5000);
cy.get(".t--page-switch-tab:contains('Tab 3')").click({force: true},{ multiple: true });
cy.url().should('include', 'appsmith');
cy.go('back');
cy.get(".t--page-switch-tab:contains('Tab 3')").should("be.visible");
//cy.get(publishPage.backToEditor).click({ force: true });
});
it("1.On change of tab selection Navigate to a URL", function() {
cy.openPropertyPane("tabswidget");
cy.get(".code-highlight")
.children()
.contains("No action")
.last()
.click({ force: true })
.selectOnClickOption("Navigate to");
cy.wait(5000);
cy.get("#switcher--url").click({ force: true });
cy.testCodeMirrorWithIndex("www.appsmith.com", 1);
cy.wait(5000);
});

it("2.Publish the app and validate the navigation change on tab selection.", function() {
cy.PublishtheApp();
cy.wait(5000);
cy.get(".t--page-switch-tab:contains('Tab 3')").click(
{ force: true },
{ multiple: true },
);
cy.url().should("include", "appsmith");
cy.go("back");
cy.get(".t--page-switch-tab:contains('Tab 3')").should("be.visible");
//cy.get(publishPage.backToEditor).click({ force: true });
});
});
3 changes: 1 addition & 2 deletions app/client/cypress/support/widgetCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,7 @@ Cypress.Commands.add("updateComputedValueV2", (value) => {
cy.wait(1000);
});


Cypress.Commands.add("testCodeMirrorWithIndex", (value,index) => {
Cypress.Commands.add("testCodeMirrorWithIndex", (value, index) => {
cy.EnableAllCodeEditors();
cy.get(".CodeMirror textarea")
.eq(index)
Expand Down
3 changes: 2 additions & 1 deletion app/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"cypress-log-to-output": "^1.1.2",
"dayjs": "^1.10.6",
"deep-diff": "^1.0.2",
"design-system": "npm:@appsmithorg/[email protected].37",
"design-system": "npm:@appsmithorg/[email protected].40-alpha.2",
"downloadjs": "^1.4.7",
"draft-js": "^0.11.7",
"exceljs-lightweight": "^1.14.0",
Expand Down Expand Up @@ -129,6 +129,7 @@
"react-spring": "^9.4.0",
"react-syntax-highlighter": "^15.5.0",
"react-table": "^7.0.0",
"react-table-sticky": "^1.1.3",
"react-tabs": "^3.0.0",
"react-timer-hook": "^3.0.4",
"react-toastify": "^5.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
StyledHiddenIcon,
StyledCheckbox,
StyledActionContainer,
StyledPinIcon,
} from "components/propertyControls/StyledControls";
import { Colors } from "constants/Colors";
import { CheckboxType } from "design-system";
Expand All @@ -34,6 +35,7 @@ type RenderComponentProps = {
isDuplicateLabel?: boolean;
isChecked?: boolean;
isCheckboxDisabled?: boolean;
sticky?: string;
};
isDelete?: boolean;
isDragging: boolean;
Expand Down Expand Up @@ -146,7 +148,12 @@ export function DraggableListCard(props: RenderComponentProps) {

return (
<ItemWrapper className={item.isDuplicateLabel ? "has-duplicate-label" : ""}>
<StyledDragIcon height={20} width={20} />
{item.sticky ? (
<StyledPinIcon height={20} width={20} />
) : (
<StyledDragIcon height={20} width={20} />
)}

<StyledOptionControlInputGroup
autoFocus={index === focusedIndex}
className={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class PrimaryColumnsControlV2 extends BaseControl<ControlProps, State> {
isColumnTypeEditable(column.columnType) && column.isEditable,
isCheckboxDisabled:
!isColumnTypeEditable(column.columnType) || column.isDerived,
sticky: column.sticky,
};
},
);
Expand Down
18 changes: 18 additions & 0 deletions app/client/src/components/propertyControls/StyledControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,24 @@ export const StyledDragIcon = styled(
}
`;

export const StyledPinIcon = styled(ControlIcons.PIN as AnyStyledComponent)`
padding: 0;
position: absolute;
margin-right: 15px;
cursor: move;
z-index: 1;
left: 4px;
&& svg {
width: 16px;
height: 16px;
position: relative;
top: 2px;
path {
fill: ${(props) => props.theme.colors.propertyPane.iconColor};
}
}
`;

export const FlexWrapper = styled.div`
display: flex;
`;
Expand Down
6 changes: 6 additions & 0 deletions app/client/src/icons/ControlIcons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import { ReactComponent as BoxShadowVariant3Icon } from "assets/icons/control/bo
import { ReactComponent as BoxShadowVariant4Icon } from "assets/icons/control/box-shadow-variant4.svg";
import { ReactComponent as BoxShadowVariant5Icon } from "assets/icons/control/box-shadow-variant5.svg";
import IncreaseV2Icon from "remixicon-react/AddLineIcon";
import PinIcon from "remixicon-react/Pushpin2LineIcon";
import PlayIcon from "assets/icons/control/play-icon.png";
import CopyIcon from "remixicon-react/FileCopyLineIcon";
import QuestionIcon from "remixicon-react/QuestionLineIcon";
Expand Down Expand Up @@ -400,6 +401,11 @@ export const ControlIcons: {
<QuestionIcon />
</IconWrapper>
),
PIN: (props: IconProps) => (
<IconWrapper {...props}>
<PinIcon />
</IconWrapper>
),
};

export type ControlIconName = keyof typeof ControlIcons;
2 changes: 2 additions & 0 deletions app/client/src/widgets/TableWidgetV2/component/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ export interface TableColumnProps {
metaProperties?: TableColumnMetaProps;
isDerived?: boolean;
columnProperties: ColumnProperties;
sticky?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use enum instead of string. Improves type safety

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have set the enum's value to lower-case since the underlying library expects the values in lower case.

}
export interface ReactTableColumnProps extends TableColumnProps {
Cell: (props: any) => JSX.Element;
Expand Down Expand Up @@ -338,6 +339,7 @@ export interface ColumnProperties
onItemClicked?: (onClick: string | undefined) => void;
iconButtonStyle?: ButtonStyleType;
imageSize?: ImageSize;
sticky?: string;
}

export const ConditionFunctions: {
Expand Down
10 changes: 8 additions & 2 deletions app/client/src/widgets/TableWidgetV2/component/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
useRowSelect,
Row as ReactTableRowType,
} from "react-table";
import { useSticky } from "react-table-sticky";
import {
TableWrapper,
TableHeaderWrapper,
Expand Down Expand Up @@ -96,6 +97,8 @@ interface TableProps {
onActionComplete: () => void,
) => void;
disabledAddNewRowSave: boolean;
handleColumnFreeze?: (columnName: string, sticky?: string) => void;
canFreezeColumn?: boolean;
}

const defaultColumn = {
Expand Down Expand Up @@ -183,6 +186,7 @@ export function Table(props: TableProps) {
useResizeColumns,
usePagination,
useRowSelect,
useSticky,
);
//Set isResizingColumn as true when column is resizing using table state
if (state.columnResizing.isResizingColumn) {
Expand Down Expand Up @@ -348,7 +352,7 @@ export function Table(props: TableProps) {
height: isHeaderVisible ? props.height - 48 : props.height,
}}
>
<div {...getTableProps()} className="table">
<div {...getTableProps()} className="table column-freeze">
<div
className="thead"
onMouseLeave={props.enableDrag}
Expand All @@ -360,7 +364,7 @@ export function Table(props: TableProps) {
style: { display: "flex" },
};
return (
<div {...headerRowProps} className="tr" key={index}>
<div {...headerRowProps} className="tr header" key={index}>
{props.multiRowSelection &&
renderHeaderCheckBoxCell(
handleAllRowSelectClick,
Expand All @@ -372,10 +376,12 @@ export function Table(props: TableProps) {
(column: any, columnIndex: number) => {
return (
<HeaderCell
canFreezeColumn={props.canFreezeColumn}
column={column}
columnIndex={columnIndex}
columnName={column.Header}
editMode={props.editMode}
handleColumnFreeze={props.handleColumnFreeze}
isAscOrder={column.isAscOrder}
isHidden={column.isHidden}
isResizingColumn={isResizingColumn.current}
Expand Down
44 changes: 24 additions & 20 deletions app/client/src/widgets/TableWidgetV2/component/TableBody/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,33 +73,37 @@ type BodyPropsType = {
const TableVirtualBodyComponent = React.forwardRef(
(props: BodyPropsType, ref: Ref<HTMLDivElement>) => {
return (
<div {...props.getTableBodyProps()} className="tbody no-scroll">
<FixedSizeList
height={
props.height -
props.tableSizes.TABLE_HEADER_HEIGHT -
props.tableSizes.COLUMN_HEADER_HEIGHT -
2 * WIDGET_PADDING // Top and bottom padding
}
itemCount={Math.max(props.rows.length, props.pageSize)}
itemData={props.rows}
itemSize={
props.tableSizes.ROW_HEIGHT + props.tableSizes.ROW_VIRTUAL_OFFSET
}
outerRef={ref}
width={`calc(100% + ${2 * WIDGET_PADDING}px`}
>
{rowRenderer}
</FixedSizeList>
</div>
<FixedSizeList
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the outer div removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This outer div is actually moved inside the innerElementType prop. Please refer to the following comment: GuillaumeJasmin/react-table-sticky#5 (comment)

className="tbody no-scroll body"
height={
props.height -
props.tableSizes.TABLE_HEADER_HEIGHT -
props.tableSizes.COLUMN_HEADER_HEIGHT -
2 * WIDGET_PADDING // Top and bottom padding
}
innerElementType={({ children, style, ...rest }: any) => (
<div {...props.getTableBodyProps()} style={style} {...rest}>
{children}
</div>
)}
itemCount={Math.max(props.rows.length, props.pageSize)}
itemData={props.rows}
itemSize={
props.tableSizes.ROW_HEIGHT + props.tableSizes.ROW_VIRTUAL_OFFSET
}
outerRef={ref}
width={`calc(100% + ${2 * WIDGET_PADDING}px`}
>
{rowRenderer}
</FixedSizeList>
);
},
);

const TableBodyComponent = React.forwardRef(
(props: BodyPropsType, ref: Ref<HTMLDivElement>) => {
return (
<div {...props.getTableBodyProps()} className="tbody" ref={ref}>
<div {...props.getTableBodyProps()} className="tbody body" ref={ref}>
{props.rows.map((row, index) => {
return <Row index={index} key={index} row={row} />;
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,17 @@ export const TableWrapper = styled.div<{
display: table;
width: 100%;
${hideScrollbar};
.thead,
.tbody {
overflow: hidden;
}
.tbody {
height: ${(props) =>
props.isHeaderVisible
? props.height - OFFSET_WITH_HEADER
: props.height - OFFSET_WITHOUT_HEADER}px;
: props.height - OFFSET_WITHOUT_HEADER}px !important;
width: 100%;
overflow-y: auto;
${hideScrollbar};
}
.tbody.no-scroll {
overflow: hidden;
overflow: visible !important;
}
.tr {
overflow: hidden;
cursor: ${(props) => props.triggerRowSelection && "pointer"};
background: ${Colors.WHITE};
&.selected-row {
Expand Down Expand Up @@ -185,6 +178,29 @@ export const TableWrapper = styled.div<{
}
}

.column-freeze {
.body {
position: relative;
z-index: 0;
}

[data-sticky-td] {
position: sticky;
position: -webkit-sticky;
background-color: inherit;
}

[data-sticky-last-left-td] {
left: 0px;
box-shadow: 2px 0px 3px #ccc;
}

[data-sticky-first-right-td] {
right: 0px;
box-shadow: -2px 0px 3px #ccc;
}
}

.tbody .tr:last-child .td {
border-bottom: none;
}
Expand Down
Loading