Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add workspaceId, mode, name to webhook #9820

Merged
merged 11 commits into from
Aug 22, 2024
Merged

Conversation

gt2345
Copy link
Contributor

@gt2345 gt2345 commented Aug 14, 2024

Ticket

MD-477

Description

Part of workload alerting project.
ERD link: https://hpe-aiatscale.atlassian.net/wiki/spaces/ENGINEERIN/pages/1666809868/Workload+Alerting+ERD

Add workspaceId, name, mode to webhook

Test Plan

Login as admin, with "Webhook improvement" flag enabled, navigate to webhook page.
The webhook creation modal should have new fields, and the table should display new fields.

Screenshot 2024-08-14 at 10 54 14 AM Screenshot 2024-08-14 at 11 01 50 AM

With feature flag off, the webhook should still work as expected.

Checklist

  • Changes have been manually QA'd
  • New features have been approved by the corresponding PM
  • User-facing API changes have the "User-facing API Change" label
  • Release notes have been added as a separate file under docs/release-notes/
    See Release Note for details.
  • Licenses have been included for new code which was copied and/or modified from any external code

Copy link

netlify bot commented Aug 14, 2024

Deploy Preview for determined-ui canceled.

Name Link
🔨 Latest commit e4011fb
🔍 Latest deploy log https://app.netlify.com/sites/determined-ui/deploys/66c4c7a289d3c300083ddeab

@gt2345 gt2345 requested review from jgongd and removed request for jesse-amano-hpe August 14, 2024 16:09
Copy link

codecov bot commented Aug 14, 2024

Codecov Report

Attention: Patch coverage is 4.42478% with 216 lines in your changes missing coverage. Please review.

Project coverage is 54.64%. Comparing base (52f2b9f) to head (e4011fb).
Report is 12 commits behind head on main.

Files Patch % Lines
webui/react/src/pages/WebhookList.tsx 0.00% 93 Missing and 1 partial ⚠️
webui/react/src/components/WebhookCreateModal.tsx 0.00% 58 Missing ⚠️
webui/react/src/pages/WebhookList.settings.ts 0.00% 34 Missing ⚠️
master/internal/webhooks/webhook.go 0.00% 22 Missing ⚠️
webui/react/src/services/decoder.ts 0.00% 7 Missing ⚠️
webui/react/src/components/Table/Table.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9820      +/-   ##
==========================================
- Coverage   54.71%   54.64%   -0.08%     
==========================================
  Files        1261     1261              
  Lines      155969   156179     +210     
  Branches     3590     3589       -1     
==========================================
- Hits        85345    85344       -1     
- Misses      70492    70703     +211     
  Partials      132      132              
Flag Coverage Δ
backend 45.14% <0.00%> (-0.04%) ⬇️
harness 72.60% <ø> (ø)
web 54.34% <4.90%> (-0.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
webui/react/src/hooks/useFeature.ts 94.95% <100.00%> (+0.26%) ⬆️
webui/react/src/types.ts 99.70% <100.00%> (+<0.01%) ⬆️
webui/react/src/components/Table/Table.tsx 82.80% <0.00%> (ø)
webui/react/src/services/decoder.ts 21.36% <0.00%> (-0.17%) ⬇️
master/internal/webhooks/webhook.go 12.50% <0.00%> (-3.72%) ⬇️
webui/react/src/pages/WebhookList.settings.ts 0.00% <0.00%> (ø)
webui/react/src/components/WebhookCreateModal.tsx 0.00% <0.00%> (ø)
webui/react/src/pages/WebhookList.tsx 0.00% <0.00%> (ø)

... and 3 files with indirect coverage changes

Copy link
Contributor

@EmilyBonar EmilyBonar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Web code is looking good but needs some tweaks. Haven't tested the feature yet

Comment on lines 61 to 62
description: 'Webhook improvement',
friendlyName: 'Webhook improvement',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: friendlyName should be Title Case, description should include at least vaguely what improvements are included

Comment on lines 68 to 71
const workspaces = Loadable.match(useObservable(workspaceStore.workspaces), {
_: () => [],
Loaded: (ws) => ws,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sugg: const workspaces = useObservable(workspaceStore.workspaces).getOrElse([])

};

export interface Settings extends InteractiveTableSettings {
columns: WebhookColumnName[];
workspace?: number[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: workspace -> workspaceIds

@@ -83,6 +103,14 @@ const WebhooksView: React.FC = () => {
fetchWebhooks();
}, [fetchWebhooks]);

useEffect(() => {
if (settings.workspace?.length) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: if (Array.isArray(settings.workspace)) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but this feels a bit unsafe for me, in case the settings.workspace is set to 0 accidentally..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up to you

@@ -83,6 +103,14 @@ const WebhooksView: React.FC = () => {
fetchWebhooks();
}, [fetchWebhooks]);

useEffect(() => {
if (settings.workspace?.length) {
setFilteredWebhooks(webhooks.filter((w) => settings.workspace?.includes(w.workspaceId)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sugg: as written this line has a nested loop. a possibly more performant alternative would be:

const idSet = new Set(settings.workspace);
setFilteredWebhooks(webhooks.filter((w) => idSet.has(w.workspaceId)));

initialValue={V1WebhookMode.WORKSPACE}
label="Trigger by"
name="mode"
rules={[{ message: 'Webhook mode is required ', required: true }]}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: remove trailing space

label="Trigger by"
name="mode"
rules={[{ message: 'Webhook mode is required ', required: true }]}>
<Select options={modeOptions} placeholder="Select mode of Webhook" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: maybe just Select webhook mode?

@@ -132,6 +157,25 @@ const WebhookCreateModalComponent: React.FC<Props> = ({ onSuccess }: Props) => {
id={idPrefix + FORM_ID}
layout="vertical"
onFieldsChange={onChange}>
{f_webhook && (
<>
<Form.Item label="Workspace" name="workspaceId">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this says it's required but doesn't seem to be in code. i see that there's a default value but you also allow the select to be cleared

Comment on lines 75 to 78
const workspaces = Loadable.match(useObservable(workspaceStore.workspaces), {
_: () => [],
Loaded: (ws) => ws,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: const workspaces = useObservable(workspaceStore.workspaces).getOrElse([])

value: V1WebhookMode.WORKSPACE,
},
{
label: 'Specific experiment with matching configuration',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: can this mode ever match multiple experiments? if so maybe change copy to Specific experiment(s) with...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EmilyBonar Thanks for reviewing!
Feel free to try out the feature, since the only changes here are related to creating webhooks, using webhooks should work as expected.

Copy link
Contributor

@jgongd jgongd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modev stamp. LGTM!

Copy link
Contributor

@EmilyBonar EmilyBonar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Web side looks good!

@gt2345 gt2345 merged commit 640126b into main Aug 22, 2024
82 of 96 checks passed
@gt2345 gt2345 deleted the gt/477-extend-webhook branch August 22, 2024 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants