feat: Add toast for successful table or schema refreshes in Sqllab (#18169)

* save

* add use redux to test

* update test for db selector

* add condition for refresh only
This commit is contained in:
Hugh A. Miles II
2022-01-26 20:26:50 -05:00
committed by GitHub
parent ac564ea6b7
commit e6bb0fc7ad
4 changed files with 15 additions and 10 deletions

View File

@@ -52,7 +52,7 @@ beforeAll(() => {
test('renders with default props', async () => {
const props = createProps();
render(<TableSelector {...props} />);
render(<TableSelector {...props} />, { useRedux: true });
const databaseSelect = screen.getByRole('combobox', {
name: 'Select database or type database name',
});
@@ -71,7 +71,7 @@ test('renders with default props', async () => {
test('renders table options', async () => {
const props = createProps();
render(<TableSelector {...props} />);
render(<TableSelector {...props} />, { useRedux: true });
const tableSelect = screen.getByRole('combobox', {
name: 'Select table or type table name',
});
@@ -86,7 +86,7 @@ test('renders table options', async () => {
test('renders disabled without schema', async () => {
const props = createProps();
render(<TableSelector {...props} schema={undefined} />);
render(<TableSelector {...props} schema={undefined} />, { useRedux: true });
const tableSelect = screen.getByRole('combobox', {
name: 'Select table or type table name',
});

View File

@@ -33,6 +33,7 @@ import DatabaseSelector, {
import RefreshLabel from 'src/components/RefreshLabel';
import CertifiedBadge from 'src/components/CertifiedBadge';
import WarningIconWithTooltip from 'src/components/WarningIconWithTooltip';
import { useToasts } from 'src/components/MessageToasts/withToasts';
const TableSelectorWrapper = styled.div`
${({ theme }) => `
@@ -167,6 +168,7 @@ const TableSelector: FunctionComponent<TableSelectorProps> = ({
const [previousRefresh, setPreviousRefresh] = useState(0);
const [loadingTables, setLoadingTables] = useState(false);
const [tableOptions, setTableOptions] = useState<TableOption[]>([]);
const { addSuccessToast } = useToasts();
useEffect(() => {
// reset selections
@@ -212,6 +214,7 @@ const TableSelector: FunctionComponent<TableSelectorProps> = ({
setTableOptions(options);
setCurrentTable(currentTable);
setLoadingTables(false);
if (forceRefresh) addSuccessToast('List updated');
})
.catch(e => {
setLoadingTables(false);