diff --git a/src/components/SourcesTableModal/SourcesView/Sources/Table/__tests__/test.tsx b/src/components/SourcesTableModal/SourcesView/Sources/Table/__tests__/test.tsx index 3ce731245..0b1c7d0a1 100644 --- a/src/components/SourcesTableModal/SourcesView/Sources/Table/__tests__/test.tsx +++ b/src/components/SourcesTableModal/SourcesView/Sources/Table/__tests__/test.tsx @@ -1,4 +1,4 @@ -import { render, screen, within } from '@testing-library/react' +import { render, screen, within, fireEvent } from '@testing-library/react' import React from 'react' import { TWITTER_LINK, sourcesMapper } from '~/components/SourcesTableModal/SourcesView/constants' import { RSS, TWITTER_HANDLE, YOUTUBE_CHANNEL } from '~/constants' @@ -55,4 +55,40 @@ describe('Table Component Tests', () => { expect(sourceTypeCell).toBeInTheDocument() expect(sourceCell).toBeInTheDocument() }) + + it('should display loader when clicking on delete icon', async () => { + const isEdit = true + + render() + + const deleteIcon = screen.getByTestId('delete-icon-2') + + fireEvent.click(deleteIcon) + + const confirmDelete = await screen.findByText('Yes') + + fireEvent.click(confirmDelete) + + const loader = await screen.findByTestId('delete-loader-2') + + expect(loader).toBeInTheDocument() + }) + + it('should display loader when clicking on edit icon and then check icon', async () => { + const isEdit = true + + render(
) + + const editIcon = screen.getByTestId('edit-icon-1') + + fireEvent.click(editIcon) + + const checkIcon = screen.getByTestId('check-icon-1') + + fireEvent.click(checkIcon) + + const loader = await screen.findByTestId('edit-loader-1') + + expect(loader).toBeInTheDocument() + }) }) diff --git a/src/components/SourcesTableModal/SourcesView/Sources/Table/index.tsx b/src/components/SourcesTableModal/SourcesView/Sources/Table/index.tsx index a9b513d92..447beac2c 100644 --- a/src/components/SourcesTableModal/SourcesView/Sources/Table/index.tsx +++ b/src/components/SourcesTableModal/SourcesView/Sources/Table/index.tsx @@ -1,6 +1,6 @@ import { Table as MaterialTable, TableBody, TableRow } from '@mui/material' import React, { useState } from 'react' -import { MdCheck, MdClose, MdDeleteForever, MdOutlineModeEdit } from 'react-icons/md' +import { MdCheck, MdClose, MdOutlineModeEdit } from 'react-icons/md' import { ClipLoader } from 'react-spinners' import styled from 'styled-components' import { BaseTextInput } from '~/components/BaseTextInput' @@ -15,6 +15,7 @@ import { RadarRequest, Sources } from '~/types' import { colors } from '~/utils/colors' import { StyledTableCell, StyledTableHead, StyledTableRow } from '../../common' import { TWITTER_LINK, sourcesMapper } from '../../constants' +import DeleteIcon from '~/components/Icons/DeleteIcon' type Props = { data: Sources[] | undefined @@ -121,11 +122,17 @@ const Table: React.FC = ({ data, canEdit = false }) => {
{loadingId === i.ref_id ? ( - + + + ) : ( - handleRemove(i.ref_id)}> - - + handleRemove(i.ref_id)} + > + + )} @@ -180,7 +187,7 @@ const EditableCell: React.FC = ({ value, onSave, id, children return (
{editing ? ( - + = ({ value, onSave, id, children value={name} /> - {loading ? : } + {loading ? ( + + + + ) : ( + + )} setEditing(false)}> @@ -198,7 +211,7 @@ const EditableCell: React.FC = ({ value, onSave, id, children {children} setEditing(true)}> - + )} @@ -231,7 +244,8 @@ const IconWrapper = styled(Flex)` border-radius: 50%; cursor: pointer; background: transparent; - color: ${colors.lightBlue500}; + align-items: center; + justify-content: center; &.centered { margin: 0 auto; } @@ -239,6 +253,10 @@ const IconWrapper = styled(Flex)` & + & { margin-left: 4px; } + + &:hover { + background: rgba(255, 255, 255, 0.1); + } ` const NoResultWrapper = styled(Flex)` @@ -283,3 +301,9 @@ const StyledLink = styled.a` color: ${colors.white}; } ` + +const ClipLoaderWrapper = styled(Flex)` + display: flex; + justify-content: center; + align-items: center; +`