Skip to content
Open
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
1 change: 1 addition & 0 deletions frontend/src/AppBuilder/WidgetManager/widgets/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ export const tableConfig = {
onFilterChanged: { displayName: 'Filter changed' },
onNewRowsAdded: { displayName: 'Add new rows' },
onTableDataDownload: { displayName: 'Download data' },
onRefresh: { displayName: 'Refresh' },
},
styles: {
columnTitleColor: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const ControlButtons = memo(
);
const clientSidePagination = useTableStore((state) => state.getTableProperties(id)?.clientSidePagination, shallow);
const hasDownloadEvent = useTableStore((state) => state.getHasDownloadEvent(id), shallow);
const { handleRefresh, isRefreshing } = useTableRefresh(id);
const { handleRefresh, isRefreshing } = useTableRefresh(id, fireEvent);

const RenderButton = ({ icon, tooltipId, tooltipContent, className, label, fill, ...restProps }) => {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { useCallback } from 'react';
import { toast } from 'react-hot-toast';
import useTableStore from '../_stores/tableStore';
import useStore from '@/AppBuilder/_stores/store';
import { useModuleContext } from '@/AppBuilder/_contexts/ModuleContext';
import { shallow } from 'zustand/shallow';

const EMPTY_ARRAY = [];

export const useTableRefresh = (id) => {
export const useTableRefresh = (id, fireEvent = () => {}) => {
const { moduleId } = useModuleContext();

const isRefreshing = useTableStore((state) => state.getIsRefreshing(id), shallow);
Expand Down Expand Up @@ -39,7 +38,9 @@ export const useTableRefresh = (id) => {
}

if (queriesToRun.length === 0) {
toast('No queries to refresh');
setIsRefreshing(id, true);
fireEvent('onRefresh');
setIsRefreshing(id, false);
Comment on lines +41 to +43
return;
}

Expand All @@ -49,9 +50,10 @@ export const useTableRefresh = (id) => {
);

Promise.allSettled(runPromises).finally(() => {
fireEvent('onRefresh');
setIsRefreshing(id, false);
});
}, [id, moduleId, isRefreshing, getDependents, dataQueries, currentMode, runQuery, setIsRefreshing]);
}, [id, moduleId, isRefreshing, getDependents, dataQueries, currentMode, runQuery, setIsRefreshing, fireEvent]);

return { handleRefresh, isRefreshing };
};
1 change: 1 addition & 0 deletions frontend/src/AppBuilder/_stores/slices/eventsSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ export const createEventsSlice = (set, get) => ({
'onSaveKeyValuePairChanges',
'onFieldValueChanged',
'onCancelKeyValuePairChanges',
'onRefresh',
].includes(eventName)
) {
executeActionsForEventId(eventName, events, mode, customVariables, moduleId);
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/_styles/table-component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -159,25 +159,28 @@
}

.footer-control-btns {
// First button
&> [data-index="0"]:not([data-last="true"]) {
.tj-tertiary-btn {
border-top-right-radius: 0 !important;
border-bottom-right-radius: 0 !important;
}
}

// Last button
&> [data-last="true"]:not([data-index="0"]) {
.tj-tertiary-btn {
border-top-left-radius: 0 !important;
border-bottom-left-radius: 0 !important;
border-left: none !important;
}
}

// Middle buttons
&> [data-last="false"]:not([data-index="0"]) {
.tj-tertiary-btn {
border-radius: 0 !important;
border-left: none !important;
border-right: none !important;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions server/src/modules/apps/services/widget-config/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ export const tableConfig = {
onFilterChanged: { displayName: 'Filter changed' },
onNewRowsAdded: { displayName: 'Add new rows' },
onTableDataDownload: { displayName: 'Download data' },
onRefresh: { displayName: 'Refresh' },
},
styles: {
columnTitleColor: {
Expand Down
Loading