Skip to content

Commit

Permalink
chore: Extract common select component code (#21094)
Browse files Browse the repository at this point in the history
  • Loading branch information
cccs-RyanK committed Sep 15, 2022
1 parent 2c7323a commit 4fcc1d9
Show file tree
Hide file tree
Showing 9 changed files with 608 additions and 668 deletions.
385 changes: 92 additions & 293 deletions superset-frontend/src/components/Select/AsyncSelect.tsx

Large diffs are not rendered by default.

17 changes: 7 additions & 10 deletions superset-frontend/src/components/Select/Select.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,10 @@ import React, {
} from 'react';
import Button from 'src/components/Button';
import ControlHeader from 'src/explore/components/ControlHeader';
import AsyncSelect, {
AsyncSelectProps,
AsyncSelectRef,
OptionsTypePage,
} from './AsyncSelect';
import AsyncSelect, { AsyncSelectProps, AsyncSelectRef } from './AsyncSelect';
import { SelectOptionsType, SelectOptionsTypePage } from './utils';

import Select, { SelectProps, OptionsType } from './Select';
import Select, { SelectProps } from './Select';

export default {
title: 'Select',
Expand All @@ -40,7 +37,7 @@ export default {

const DEFAULT_WIDTH = 200;

const options: OptionsType = [
const options: SelectOptionsType = [
{
label: 'Such an incredibly awesome long long label',
value: 'Such an incredibly awesome long long label',
Expand Down Expand Up @@ -160,7 +157,7 @@ const mountHeader = (type: String) => {
return header;
};

const generateOptions = (opts: OptionsType, count: number) => {
const generateOptions = (opts: SelectOptionsType, count: number) => {
let generated = opts.slice();
let iteration = 0;
while (generated.length < count) {
Expand Down Expand Up @@ -440,7 +437,7 @@ export const AsynchronousSelect = ({
search: string,
page: number,
pageSize: number,
): Promise<OptionsTypePage> => {
): Promise<SelectOptionsTypePage> => {
const username = search.trim().toLowerCase();
return new Promise(resolve => {
let results = getResults(username);
Expand All @@ -458,7 +455,7 @@ export const AsynchronousSelect = ({
[responseTime],
);

const fetchUserListError = async (): Promise<OptionsTypePage> =>
const fetchUserListError = async (): Promise<SelectOptionsTypePage> =>
new Promise((_, reject) => {
reject(new Error('Error while fetching the names from the server'));
});
Expand Down

0 comments on commit 4fcc1d9

Please sign in to comment.