Skip to content

Commit

Permalink
Merge pull request #644 from systemli/fix/harmonize_buttons
Browse files Browse the repository at this point in the history
Harmonize naming of Enable/Disable and Delete buttons
  • Loading branch information
doobry-systemli authored Jun 25, 2024
2 parents 343f053 + 1033718 commit 9e003ae
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/components/ticker/BlueskyCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('BlueSkyCard', () => {
expect(screen.getByText('You are connected with Bluesky.')).toBeInTheDocument()
expect(screen.getByRole('link', { name: 'handle.bsky.social' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Configure' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Disconnect' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Delete' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Disable' })).toBeInTheDocument()

fetchMock.mockResponseOnce(JSON.stringify({ status: 'success' }))
Expand All @@ -84,7 +84,7 @@ describe('BlueSkyCard', () => {

fetchMock.mockResponseOnce(JSON.stringify({ status: 'success' }))

await userEvent.click(screen.getByRole('button', { name: 'Disconnect' }))
await userEvent.click(screen.getByRole('button', { name: 'Delete' }))

expect(fetchMock).toHaveBeenCalledTimes(2)
expect(fetchMock).toHaveBeenCalledWith('http://localhost:8080/v1/admin/tickers/1/bluesky', {
Expand Down
6 changes: 3 additions & 3 deletions src/components/ticker/BlueskyCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const BlueskyCard: FC<Props> = ({ ticker }) => {

const bluesky = ticker.bluesky

const handleDisconnect = useCallback(() => {
const handleDelete = useCallback(() => {
deleteTickerBlueskyApi(token, ticker).finally(() => {
queryClient.invalidateQueries({ queryKey: ['ticker', ticker.id] })
})
Expand Down Expand Up @@ -75,8 +75,8 @@ const BlueskyCard: FC<Props> = ({ ticker }) => {
Enable
</Button>
)}
<Button onClick={handleDisconnect} size="small" startIcon={<FontAwesomeIcon icon={faTrash} />}>
Disconnect
<Button onClick={handleDelete} size="small" startIcon={<FontAwesomeIcon icon={faTrash} />}>
Delete
</Button>
</CardActions>
) : null}
Expand Down
4 changes: 2 additions & 2 deletions src/components/ticker/MastodonCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('MastodonCard', () => {
expect(screen.getByText('Your Profile:')).toBeInTheDocument()
expect(screen.getByText('@[email protected]')).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Configure' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Disconnect' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Delete' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Disable' })).toBeInTheDocument()

fetchMock.mockResponseOnce(JSON.stringify({ status: 'success' }))
Expand All @@ -85,7 +85,7 @@ describe('MastodonCard', () => {

fetchMock.mockResponseOnce(JSON.stringify({ status: 'success' }))

screen.getByRole('button', { name: 'Disconnect' }).click()
screen.getByRole('button', { name: 'Delete' }).click()

expect(fetchMock).toHaveBeenCalledTimes(2)
expect(fetchMock).toHaveBeenCalledWith('http://localhost:8080/v1/admin/tickers/1/mastodon', {
Expand Down
8 changes: 4 additions & 4 deletions src/components/ticker/MastodonCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { faMastodon } from '@fortawesome/free-brands-svg-icons'
import { faBan, faGear, faPause, faPlay } from '@fortawesome/free-solid-svg-icons'
import { faGear, faPause, faPlay, faTrash } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { Box, Button, Card, CardActions, CardContent, Divider, Link, Stack, Typography } from '@mui/material'
import { useQueryClient } from '@tanstack/react-query'
Expand All @@ -20,7 +20,7 @@ const MastodonCard: FC<Props> = ({ ticker }) => {

const mastodon = ticker.mastodon

const handleDisconnect = useCallback(() => {
const handleDelete = useCallback(() => {
deleteTickerMastodonApi(token, ticker).finally(() => {
queryClient.invalidateQueries({ queryKey: ['ticker', ticker.id] })
})
Expand Down Expand Up @@ -79,8 +79,8 @@ const MastodonCard: FC<Props> = ({ ticker }) => {
Enable
</Button>
)}
<Button onClick={handleDisconnect} startIcon={<FontAwesomeIcon icon={faBan} />}>
Disconnect
<Button onClick={handleDelete} startIcon={<FontAwesomeIcon icon={faTrash} />}>
Delete
</Button>
</CardActions>
) : null}
Expand Down
4 changes: 2 additions & 2 deletions src/components/ticker/TelegramCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('TelegramCard', () => {
expect(screen.getByText('You are connected with Telegram.')).toBeInTheDocument()
expect(screen.getByRole('link', { name: 'channel' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Configure' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Disconnect' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Delete' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Disable' })).toBeInTheDocument()

fetchMock.mockResponseOnce(JSON.stringify({ status: 'success' }))
Expand All @@ -84,7 +84,7 @@ describe('TelegramCard', () => {

fetchMock.mockResponseOnce(JSON.stringify({ status: 'success' }))

await userEvent.click(screen.getByRole('button', { name: 'Disconnect' }))
await userEvent.click(screen.getByRole('button', { name: 'Delete' }))

expect(fetchMock).toHaveBeenCalledTimes(2)
expect(fetchMock).toHaveBeenCalledWith('http://localhost:8080/v1/admin/tickers/1/telegram', {
Expand Down
8 changes: 4 additions & 4 deletions src/components/ticker/TelegramCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { faTelegram } from '@fortawesome/free-brands-svg-icons'
import { faBan, faGear, faPause, faPlay } from '@fortawesome/free-solid-svg-icons'
import { faGear, faPause, faPlay, faTrash } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { Box, Button, Card, CardActions, CardContent, Divider, Link, Stack, Typography } from '@mui/material'
import { useQueryClient } from '@tanstack/react-query'
Expand All @@ -23,7 +23,7 @@ const TelegramCard: FC<Props> = ({ ticker }) => {
putTickerTelegramApi(token, { active: !telegram.active }, ticker).finally(() => queryClient.invalidateQueries({ queryKey: ['ticker', ticker.id] }))
}, [token, queryClient, telegram.active, ticker])

const handleDisconnect = useCallback(() => {
const handleDelete = useCallback(() => {
deleteTickerTelegramApi(token, ticker).finally(() => {
queryClient.invalidateQueries({ queryKey: ['ticker', ticker.id] })
})
Expand Down Expand Up @@ -74,8 +74,8 @@ const TelegramCard: FC<Props> = ({ ticker }) => {
Enable
</Button>
)}
<Button onClick={handleDisconnect} startIcon={<FontAwesomeIcon icon={faBan} />}>
Disconnect
<Button onClick={handleDelete} startIcon={<FontAwesomeIcon icon={faTrash} />}>
Delete
</Button>
</CardActions>
) : null}
Expand Down

0 comments on commit 9e003ae

Please sign in to comment.