This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #220 from gashcrumb/integration-details
- Loading branch information
Showing
12 changed files
with
708 additions
and
159 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Activity, IntegrationDeployment } from '@syndesis/models'; | ||
import * as React from 'react'; | ||
import { SyndesisFetch } from './SyndesisFetch'; | ||
|
||
export interface IIntegrationDeploymentResponse { | ||
items: IntegrationDeployment[]; | ||
totalCount: number; | ||
} | ||
|
||
export interface IActivitiesAndDeploymentsChildrenProps { | ||
activities: Activity[]; | ||
deployments: IntegrationDeployment[]; | ||
fetchDeployments: () => Promise<void>; | ||
fetchActivities: () => Promise<void>; | ||
} | ||
|
||
export interface IWithActivitiesProps { | ||
integrationId: string; | ||
children(props: IActivitiesAndDeploymentsChildrenProps): any; | ||
} | ||
|
||
export class WithActivities extends React.Component<IWithActivitiesProps> { | ||
public render() { | ||
return ( | ||
<SyndesisFetch<IIntegrationDeploymentResponse> | ||
url={`/integrations/${this.props.integrationId}/deployments`} | ||
defaultValue={{ items: [], totalCount: 0 }} | ||
> | ||
{({ read: fetchDeployments, response: deployments }) => ( | ||
<SyndesisFetch<Activity[]> | ||
url={`/activity/integrations/${this.props.integrationId}`} | ||
defaultValue={[]} | ||
> | ||
{({ read: fetchActivities, response: activities }) => { | ||
return this.props.children({ | ||
activities: activities.data, | ||
deployments: deployments.data.items, | ||
fetchActivities, | ||
fetchDeployments, | ||
}); | ||
}} | ||
</SyndesisFetch> | ||
)} | ||
</SyndesisFetch> | ||
); | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
app/ui-react/packages/api/src/WithMonitoredIntegration.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { | ||
IIntegrationOverviewWithDraft, | ||
IntegrationMonitoring, | ||
IntegrationWithMonitoring, | ||
} from '@syndesis/models'; | ||
import * as React from 'react'; | ||
import { IFetchState } from './Fetch'; | ||
import { ServerEventsContext } from './ServerEventsContext'; | ||
import { SyndesisFetch } from './SyndesisFetch'; | ||
import { WithChangeListener } from './WithChangeListener'; | ||
import { WithIntegration } from './WithIntegration'; | ||
import { IChangeEvent } from './WithServerEvents'; | ||
|
||
export interface IWithMonitoredIntegrationProps { | ||
integrationId: string; | ||
disableUpdates?: boolean; | ||
children(props: IFetchState<IntegrationWithMonitoring>): any; | ||
} | ||
|
||
/** | ||
* A component that fetches the integration with the specified identifier. | ||
* @see [integrationId]{@link IWithIntegrationProps#integrationId} | ||
*/ | ||
export class WithMonitoredIntegration extends React.Component< | ||
IWithMonitoredIntegrationProps | ||
> { | ||
public constructor(props: IWithMonitoredIntegrationProps) { | ||
super(props); | ||
this.changeFilter = this.changeFilter.bind(this); | ||
} | ||
public changeFilter(change: IChangeEvent) { | ||
return ( | ||
change.kind.startsWith('integration') && | ||
change.id.startsWith(this.props.integrationId) | ||
); | ||
} | ||
public getMonitoredIntegration( | ||
integration: IIntegrationOverviewWithDraft, | ||
response: IFetchState<IntegrationMonitoring[]> | ||
) { | ||
return { | ||
integration, | ||
monitoring: response.data.find( | ||
(o: IntegrationMonitoring) => o.integrationId === integration.id | ||
), | ||
}; | ||
} | ||
public render() { | ||
return ( | ||
<WithIntegration | ||
integrationId={this.props.integrationId} | ||
disableUpdates={this.props.disableUpdates} | ||
> | ||
{({ data: integration, ...props }) => ( | ||
<SyndesisFetch<IntegrationMonitoring[]> | ||
url={'/monitoring/integrations'} | ||
defaultValue={[]} | ||
> | ||
{({ read, response }) => { | ||
if (this.props.disableUpdates) { | ||
const data = this.getMonitoredIntegration( | ||
integration, | ||
response | ||
); | ||
return this.props.children({ ...props, data }); | ||
} | ||
return ( | ||
<ServerEventsContext.Consumer> | ||
{({ registerChangeListener, unregisterChangeListener }) => ( | ||
<WithChangeListener | ||
read={read} | ||
registerChangeListener={registerChangeListener} | ||
unregisterChangeListener={unregisterChangeListener} | ||
filter={this.changeFilter} | ||
> | ||
{() => { | ||
const data = this.getMonitoredIntegration( | ||
integration, | ||
response | ||
); | ||
return this.props.children({ ...props, data }); | ||
}} | ||
</WithChangeListener> | ||
)} | ||
</ServerEventsContext.Consumer> | ||
); | ||
}} | ||
</SyndesisFetch> | ||
)} | ||
</WithIntegration> | ||
); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
89 changes: 89 additions & 0 deletions
89
app/ui-react/syndesis/src/modules/integrations/components/IntegrationDetailHeader.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { canActivate, canDeactivate } from '@syndesis/api'; | ||
import { | ||
IntegrationMonitoring, | ||
IntegrationWithMonitoring, | ||
} from '@syndesis/models'; | ||
import { | ||
IMenuActions, | ||
IntegrationDetailBreadcrumb, | ||
IntegrationDetailInfo, | ||
} from '@syndesis/ui'; | ||
import * as React from 'react'; | ||
import { Translation } from 'react-i18next'; | ||
import resolvers from '../../resolvers'; | ||
import { IntegrationDetailNavBar } from '../shared'; | ||
|
||
export interface IIntegrationDetailHeaderProps { | ||
data: IntegrationWithMonitoring; | ||
startAction: IMenuActions; | ||
stopAction: IMenuActions; | ||
deleteAction: IMenuActions; | ||
ciCdAction: IMenuActions; | ||
editAction: IMenuActions; | ||
exportAction: IMenuActions; | ||
getPodLogUrl: ( | ||
monitoring: IntegrationMonitoring | undefined | ||
) => string | undefined; | ||
} | ||
|
||
export const IntegrationDetailHeader: React.FunctionComponent< | ||
IIntegrationDetailHeaderProps | ||
> = (props: IIntegrationDetailHeaderProps) => { | ||
const breadcrumbMenuActions: IMenuActions[] = []; | ||
if (canActivate(props.data.integration)) { | ||
breadcrumbMenuActions.push(props.startAction); | ||
} | ||
if (canDeactivate(props.data.integration)) { | ||
breadcrumbMenuActions.push(props.stopAction); | ||
} | ||
breadcrumbMenuActions.push(props.deleteAction); | ||
breadcrumbMenuActions.push(props.ciCdAction); | ||
|
||
return ( | ||
<Translation ns={['integrations', 'shared']}> | ||
{t => ( | ||
<> | ||
<IntegrationDetailBreadcrumb | ||
editHref={props.editAction.href} | ||
editLabel={props.editAction.label} | ||
exportAction={props.exportAction.onClick} | ||
exportHref={props.exportAction.href} | ||
exportLabel={props.exportAction.label} | ||
homeHref={resolvers.dashboard.root()} | ||
i18nHome={t('shared:Home')} | ||
i18nIntegrations={t('shared:Integrations')} | ||
i18nPageTitle={t('integrations:detail:pageTitle')} | ||
integrationId={props.data.integration.id} | ||
integrationsHref={resolvers.integrations.list()} | ||
menuActions={breadcrumbMenuActions} | ||
/> | ||
|
||
<IntegrationDetailInfo | ||
name={props.data.integration.name} | ||
version={props.data.integration.version} | ||
currentState={props.data.integration.currentState!} | ||
targetState={props.data.integration.targetState!} | ||
monitoringValue={ | ||
props.data.monitoring && | ||
t('integrations:' + props.data.monitoring.detailedState.value) | ||
} | ||
monitoringCurrentStep={ | ||
props.data.monitoring && | ||
props.data.monitoring.detailedState.currentStep | ||
} | ||
monitoringTotalSteps={ | ||
props.data.monitoring && | ||
props.data.monitoring.detailedState.totalSteps | ||
} | ||
monitoringLogUrl={props.getPodLogUrl(props.data.monitoring)} | ||
i18nProgressPending={t('shared:Pending')} | ||
i18nProgressStarting={t('integrations:progressStarting')} | ||
i18nProgressStopping={t('integrations:progressStopping')} | ||
i18nLogUrlText={t('shared:viewLogs')} | ||
/> | ||
<IntegrationDetailNavBar integration={props.data.integration} /> | ||
</> | ||
)} | ||
</Translation> | ||
); | ||
}; |
1 change: 1 addition & 0 deletions
1
app/ui-react/syndesis/src/modules/integrations/components/index.ts
This file contains 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
Oops, something went wrong.