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

fix: metadata arrow action #6300

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -32,10 +32,9 @@ class GroupbyItem extends Component {
};

renderTipMessage = () => {
const { column } = this.props;
const { column, view } = this.props;
const { tooltipOpen } = this.state;
const page = window.app.getPage();
const { shown_column_keys } = page || {};
const { shown_column_keys } = view || {};

if (!shown_column_keys || !Array.isArray(shown_column_keys) || shown_column_keys.includes(column.key)) {
return null;
Expand Down Expand Up @@ -110,6 +109,7 @@ class GroupbyItem extends Component {
GroupbyItem.propTypes = {
index: PropTypes.number,
column: PropTypes.object,
view: PropTypes.object,
groupby: PropTypes.object,
columnsOptions: PropTypes.array,
geoCountTypeOptions: PropTypes.array,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,8 @@ const Container = () => {
return recordGetter(recordIndex);
}, [groupRecordGetter, recordGetter]);

const getTableContentWidth = useCallback(() => {
return containerRef?.current?.offsetWidth || 0;
}, [containerRef]);

const getTableContentLeft = useCallback(() => {
return containerRef?.current?.getBoundingClientRect()?.left || 0;
const getTableContentRect = useCallback(() => {
return containerRef?.current?.getBoundingClientRect() || { x: 0, right: window.innerWidth };
}, [containerRef]);

useEffect(() => {
Expand Down Expand Up @@ -182,8 +178,7 @@ const Container = () => {
modifyRecords={modifyRecords}
recordGetterById={recordGetterById}
recordGetterByIndex={recordGetterByIndex}
getTableContentWidth={getTableContentWidth}
getTableContentLeft={getTableContentLeft}
getTableContentRect={getTableContentRect}
getAdjacentRowsIds={getAdjacentRowsIds}
loadAll={loadAll}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@
width: 16px;
margin-left: 0;
transform: translateY(0px);
flex-shrink: 0;
}

.sf-metadata-result-table-cell .select-all-checkbox-container .sf-metadata-icon-partially-selected {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class GroupContainerRight extends Component {
isExpanded={isExpanded}
columns={columns}
summaryConfigs={summaryConfigs}
getTableContentLeft={this.props.getTableContentLeft}
getTableContentRect={this.props.getTableContentRect}
/>
</div>
);
Expand All @@ -50,7 +50,7 @@ GroupContainerRight.propTypes = {
height: PropTypes.number,
groupOffsetLeft: PropTypes.number,
lastFrozenColumnKey: PropTypes.string,
getTableContentLeft: PropTypes.func,
getTableContentRect: PropTypes.func,
};

export default GroupContainerRight;
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class GroupContainer extends Component {

fixedFrozenDOMs = (scrollLeft, scrollTop) => {
if (this.backDrop) {
const tableContentLeft = this.props.getTableContentLeft();
const tableContentLeft = this.props.getTableContentRect();
this.backDrop.style.position = 'fixed';
this.backDrop.style.marginLeft = tableContentLeft + 'px';
this.backDrop.style.marginTop = (-scrollTop) + 'px';
Expand Down Expand Up @@ -134,7 +134,7 @@ class GroupContainer extends Component {
lastFrozenColumnKey={lastFrozenColumnKey}
columns={columns}
summaryConfigs={summaryConfigs}
getTableContentLeft={this.props.getTableContentLeft}
getTableContentRect={this.props.getTableContentRect}
/>
</div>
);
Expand All @@ -158,7 +158,7 @@ GroupContainer.propTypes = {
scrollLeft: PropTypes.number,
maxLevel: PropTypes.number,
summaryConfigs: PropTypes.object,
getTableContentLeft: PropTypes.func,
getTableContentRect: PropTypes.func,
onExpandGroupToggle: PropTypes.func,
updateSummaryConfig: PropTypes.func,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class GroupHeaderCell extends React.PureComponent {
fixedFrozenDOMs = (scrollLeft, scrollTop) => {
if (this.headerCell) {
const { firstColumnWidth, groupOffsetLeft } = this.props;
const tableContentLeft = this.props.getTableContentLeft();
const tableContentLeft = this.props.getTableContentRect();
this.headerCell.style.position = 'fixed';
this.headerCell.style.marginLeft = (SEQUENCE_COLUMN_WIDTH + firstColumnWidth + groupOffsetLeft + tableContentLeft) + 'px';
this.headerCell.style.marginTop = (-scrollTop) + 'px';
Expand Down Expand Up @@ -64,7 +64,7 @@ GroupHeaderCell.propTypes = {
groupOffsetLeft: PropTypes.number,
summary: PropTypes.object,
summaryMethod: PropTypes.string,
getTableContentLeft: PropTypes.func,
getTableContentRect: PropTypes.func,
};

export default GroupHeaderCell;
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class GroupHeaderRight extends Component {
isExpanded={isExpanded}
summary={summary}
summaryMethod={summaryMethod}
getTableContentLeft={this.props.getTableContentLeft}
getTableContentRect={this.props.getTableContentRect}
/>
);
});
Expand All @@ -79,7 +79,7 @@ GroupHeaderRight.propTypes = {
lastFrozenColumnKey: PropTypes.string,
columns: PropTypes.array,
summaryConfigs: PropTypes.object,
getTableContentLeft: PropTypes.func,
getTableContentRect: PropTypes.func,
};

export default GroupHeaderRight;
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ class GroupTitle extends Component {
this.collaborators = window.sfMetadataContext.getCollaboratorsFromCache();
}

getOptionColors = () => {
const { dtableUtils } = window.app;
return dtableUtils.getOptionColors();
};

renderCollaborator = (collaborator) => {
const { email, avatar_url, name } = collaborator || {};
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class Records extends Component {
this.lastScrollLeft = this.scrollLeft;
this.initPosition = { idx: -1, rowIdx: -1, groupRecordIndex: -1 };
const columnMetrics = this.createColumnMetrics(props);
const initHorizontalScrollState = this.getHorizontalScrollState({ gridWidth: props.tableContentWidth, columnMetrics, scrollLeft: 0 });
const { width: tableContentWidth } = props.getTableContentRect();
const initHorizontalScrollState = this.getHorizontalScrollState({ gridWidth: tableContentWidth, columnMetrics, scrollLeft: 0 });
this.state = {
columnMetrics,
recordMetrics: this.createRowMetrics(),
Expand All @@ -45,7 +46,6 @@ class Records extends Component {
}

componentDidMount() {
window.addEventListener('popstate', this.onPopState);
document.addEventListener('copy', this.onCopyCells);
document.addEventListener('paste', this.onPasteCells);
if (window.isMobile) {
Expand All @@ -56,11 +56,11 @@ class Records extends Component {
}
this.unsubscribeSelectNone = window.sfMetadataContext.eventBus.subscribe(EVENT_BUS_TYPE.SELECT_NONE, this.selectNone);
this.getScrollPosition();
this.checkExpandRow();
}

UNSAFE_componentWillReceiveProps(nextProps) {
const { columns, tableContentWidth } = nextProps;
const { columns, getTableContentRect } = nextProps;
const { width: tableContentWidth } = getTableContentRect();
if (
this.props.columns !== columns
) {
Expand All @@ -71,7 +71,7 @@ class Records extends Component {
gridWidth: tableContentWidth,
});
this.setState({ columnMetrics });
} else if (this.props.tableContentWidth !== tableContentWidth) {
} else if (this.props.getTableContentRect()?.width !== tableContentWidth) {
this.updateHorizontalScrollState({
columnMetrics: this.state.columnMetrics,
scrollLeft: this.lastScrollLeft,
Expand All @@ -82,7 +82,6 @@ class Records extends Component {
}

componentWillUnmount() {
window.removeEventListener('popstate', this.onPopState);
document.removeEventListener('copy', this.onCopyCells);
document.removeEventListener('paste', this.onPasteCells);
if (window.isMobile) {
Expand Down Expand Up @@ -143,10 +142,6 @@ class Records extends Component {
}
};

checkExpandRow = async () => {
// todo
};

storeScrollPosition = () => {
const scrollTop = this.bodyRef.getScrollTop();
const scrollLeft = this.getScrollLeft();
Expand Down Expand Up @@ -177,11 +172,12 @@ class Records extends Component {
};

handleHorizontalScroll = (scrollLeft, scrollTop) => {
const { width: tableContentWidth } = this.props.getTableContentRect();
if (isMobile) {
this.updateHorizontalScrollState({
scrollLeft,
columnMetrics: this.state.columnMetrics,
gridWidth: this.props.tableContentWidth,
gridWidth: tableContentWidth,
});
return;
}
Expand Down Expand Up @@ -213,7 +209,7 @@ class Records extends Component {
this.updateHorizontalScrollState({
scrollLeft,
columnMetrics: this.state.columnMetrics,
gridWidth: this.props.tableContentWidth,
gridWidth: tableContentWidth,
});
};

Expand Down Expand Up @@ -359,10 +355,6 @@ class Records extends Component {
this.updateSelectedRange(selectedRange);
};

onPopState = () => {
this.checkExpandRow();
};

onCopyCells = (e) => {
window.sfMetadataContext.eventBus.dispatch(EVENT_BUS_TYPE.COPY_CELLS, e);
};
Expand Down Expand Up @@ -753,7 +745,7 @@ Records.propTypes = {
groups: PropTypes.array,
groupbys: PropTypes.array,
searchResult: PropTypes.object,
tableContentWidth: PropTypes.number,
getTableContentRect: PropTypes.func,
scrollToLoadMore: PropTypes.func,
updateRecord: PropTypes.func,
updateRecords: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class RecordsBody extends Component {
};

setColumnVisibleEnd = () => {
const { columns, getScrollLeft, tableContentWidth } = this.props;
const { columns, getScrollLeft, getTableContentRect } = this.props;
const { width: tableContentWidth } = getTableContentRect();
let columnVisibleEnd = 0;
const contentScrollLeft = getScrollLeft();
let endColumnWidth = tableContentWidth + contentScrollLeft;
Expand Down Expand Up @@ -135,7 +136,8 @@ class RecordsBody extends Component {
};

scrollToColumn = (idx) => {
const { columns, tableContentWidth } = this.props;
const { columns, getTableContentRect } = this.props;
const { width: tableContentWidth } = getTableContentRect();
const newScrollLeft = getColumnScrollPosition(columns, idx, tableContentWidth);
if (newScrollLeft !== null) {
this.props.setRecordsScrollLeft(newScrollLeft);
Expand Down Expand Up @@ -550,7 +552,7 @@ class RecordsBody extends Component {
getRowTop={this.getRowTop}
scrollTop={this.oldScrollTop}
getScrollLeft={this.props.getScrollLeft}
getTableContentLeft={this.props.getTableContentLeft}
getTableContentRect={this.props.getTableContentRect}
getMobileFloatIconStyle={this.props.getMobileFloatIconStyle}
onToggleMobileMoreOperations={this.props.onToggleMobileMoreOperations}
editorPortalTarget={this.props.editorPortalTarget}
Expand Down Expand Up @@ -606,7 +608,7 @@ RecordsBody.propTypes = {
hasSelectedCell: PropTypes.func,
cacheScrollTop: PropTypes.func,
scrollToLoadMore: PropTypes.func,
getTableContentLeft: PropTypes.func,
getTableContentRect: PropTypes.func,
getMobileFloatIconStyle: PropTypes.func,
onToggleMobileMoreOperations: PropTypes.func,
onToggleInsertRecordDialog: PropTypes.func,
Expand All @@ -628,7 +630,6 @@ RecordsBody.propTypes = {
paste: PropTypes.func,
searchResult: PropTypes.object,
scrollToRowIndex: PropTypes.number,
tableContentWidth: PropTypes.number,
frozenColumnsWidth: PropTypes.number,
editMobileCell: PropTypes.func,
insertRecords: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ class RecordsGroupBody extends Component {
};

setColumnVisibleEnd = () => {
const { columns, getScrollLeft, tableContentWidth } = this.props;
const { columns, getScrollLeft, getTableContentRect } = this.props;
const { width: tableContentWidth } = getTableContentRect();
let columnVisibleEnd = 0;
const contentScrollLeft = getScrollLeft();
let endColumnWidth = tableContentWidth + contentScrollLeft;
Expand Down Expand Up @@ -208,7 +209,8 @@ class RecordsGroupBody extends Component {
};

scrollToColumn = (idx) => {
const { columns, tableContentWidth } = this.props;
const { columns, getTableContentRect } = this.props;
const { width: tableContentWidth } = getTableContentRect();
const newScrollLeft = getColumnScrollPosition(columns, idx, tableContentWidth);
if (newScrollLeft !== null) {
this.props.setRecordsScrollLeft(newScrollLeft);
Expand Down Expand Up @@ -822,13 +824,12 @@ class RecordsGroupBody extends Component {
maxLevel={maxLevel}
groupOffsetLeft={groupOffsetLeft}
scrollLeft={scrollLeft}
leftBarWidth={0}
columns={columns}
summaryConfigs={summaryConfigs}
isExpanded={isExpanded}
folding={folding}
lastFrozenColumnKey={lastFrozenColumnKey}
getTableContentLeft={this.props.getTableContentLeft}
getTableContentRect={this.props.getTableContentRect}
onExpandGroupToggle={this.onExpandGroupToggle}
/>
);
Expand Down Expand Up @@ -923,7 +924,7 @@ class RecordsGroupBody extends Component {
scrollTop={this.oldScrollTop}
getRowTop={this.getRowTop}
getScrollLeft={this.props.getScrollLeft}
getTableContentLeft={this.props.getTableContentLeft}
getTableContentRect={this.props.getTableContentRect}
getMobileFloatIconStyle={this.props.getMobileFloatIconStyle}
onToggleMobileMoreOperations={this.props.onToggleMobileMoreOperations}
onToggleInsertRecordDialog={this.props.onToggleInsertRecordDialog}
Expand Down Expand Up @@ -983,7 +984,6 @@ RecordsGroupBody.propTypes = {
columns: PropTypes.array,
colOverScanStartIdx: PropTypes.number,
colOverScanEndIdx: PropTypes.number,
tableContentWidth: PropTypes.number,
totalWidth: PropTypes.number,
containerWidth: PropTypes.number,
groups: PropTypes.array,
Expand All @@ -1003,7 +1003,7 @@ RecordsGroupBody.propTypes = {
hasSelectedCell: PropTypes.func,
cacheScrollTop: PropTypes.func,
scrollToLoadMore: PropTypes.func,
getTableContentLeft: PropTypes.func,
getTableContentRect: PropTypes.func,
getMobileFloatIconStyle: PropTypes.func,
onToggleMobileMoreOperations: PropTypes.func,
onToggleInsertRecordDialog: PropTypes.func,
Expand Down
Loading
Loading