buildTable()

in source/idea/idea-cluster-manager/webapp/src/components/list-view/list-view.tsx [507:662]


    buildTable() {
        return (
            <IdeaTable
                ref={this.table}
                header={
                    <Header variant={this.props.titleVariant || "awsui-h1-sticky"} counter={this.getCounter() || this.props.counter} description={this.props.description} actions={this.buildActions()}>
                        {this.props.title}
                    </Header>
                }
                variant={this.props.variant}
                stickyHeader={this.props.stickyHeader}
                loading={this.state.loading}
                listing={this.state.listing}
                empty={this.props.empty}
                selectedItems={this.props.selectedItems}
                selectionType={this.props.selectionType}
                showFilters={this.props.showFilters}
                filterType={this.props.filterType}
                filters={this.props.filters}
                filteringPlaceholder={this.props.filteringPlaceholder}
                defaultFilteringText={this.props.defaultFilteringText}
                selectFilters={this.props.selectFilters}
                filteringProperties={this.props.filteringProperties}
                filteringOptions={this.props.filteringOptions}
                onFilter={(filters) => {
                    let applicableFilters;
                    if (this.props.onFilter) {
                        applicableFilters = this.props.onFilter(filters);
                    } else {
                        applicableFilters = filters;
                    }
                    this.setState(
                        {
                            listing: [],
                            selectedItems: [],
                            currentPage: 1,
                            totalPages: 1,
                            listingRequest: {
                                ...this.state.listingRequest,
                                filters: applicableFilters,
                            },
                        },
                        () => {
                            this.fetchRecords();
                        }
                    );
                }}
                onPropertyFilterChange={(query) => {
                    if (this.props.onFilterPropertyChange) {
                        const request = this.props.onFilterPropertyChange(query);
                        this.setState(
                            {
                                listing: [],
                                listingRequest: request,
                                selectedItems: [],
                                currentPage: 1,
                                totalPages: 1,
                            },
                            () => {
                                this.fetchRecords();
                            }
                        );
                    }
                }}
                showPreferences={this.props.showPreferences}
                preferencesKey={this.props.preferencesKey}
                onPreferenceChange={(detail) => {
                    let shouldReload = detail.pageSize !== this.state?.listingRequest?.paginator?.page_size;
                    this.setState(
                        {
                            listingRequest: {
                                ...this.state.listingRequest,
                                paginator: {
                                    ...this.state.listingRequest.paginator,
                                    page_size: detail.pageSize,
                                },
                            },
                        },
                        () => {
                            if (this.props.onPreferenceChange) {
                                this.props.onPreferenceChange(detail);
                            }

                            if (shouldReload) {
                                this.fetchRecords();
                            }
                        }
                    );
                }}
                onSelectionChange={(event) => {
                    this.setState(
                        {
                            selectedItems: event.detail.selectedItems,
                        },
                        () => {
                            if (this.props.onSelectionChange) {
                                this.props.onSelectionChange(event);
                            }
                        }
                    );
                }}
                columnDefinitions={this.props.columnDefinitions}
                showPaginator={this.props.showPaginator}
                currentPage={this.state.currentPage}
                totalPages={this.getTotalPages()}
                openEndPaging={this.hasMorePages()}
                onPage={(page, type) => {
                    let totalPages = this.state.totalPages;
                    if (this.isOpenEndedPaging()) {
                        if (type === "next" && this.hasMorePages()) {
                            totalPages = page;
                        }
                    }

                    this.setState(
                        {
                            currentPage: page,
                            totalPages: totalPages,
                        },
                        () => {
                            if (this.props.onPage) {
                                const paginator = this.props.onPage(page, type);
                                this.setState(
                                    {
                                        listingRequest: {
                                            ...this.state.listingRequest,
                                            paginator: paginator,
                                        },
                                    },
                                    () => {
                                        this.fetchRecords();
                                    }
                                );
                            } else {
                                const paginator = this.getPaginator();
                                this.setState(
                                    {
                                        listingRequest: {
                                            ...this.state.listingRequest,
                                            paginator: {
                                                ...paginator,
                                                start: (page - 1) * paginator.page_size!,
                                            },
                                        },
                                    },
                                    () => {
                                        this.fetchRecords();
                                    }
                                );
                            }
                        }
                    );
                }}
            />
        );
    }