Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ describe('Item Component', () => {
)

const enterRenameMode = () => {
const firstButton = result.container.querySelectorAll('button')[0] as HTMLElement
fireEvent.click(firstButton)
fireEvent.click(screen.getByRole('button', { name: 'common.operation.rename' }))
}

return { ...result, onRename, enterRenameMode }
Expand Down Expand Up @@ -337,7 +336,7 @@ describe('Item Component', () => {
credentials: { api_key: 'secret' },
})

const { container } = render(
render(
<Item
credential={credential}
onEdit={onEdit}
Expand All @@ -348,10 +347,7 @@ describe('Item Component', () => {
/>,
)

const editButton = container
.querySelector('.i-ri-equalizer-2-line')
?.closest('button') as HTMLElement
fireEvent.click(editButton)
fireEvent.click(screen.getByRole('button', { name: 'common.operation.edit' }))
expect(onEdit).toHaveBeenCalledWith('edit-test-id', {
api_key: 'secret',
__name__: 'Edit Test',
Expand Down Expand Up @@ -403,7 +399,7 @@ describe('Item Component', () => {
const onDelete = vi.fn()
const credential = createCredential({ id: 'delete-test-id' })

const { container } = render(
render(
<Item
credential={credential}
onDelete={onDelete}
Expand All @@ -414,10 +410,7 @@ describe('Item Component', () => {
/>,
)

const deleteButton = container
.querySelector('.i-ri-delete-bin-line')
?.closest('button') as HTMLElement
fireEvent.click(deleteButton)
fireEvent.click(screen.getByRole('button', { name: 'common.operation.delete' }))
expect(onDelete).toHaveBeenCalledWith('delete-test-id')
})

Expand Down Expand Up @@ -521,7 +514,7 @@ describe('Item Component', () => {
const onDelete = vi.fn()
const credential = createCredential()

const { container } = render(
render(
<Item
credential={credential}
onItemClick={onItemClick}
Expand All @@ -533,10 +526,7 @@ describe('Item Component', () => {
/>,
)

const deleteButton = container
.querySelector('.i-ri-delete-bin-line')
?.closest('button') as HTMLElement
fireEvent.click(deleteButton)
fireEvent.click(screen.getByRole('button', { name: 'common.operation.delete' }))
expect(onDelete).toHaveBeenCalled()
})
})
Expand Down
15 changes: 12 additions & 3 deletions web/app/components/plugins/plugin-auth/authorized/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,15 @@ const Item = ({
<TooltipTrigger
render={
<ActionButton
aria-label={t(($) => $['operation.rename'], { ns: 'common' })}
disabled={disabled || !canManageCredential}
onClick={(e) => {
e.stopPropagation()
setRenaming(true)
setRenameValue(credential.name)
}}
>
<span className="i-ri-edit-line size-4 text-text-tertiary" />
<span aria-hidden className="i-ri-edit-line size-4 text-text-tertiary" />
</ActionButton>
}
/>
Expand All @@ -200,6 +201,7 @@ const Item = ({
<TooltipTrigger
render={
<ActionButton
aria-label={t(($) => $['operation.edit'], { ns: 'common' })}
disabled={disabled || !canManageCredential}
onClick={(e) => {
e.stopPropagation()
Expand All @@ -210,7 +212,10 @@ const Item = ({
})
}}
>
<span className="i-ri-equalizer-2-line size-4 text-text-tertiary" />
<span
aria-hidden
className="i-ri-equalizer-2-line size-4 text-text-tertiary"
/>
</ActionButton>
}
/>
Expand All @@ -222,14 +227,18 @@ const Item = ({
<TooltipTrigger
render={
<ActionButton
aria-label={t(($) => $['operation.delete'], { ns: 'common' })}
className="hover:bg-transparent"
disabled={disabled || !canManageCredential}
onClick={(e) => {
e.stopPropagation()
onDelete?.(credential.id)
}}
>
<span className="i-ri-delete-bin-line size-4 text-text-tertiary hover:text-text-destructive" />
<span
aria-hidden
className="i-ri-delete-bin-line size-4 text-text-tertiary hover:text-text-destructive"
/>
</ActionButton>
}
/>
Expand Down