Skip to content

Commit

Permalink
Minor ux improvement in integrations table
Browse files Browse the repository at this point in the history
  • Loading branch information
reichert621 committed Jan 9, 2021
1 parent 898feb5 commit 4120640
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 9 additions & 1 deletion assets/src/components/integrations/IntegrationsOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import NewWebhookModal from './NewWebhookModal';
type Props = RouteComponentProps<{type?: string}> & {};
type State = {
loading: boolean;
refreshing: boolean;
isWebhookModalOpen: boolean;
selectedWebhook: WebhookEventSubscription | null;
integrations: Array<IntegrationType>;
Expand All @@ -24,6 +25,7 @@ type State = {
class IntegrationsOverview extends React.Component<Props, State> {
state: State = {
loading: true,
refreshing: false,
isWebhookModalOpen: false,
selectedWebhook: null,
integrations: [],
Expand Down Expand Up @@ -62,6 +64,8 @@ class IntegrationsOverview extends React.Component<Props, State> {

refreshAllIntegrations = async () => {
try {
this.setState({refreshing: true});

const integrations = await Promise.all([
this.fetchSlackIntegration(),
this.fetchSlackSupportIntegration(),
Expand All @@ -71,9 +75,11 @@ class IntegrationsOverview extends React.Component<Props, State> {
this.fetchWhatsAppIntegration(),
]);

this.setState({integrations});
this.setState({integrations, refreshing: false});
} catch (err) {
logger.error('Error refreshing integrations:', err);

this.setState({refreshing: false});
}
};

Expand Down Expand Up @@ -229,6 +235,7 @@ class IntegrationsOverview extends React.Component<Props, State> {
render() {
const {
loading,
refreshing,
isWebhookModalOpen,
selectedWebhook,
webhooks = [],
Expand Down Expand Up @@ -277,6 +284,7 @@ class IntegrationsOverview extends React.Component<Props, State> {

<Box mt={3} mb={4}>
<IntegrationsTable
loading={refreshing}
integrations={integrations}
onDisconnectSlack={this.handleDisconnectSlack}
/>
Expand Down
6 changes: 5 additions & 1 deletion assets/src/components/integrations/IntegrationsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ const getGmailAuthUrl = () => {
};

const IntegrationsTable = ({
loading,
integrations,
onDisconnectSlack,
}: {
loading?: boolean;
integrations: Array<IntegrationType>;
onDisconnectSlack: (id: string) => void;
}) => {
Expand Down Expand Up @@ -181,7 +183,9 @@ const IntegrationsTable = ({
},
];

return <Table dataSource={integrations} columns={columns} />;
return (
<Table loading={loading} dataSource={integrations} columns={columns} />
);
};

export default IntegrationsTable;

0 comments on commit 4120640

Please sign in to comment.