forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: harmonize and clean up list views (apache#25961)
- Loading branch information
Showing
47 changed files
with
783 additions
and
665 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
superset-frontend/src/components/AuditInfo/ModifiedInfo.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from 'react'; | ||
import { render, screen, waitFor } from 'spec/helpers/testing-library'; | ||
import '@testing-library/jest-dom'; | ||
import userEvent from '@testing-library/user-event'; | ||
|
||
import { ModifiedInfo } from '.'; | ||
|
||
const TEST_DATE = '2023-11-20'; | ||
const USER = { | ||
id: 1, | ||
first_name: 'Foo', | ||
last_name: 'Bar', | ||
}; | ||
|
||
test('should render a tooltip when user is provided', async () => { | ||
render(<ModifiedInfo user={USER} date={TEST_DATE} />); | ||
|
||
const dateElement = screen.getByTestId('audit-info-date'); | ||
expect(dateElement).toBeInTheDocument(); | ||
expect(screen.getByText(TEST_DATE)).toBeInTheDocument(); | ||
expect(screen.queryByText('Modified by: Foo Bar')).not.toBeInTheDocument(); | ||
userEvent.hover(dateElement); | ||
const tooltip = await screen.findByRole('tooltip'); | ||
expect(tooltip).toBeInTheDocument(); | ||
expect(screen.getByText('Modified by: Foo Bar')).toBeInTheDocument(); | ||
}); | ||
|
||
test('should render only the date if username is not provided', async () => { | ||
render(<ModifiedInfo date={TEST_DATE} />); | ||
|
||
const dateElement = screen.getByTestId('audit-info-date'); | ||
expect(dateElement).toBeInTheDocument(); | ||
expect(screen.getByText(TEST_DATE)).toBeInTheDocument(); | ||
userEvent.hover(dateElement); | ||
await waitFor( | ||
() => { | ||
const tooltip = screen.queryByRole('tooltip'); | ||
expect(tooltip).not.toBeInTheDocument(); | ||
}, | ||
{ timeout: 1000 }, | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
|
||
import Owner from 'src/types/Owner'; | ||
import { Tooltip } from 'src/components/Tooltip'; | ||
import getOwnerName from 'src/utils/getOwnerName'; | ||
import { t } from '@superset-ui/core'; | ||
|
||
export type ModifiedInfoProps = { | ||
user?: Owner; | ||
date: string; | ||
}; | ||
|
||
export const ModifiedInfo = ({ user, date }: ModifiedInfoProps) => { | ||
const dateSpan = ( | ||
<span className="no-wrap" data-test="audit-info-date"> | ||
{date} | ||
</span> | ||
); | ||
|
||
if (user) { | ||
const userName = getOwnerName(user); | ||
const title = t('Modified by: %s', userName); | ||
return ( | ||
<Tooltip title={title} placement="bottom"> | ||
{dateSpan} | ||
</Tooltip> | ||
); | ||
} | ||
return dateSpan; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.