Skip to content

Commit e66c4ad

Browse files
authored
feat(config-ui): add tips for project incoming webhook (#5119)
* feat(config-ui): add new component alert * feat(config-ui): add tips for project incoming webhook
1 parent ba2839b commit e66c4ad

File tree

3 files changed

+79
-29
lines changed

3 files changed

+79
-29
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
import styled from 'styled-components';
20+
21+
const Wrapper = styled.div`
22+
padding: 24px;
23+
background: #f0f4fe;
24+
border: 1px solid #bdcefb;
25+
border-radius: 4px;
26+
`;
27+
28+
interface Props {
29+
style?: React.CSSProperties;
30+
content?: React.ReactNode;
31+
children?: React.ReactNode;
32+
}
33+
34+
export const Alert = ({ style, content, children }: Props) => {
35+
return <Wrapper style={style}>{content ?? children}</Wrapper>;
36+
};

config-ui/src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
export * from './action';
20+
export * from './alert';
2021
export * from './card';
2122
export * from './dialog';
2223
export * from './divider';

config-ui/src/pages/project/detail/panel/incoming-webhooks.tsx

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
*
1717
*/
1818

19-
import React, { useState, useMemo } from 'react';
19+
import { useState, useMemo } from 'react';
2020
import { Button, Intent } from '@blueprintjs/core';
2121

22-
import { NoData } from '@/components';
22+
import { Alert, NoData } from '@/components';
2323
import type { WebhookItemType } from '@/plugins/register/webook';
2424
import { WebhookCreateDialog, WebhookSelectorDialog, WebHookConnection } from '@/plugins/register/webook';
2525

@@ -56,31 +56,44 @@ export const IncomingWebhooksPanel = ({
5656
setType(undefined);
5757
};
5858

59-
if (!webhookIds.length) {
60-
return (
61-
<>
62-
<NoData
63-
text="Push `incidents` or `deployments` from your tools by incoming webhooks."
64-
action={
65-
<>
66-
<Button intent={Intent.PRIMARY} icon="plus" text="Add a Webhook" onClick={() => setType('create')} />
67-
<div style={{ margin: '8px 0' }}>or</div>
68-
<Button
69-
outlined
70-
intent={Intent.PRIMARY}
71-
text="Select Existing Webhooks"
72-
onClick={() => setType('selectExist')}
73-
/>
74-
</>
75-
}
76-
/>
77-
{type === 'create' && <WebhookCreateDialog isOpen onCancel={handleCancel} onSubmitAfter={onCreateWebhook} />}
78-
{type === 'selectExist' && (
79-
<WebhookSelectorDialog isOpen saving={saving} onCancel={handleCancel} onSubmit={onSelectWebhook} />
80-
)}
81-
</>
82-
);
83-
}
84-
85-
return <WebHookConnection filterIds={webhookIds} onCreateAfter={onCreateWebhook} onDeleteAfter={onDeleteWebhook} />;
59+
return (
60+
<>
61+
<Alert style={{ marginBottom: 24, color: '#3C5088' }}>
62+
<div>
63+
The data pushed by Webhooks will only be calculated for DORA in the next run of the Blueprint of this project
64+
because DORA relies on the post-processing of "deployments," "incidents," and "pull requests" triggered by
65+
running the blueprint.
66+
</div>
67+
<div style={{ marginTop: 16 }}>
68+
To calculate DORA after receiving Webhook data immediately, you can visit the{' '}
69+
<b style={{ textDecoration: 'underline' }}>Status tab</b> of the Blueprint page and click on Run Now.
70+
</div>
71+
</Alert>
72+
{!webhookIds.length ? (
73+
<>
74+
<NoData
75+
text="Push `incidents` or `deployments` from your tools by incoming webhooks."
76+
action={
77+
<>
78+
<Button intent={Intent.PRIMARY} icon="plus" text="Add a Webhook" onClick={() => setType('create')} />
79+
<div style={{ margin: '8px 0' }}>or</div>
80+
<Button
81+
outlined
82+
intent={Intent.PRIMARY}
83+
text="Select Existing Webhooks"
84+
onClick={() => setType('selectExist')}
85+
/>
86+
</>
87+
}
88+
/>
89+
{type === 'create' && <WebhookCreateDialog isOpen onCancel={handleCancel} onSubmitAfter={onCreateWebhook} />}
90+
{type === 'selectExist' && (
91+
<WebhookSelectorDialog isOpen saving={saving} onCancel={handleCancel} onSubmit={onSelectWebhook} />
92+
)}
93+
</>
94+
) : (
95+
<WebHookConnection filterIds={webhookIds} onCreateAfter={onCreateWebhook} onDeleteAfter={onDeleteWebhook} />
96+
)}
97+
</>
98+
);
8699
};

0 commit comments

Comments
 (0)