Created
July 29, 2019 07:47
-
-
Save cedricdekimpe/f582d282eeddee7c0f74edbb2b343b81 to your computer and use it in GitHub Desktop.
merge conflict
This file contains hidden or 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
diff --cc app/javascript/src/apps/Dashboard/index.tsx | |
index f7e201298,070ea9009..000000000 | |
--- a/app/javascript/src/apps/Dashboard/index.tsx | |
+++ b/app/javascript/src/apps/Dashboard/index.tsx | |
@@@ -1,13 -1,216 +1,230 @@@ | |
++<<<<<<< HEAD | |
+import React from "react"; | |
+//import MainNavigationBar from "@components/Navigation/MainNavigationBar"; | |
+import AppIntelligence from "./AppIntelligence"; | |
++======= | |
+ import React, { lazy, Suspense, useState, useEffect, Fragment } from "react"; | |
+ import axios from "axios"; | |
+ import { Tabs, Tab } from "react-bootstrap"; | |
+ import { listSlimFollowedApps } from "@services/FollowedAppsService"; | |
+ import { listIntegrationApps, listIntegrations } from "@services/IntegrationService"; | |
+ import Integration from "@models/Integration"; | |
+ import SlimFollowedApp from "@models/SlimFollowedApp"; | |
+ import IntegrationApp from "@models/IntegrationApp"; | |
+ import DashFilters from "@apps/Dashboard/containers/DashFilters"; | |
+ import FilterView from "@apps/Dashboard/FilterView"; | |
+ import Summaries from "@apps/Dashboard/SummaryView"; | |
+ import AppTweakSpinner from "@components/AppTweakSpinner"; | |
+ import TabTitle from "@components/TabTitle"; | |
+ import filter from "lodash/filter"; | |
+ import includes from "lodash/includes"; | |
+ import size from "lodash/size"; | |
+ import { mixpanel, addToMixpanelEvents } from "@globals/mixpanel"; | |
+ import AppTweakBanner from "@components/AppTweakBanner"; | |
+ | |
+ // Lazy loads | |
+ const FollowedAppsView = lazy(() => | |
+ import("@apps/Dashboard/FollowedAppsView") | |
+ ); | |
+ const IntegrationsView = lazy(() => | |
+ import("@apps/Dashboard/IntegrationsView") | |
+ ); | |
+ | |
+ interface DashProps {} | |
+ | |
+ const Dashboard = (props: DashProps) => { | |
+ const signal = axios.CancelToken.source(); | |
+ | |
+ const emptyFollowedApps: SlimFollowedApp[] = []; | |
+ const emptyIntegrationApps: IntegrationApp[] = []; | |
+ const emptyIntegrationAccounts: Integration[] = []; | |
+ const emptyStringArray: string[] = []; | |
+ | |
+ const [selectedTab, setSelectedTab] = useState(1); | |
+ | |
+ const [isLoadingFollowedApps, setIsLoadingFollowedApps] = useState(true); | |
+ const [isLoadingIntegrationApps, setIsLoadingIntegrationApps] = useState( | |
+ true | |
+ ); | |
+ const [ | |
+ isLoadingIntegrationAccounts, | |
+ setIsLoadingIntegrationAccounts | |
+ ] = useState(true); | |
+ const [isError, setIsError] = useState(false); | |
+ | |
+ const [followedApps, setFollowedApps] = useState(emptyFollowedApps); | |
+ const [integrationApps, setIntegrationApps] = useState(emptyIntegrationApps); | |
+ const [integrationAccounts, setIntegrationAccounts] = useState( | |
+ emptyIntegrationAccounts | |
+ ); | |
+ | |
+ const initialFilterState = { | |
+ applicationId: "", | |
+ country: emptyStringArray, | |
+ store: "all", | |
+ selectedApp: undefined | |
+ }; | |
+ | |
+ useEffect(() => { | |
+ const fetchFollowedApps = async () => { | |
+ try { | |
+ const followedApps = await listSlimFollowedApps(signal.token); | |
+ setFollowedApps(followedApps); | |
+ } catch (error) { | |
+ setIsError(true); | |
+ } | |
+ setIsLoadingFollowedApps(false); | |
+ }; | |
+ | |
+ fetchFollowedApps(); | |
+ | |
+ return () => { | |
+ signal.cancel("API call cancelled"); | |
+ }; | |
+ }, []); | |
+ | |
+ useEffect(() => { | |
+ const fetchIntegrationApps = async () => { | |
+ try { | |
+ const integrationApps = await listIntegrationApps(signal.token); | |
+ setIntegrationApps(integrationApps); | |
+ } catch (error) { | |
+ setIsError(true); | |
+ } | |
+ setIsLoadingIntegrationApps(false); | |
+ }; | |
+ | |
+ fetchIntegrationApps(); | |
+ | |
+ return () => { | |
+ signal.cancel("API call cancelled"); | |
+ }; | |
+ }, []); | |
+ | |
+ useEffect(() => { | |
+ const fetchIntegrationAccounts = async () => { | |
+ try { | |
+ const integrations = await listIntegrations(); | |
+ setIntegrationAccounts(integrations); | |
+ } catch (error) { | |
+ setIsError(true); | |
+ } | |
+ setIsLoadingIntegrationAccounts(false); | |
+ }; | |
+ | |
+ fetchIntegrationAccounts(); | |
+ | |
+ //return ()=>{signal.cancel("API call cancelled");} | |
+ }, []); | |
+ | |
+ const updateFollowedApps = (appObj: any) => { | |
+ const updated = includes(followedApps.map(app => app.id), appObj.id) | |
+ ? filter(followedApps, app => app.id !== appObj.id) | |
+ : followedApps.concat([appObj]); | |
+ setFollowedApps(updated); | |
+ }; | |
+ | |
+ const trackAddNewIntegeration = () => { | |
+ if (mixpanel) { | |
+ addToMixpanelEvents('Dashboard > Clicked Button Add new integration') | |
+ } | |
+ } | |
++>>>>>>> debug/20190725 | |
+const Dashboard = () => { | |
return ( | |
++<<<<<<< HEAD | |
+ <> | |
+ {/*<MainNavigationBar activeTab="/" />*/} | |
+ <AppIntelligence /> | |
+ </> | |
++======= | |
+ <Fragment> | |
+ <h1>My Apps</h1> | |
+ | |
+ <a | |
+ className="pull-right btn btn-outline btn-info" | |
+ href="/dashboard/external_accounts/setup" | |
+ onClick={e => trackAddNewIntegeration()} | |
+ > | |
+ <i className="fa fa-plus" /> | |
+ {" Add new Integration"} | |
+ </a> | |
+ | |
+ <a className="pull-right btn btn-primary showWizard mr10"> | |
+ <i className="fa fa-plus" /> | |
+ {" Add an app"} | |
+ </a> | |
+ | |
+ | |
+ <DashFilters.Provider initialState={initialFilterState}> | |
+ <div className="aptwk-dash-container-section-1"> | |
+ <FilterView followedApps={followedApps} /> | |
+ </div> | |
+ <div> | |
+ {isLoadingFollowedApps ? ( | |
+ <AppTweakSpinner height="145px" /> | |
+ ) : ( | |
+ <Summaries | |
+ followedApps={followedApps} | |
+ integratedApps={integrationApps} | |
+ /> | |
+ )} | |
+ <Tabs | |
+ animation={false} | |
+ id="dashboard_tabsContainer" | |
+ activeKey={selectedTab} | |
+ onSelect={i => setSelectedTab(i)} | |
+ > | |
+ <Tab | |
+ eventKey={1} | |
+ title={ | |
+ <TabTitle | |
+ title="Followed Apps" | |
+ badge={isLoadingFollowedApps ? "..." : size(followedApps).toString()} | |
+ /> | |
+ } | |
+ > | |
+ <Suspense key={1} fallback={<AppTweakSpinner />}> | |
+ {isLoadingFollowedApps ? ( | |
+ <AppTweakSpinner height="400px" /> | |
+ ) : ( | |
+ <FollowedAppsView | |
+ followedApps={followedApps} | |
+ integratedApps={integrationApps} | |
+ unfollow={updateFollowedApps} | |
+ switchTabs={() => setSelectedTab(2)} | |
+ /> | |
+ )} | |
+ </Suspense> | |
+ </Tab> | |
+ <Tab | |
+ eventKey={2} | |
+ title={ | |
+ <TabTitle | |
+ title="Integrations" | |
+ badge={isLoadingIntegrationApps ? "..." : size(integrationApps).toString()} | |
+ /> | |
+ } | |
+ > | |
+ <Suspense key={2} fallback={<AppTweakSpinner />}> | |
+ {isLoadingIntegrationApps || isLoadingIntegrationAccounts ? ( | |
+ <AppTweakSpinner height="400px" /> | |
+ ) : ( | |
+ <IntegrationsView | |
+ integrations={integrationAccounts} | |
+ followedApps={followedApps} | |
+ integratedApps={integrationApps} | |
+ follow={updateFollowedApps} | |
+ /> | |
+ )} | |
+ </Suspense> | |
+ </Tab> | |
+ </Tabs> | |
+ </div> | |
+ </DashFilters.Provider> | |
+ </Fragment> | |
++>>>>>>> debug/20190725 | |
); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment