From 21b4be2173e36fef157e46582060e265edb1bf45 Mon Sep 17 00:00:00 2001 From: Guillaume Jambet Date: Wed, 31 Jan 2018 18:47:59 +0100 Subject: SONAR-10344 api/webhooks/search returns webhooks for global and project --- server/sonar-web/src/main/js/api/webhooks.ts | 16 +--------------- server/sonar-web/src/main/js/app/types.ts | 15 +++++++++++++++ .../src/main/js/apps/webhooks/components/App.tsx | 6 +++--- .../src/main/js/apps/webhooks/components/WebhookItem.tsx | 2 +- .../main/js/apps/webhooks/components/WebhooksList.tsx | 15 +++++---------- 5 files changed, 25 insertions(+), 29 deletions(-) (limited to 'server/sonar-web/src/main/js') diff --git a/server/sonar-web/src/main/js/api/webhooks.ts b/server/sonar-web/src/main/js/api/webhooks.ts index fa526855e02..547702464b1 100644 --- a/server/sonar-web/src/main/js/api/webhooks.ts +++ b/server/sonar-web/src/main/js/api/webhooks.ts @@ -19,21 +19,7 @@ */ import { getJSON } from '../helpers/request'; import throwGlobalError from '../app/utils/throwGlobalError'; - -export interface Delivery { - id: string; - at: string; - success: boolean; - httpStatus: number; - durationMs: number; -} - -export interface Webhook { - key: string; - name: string; - url: string; - latestDelivery?: Delivery; -} +import { Webhook } from '../app/types'; export function searchWebhooks(data: { organization: string | undefined; diff --git a/server/sonar-web/src/main/js/app/types.ts b/server/sonar-web/src/main/js/app/types.ts index 13b8bac9f66..43f2c58bad5 100644 --- a/server/sonar-web/src/main/js/app/types.ts +++ b/server/sonar-web/src/main/js/app/types.ts @@ -383,3 +383,18 @@ export enum Visibility { Public = 'public', Private = 'private' } + +export interface Webhook { + key: string; + latestDelivery?: WebhookDelivery; + name: string; + url: string; +} + +export interface WebhookDelivery { + at: string; + durationMs: number; + httpStatus: number; + id: string; + success: boolean; +} diff --git a/server/sonar-web/src/main/js/apps/webhooks/components/App.tsx b/server/sonar-web/src/main/js/apps/webhooks/components/App.tsx index 36f26f55913..e1d559ef307 100644 --- a/server/sonar-web/src/main/js/apps/webhooks/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/webhooks/components/App.tsx @@ -21,13 +21,13 @@ import * as React from 'react'; import { Helmet } from 'react-helmet'; import PageHeader from './PageHeader'; import WebhooksList from './WebhooksList'; -import { searchWebhooks, Webhook } from '../../../api/webhooks'; -import { LightComponent, Organization } from '../../../app/types'; +import { searchWebhooks } from '../../../api/webhooks'; +import { LightComponent, Organization, Webhook } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; interface Props { - organization: Organization | undefined; component?: LightComponent; + organization: Organization | undefined; } interface State { diff --git a/server/sonar-web/src/main/js/apps/webhooks/components/WebhookItem.tsx b/server/sonar-web/src/main/js/apps/webhooks/components/WebhookItem.tsx index 1be6a9da181..f156900d581 100644 --- a/server/sonar-web/src/main/js/apps/webhooks/components/WebhookItem.tsx +++ b/server/sonar-web/src/main/js/apps/webhooks/components/WebhookItem.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { Webhook } from '../../../api/webhooks'; +import { Webhook } from '../../../app/types'; interface Props { webhook: Webhook; diff --git a/server/sonar-web/src/main/js/apps/webhooks/components/WebhooksList.tsx b/server/sonar-web/src/main/js/apps/webhooks/components/WebhooksList.tsx index 61689e75561..600fad4e8d3 100644 --- a/server/sonar-web/src/main/js/apps/webhooks/components/WebhooksList.tsx +++ b/server/sonar-web/src/main/js/apps/webhooks/components/WebhooksList.tsx @@ -19,7 +19,7 @@ */ import * as React from 'react'; import WebhookItem from './WebhookItem'; -import { Webhook } from '../../../api/webhooks'; +import { Webhook } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; interface Props { @@ -36,21 +36,16 @@ export default class WebhooksList extends React.PureComponent { ); - renderNoWebhooks = () => ( - - {translate('webhooks.no_result')} - - ); - render() { const { webhooks } = this.props; + if (webhooks.length < 1) { + return

{translate('webhooks.no_result')}

; + } return ( {this.renderHeader()} - {webhooks.length > 0 - ? webhooks.map(webhook => ) - : this.renderNoWebhooks()} + {webhooks.map(webhook => )}
); -- cgit v1.2.3