@@ -99,8 +99,11 @@ import {
9999 getIsFetchingApplications ,
100100} from "ee/selectors/selectedWorkspaceSelectors" ;
101101import {
102+ getIsFetchingMyOrganizations ,
103+ getMyOrganizations ,
102104 getOrganizationPermissions ,
103105 shouldShowLicenseBanner ,
106+ activeOrganizationId ,
104107} from "ee/selectors/organizationSelectors" ;
105108import { getWorkflowsList } from "ee/selectors/workflowSelectors" ;
106109import {
@@ -141,6 +144,10 @@ import {
141144} from "git" ;
142145import OldRepoLimitExceededErrorModal from "pages/Editor/gitSync/RepoLimitExceededErrorModal" ;
143146import { trackCurrentDomain } from "utils/multiOrgDomains" ;
147+ import OrganizationDropdown from "components/OrganizationDropdown" ;
148+ import { fetchMyOrganizations } from "ee/actions/organizationActions" ;
149+ import type { Organization } from "ee/api/OrganizationApi" ;
150+ import { useIsCloudBillingEnabled } from "hooks" ;
144151
145152function GitModals ( ) {
146153 const isGitModEnabled = useGitModEnabled ( ) ;
@@ -434,25 +441,45 @@ export const submitCreateWorkspaceForm = async (data: any, dispatch: any) => {
434441} ;
435442
436443export interface LeftPaneProps {
444+ activeOrganizationId ?: string ;
445+ activeWorkspaceId ?: string ;
437446 isBannerVisible ?: boolean ;
447+ isFetchingOrganizations : boolean ;
438448 isFetchingWorkspaces : boolean ;
449+ organizations : Organization [ ] ;
439450 workspaces : Workspace [ ] ;
440- activeWorkspaceId ?: string ;
441451}
442452
443453export function LeftPane ( props : LeftPaneProps ) {
444454 const {
455+ activeOrganizationId,
445456 activeWorkspaceId,
446457 isBannerVisible = false ,
458+ isFetchingOrganizations,
447459 isFetchingWorkspaces,
460+ organizations = [ ] ,
448461 workspaces = [ ] ,
449462 } = props ;
450463 const isMobile = useIsMobileDevice ( ) ;
464+ const isCloudBillingEnabled = useIsCloudBillingEnabled ( ) ;
451465
452466 if ( isMobile ) return null ;
453467
454468 return (
455469 < LeftPaneWrapper isBannerVisible = { isBannerVisible } >
470+ { isCloudBillingEnabled &&
471+ ! isFetchingOrganizations &&
472+ organizations . length > 0 && (
473+ < OrganizationDropdown
474+ organizations = { organizations }
475+ selectedOrganization = {
476+ organizations . find (
477+ ( organization ) =>
478+ organization . organizationId === activeOrganizationId ,
479+ ) || organizations [ 0 ]
480+ }
481+ />
482+ ) }
456483 < LeftPaneSection
457484 heading = { createMessage ( WORKSPACES_HEADING ) }
458485 isBannerVisible = { isBannerVisible }
@@ -992,6 +1019,9 @@ export const ApplictionsMainPage = (props: any) => {
9921019 const isHomePage = useRouteMatch ( "/applications" ) ?. isExact ;
9931020 const isLicensePage = useRouteMatch ( "/license" ) ?. isExact ;
9941021 const isBannerVisible = showBanner && ( isHomePage || isLicensePage ) ;
1022+ const organizations = useSelector ( getMyOrganizations ) ;
1023+ const isFetchingOrganizations = useSelector ( getIsFetchingMyOrganizations ) ;
1024+ const currentOrganizationId = useSelector ( activeOrganizationId ) ;
9951025
9961026 // TODO: Fix this the next time the file is edited
9971027 // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1013,6 +1043,10 @@ export const ApplictionsMainPage = (props: any) => {
10131043 workspaceIdFromQueryParams ? workspaceIdFromQueryParams : workspaces [ 0 ] ?. id ,
10141044 ) ;
10151045
1046+ useEffect ( ( ) => {
1047+ dispatch ( fetchMyOrganizations ( ) ) ;
1048+ } , [ ] ) ;
1049+
10161050 useEffect ( ( ) => {
10171051 setActiveWorkspaceId (
10181052 workspaceIdFromQueryParams
@@ -1056,9 +1090,12 @@ export const ApplictionsMainPage = (props: any) => {
10561090 return (
10571091 < PageWrapper displayName = "Applications" >
10581092 < LeftPane
1093+ activeOrganizationId = { currentOrganizationId }
10591094 activeWorkspaceId = { activeWorkspaceId }
10601095 isBannerVisible = { isBannerVisible }
1096+ isFetchingOrganizations = { isFetchingOrganizations }
10611097 isFetchingWorkspaces = { isFetchingWorkspaces }
1098+ organizations = { organizations }
10621099 workspaces = { workspaces }
10631100 />
10641101 < MediaQuery maxWidth = { MOBILE_MAX_WIDTH } >
0 commit comments