From 95cd2445f5afd4ae80f1ddf8050329e7e499d857 Mon Sep 17 00:00:00 2001 From: MahtabBukhari Date: Wed, 9 Oct 2024 16:46:34 +0500 Subject: [PATCH 1/2] fix(persist-header): source table header should be persist --- .../SourcesView/Topics/Table/index.tsx | 259 +++++++++--------- .../SourcesView/Topics/index.tsx | 35 +-- .../SourcesTableModal/SourcesView/types.ts | 1 + 3 files changed, 144 insertions(+), 151 deletions(-) diff --git a/src/components/SourcesTableModal/SourcesView/Topics/Table/index.tsx b/src/components/SourcesTableModal/SourcesView/Topics/Table/index.tsx index 6e797046e..14c748b14 100644 --- a/src/components/SourcesTableModal/SourcesView/Topics/Table/index.tsx +++ b/src/components/SourcesTableModal/SourcesView/Topics/Table/index.tsx @@ -30,13 +30,14 @@ interface CheckboxIconProps { export const Table: React.FC = ({ setShowMuteUnmute, showMuted, + loading, onTopicEdit, onChangeFilter, checkedStates, setCheckedStates, }) => { const { close } = useModal('sourcesTable') - const [loading, setLoading] = useState(false) + const [muteLoading, setMuteLoading] = useState(false) const [anchorEl, setAnchorEl] = React.useState(null) const [selectedRefId, setSelectedRefId] = React.useState('') @@ -74,7 +75,7 @@ export const Table: React.FC = ({ const id = open ? 'simple-popover' : undefined const handleSelectedMuteUnmute = async () => { - setLoading(true) + setMuteLoading(true) try { const promises = Object.keys(checkedStates).map(async (checkedId) => { @@ -105,153 +106,149 @@ export const Table: React.FC = ({ setCheckedStates({}) - setLoading(false) + setMuteLoading(false) } catch (error) { console.error('Error:', error) - setLoading(false) + setMuteLoading(false) } } - return !data ? ( + return !loading && !data ? ( There is not any results for selected filters ) : ( <> - {!Object.keys(data).length ? ( + {data && !Object.keys(data).length ? ( There is not any results for selected filters ) : ( - - {loading ? ( - - ) : ( - <> - - {checkedCount > 0 ? ( - - - - setCheckedStates({})}> - - - - - - - {checkedCount} - selected - - - - - {showMuted ? ( - <> - Unmute ALL - - ) : ( - <> - Mute ALL - - )} - - - handlePopoverAction('mergeTopic')}> - Merge - - - + + + {checkedCount > 0 ? ( + + + + setCheckedStates({})}> + + + + + + + {checkedCount} + selected + - - - ) : ( - - + + + {showMuted ? ( + <> + Unmute ALL + + ) : ( + <> + Mute ALL + + )} + - - handleChange(ALPHABETICALLY)}> - Name - - - Type - - handleChange(EDGE_COUNT)}> - Count - - - Edge list - - handleChange(DATE)}> - Date - - - - - - - {showMuted && } - - Muted - - - - - - )} - - {data && ( - - {ids?.map((i: string) => ( - isChecked).length > 1} - onClick={handleClick} - onSearch={handleSearch} - setCheckedStates={setCheckedStates} - topic={data[i]} - /> - ))} - - )} - - {selectedRefId ? ( - - {showMuted ? ( - handlePopoverAction('unMute')}> - {' '} - Unmute - - ) : ( - handlePopoverAction('mute')}> - {' '} - Mute - - )} - handlePopoverAction('editTopic')}> - Rename - - - handlePopoverAction('mergeTopic')}> - Merge - - handlePopoverAction('addEdge')}> - Add edge - - - ) : null} - - )} + handlePopoverAction('mergeTopic')}> + Merge + + + + + + + ) : ( + + + + + handleChange(ALPHABETICALLY)}> + Name + + + Type + + handleChange(EDGE_COUNT)}> + Count + + + Edge list + + handleChange(DATE)}> + Date + + + + + + + {showMuted && } + + Muted + + + + + + )} + + {(loading || muteLoading) && !data && } + + {data && ( + + {ids?.map((i: string) => ( + isChecked).length > 1} + onClick={handleClick} + onSearch={handleSearch} + setCheckedStates={setCheckedStates} + topic={data[i]} + /> + ))} + + )} + + {selectedRefId ? ( + + {showMuted ? ( + handlePopoverAction('unMute')}> + {' '} + Unmute + + ) : ( + handlePopoverAction('mute')}> + {' '} + Mute + + )} + handlePopoverAction('editTopic')}> + Rename + + + handlePopoverAction('mergeTopic')}> + Merge + + handlePopoverAction('addEdge')}> + Add edge + + + ) : null} )} diff --git a/src/components/SourcesTableModal/SourcesView/Topics/index.tsx b/src/components/SourcesTableModal/SourcesView/Topics/index.tsx index 530edcd5d..be34b9eed 100644 --- a/src/components/SourcesTableModal/SourcesView/Topics/index.tsx +++ b/src/components/SourcesTableModal/SourcesView/Topics/index.tsx @@ -146,26 +146,21 @@ export const TopicSources = () => { - {loading && !data ? ( - - ) : ( - <> - setFilters({ is_muted: !filters.is_muted })} - showMuted={filters.is_muted} - /> - {total > ids.length ? ( - - ) : null} - - )} +
setFilters({ is_muted: !filters.is_muted })} + showMuted={filters.is_muted} + /> + {total > ids.length ? ( + + ) : null} diff --git a/src/components/SourcesTableModal/SourcesView/types.ts b/src/components/SourcesTableModal/SourcesView/types.ts index 11c10fca4..8977299ba 100644 --- a/src/components/SourcesTableModal/SourcesView/types.ts +++ b/src/components/SourcesTableModal/SourcesView/types.ts @@ -7,6 +7,7 @@ export type Props = { export type TopicTableProps = { showMuted?: boolean + loading: boolean onTopicEdit: (id: string, action: string) => void onChangeFilter: (val: string) => void setShowMuteUnmute: () => void From 16e0160ce966e770dcdb0e282a70ed637fa5f8c9 Mon Sep 17 00:00:00 2001 From: MahtabBukhari Date: Wed, 9 Oct 2024 17:47:52 +0500 Subject: [PATCH 2/2] fix(persist-header): source table header should persist --- .../SourcesView/Topics/Table/index.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/components/SourcesTableModal/SourcesView/Topics/Table/index.tsx b/src/components/SourcesTableModal/SourcesView/Topics/Table/index.tsx index 14c748b14..2e09c4ea4 100644 --- a/src/components/SourcesTableModal/SourcesView/Topics/Table/index.tsx +++ b/src/components/SourcesTableModal/SourcesView/Topics/Table/index.tsx @@ -199,7 +199,11 @@ export const Table: React.FC = ({ )} - {(loading || muteLoading) && !data && } + {(loading || muteLoading) && !data && ( + + + + )} {data && ( @@ -365,3 +369,14 @@ const TableInnerWrapper = styled(Flex)` width: 100%; position: relative; ` + +const ClipLoaderWrapper = styled.div` + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + z-index: 10; + display: flex; + align-items: center; + justify-content: center; +`