Skip to content

Commit

Permalink
upcoming: [DI-21694] - Added the Create Alert Button and few componen…
Browse files Browse the repository at this point in the history
…ts for the Create Alert Definition Form (linode#11255)

* Upcoming : [DI:21546] - Added the create button and name,description,severity components from General Information for the Create Alert Definition form

* Upcoming: [DI:21456] - Added unit test for AlertSeverity component, changed the naming of properties in the Alert type, updated the url of endpoint

* Upcoming: [DI:21546] - Added the unit test for CreateAlertDefinition component

* upcoming: [DI:21546] - Added the onChange for the tabs

* Upcoming: [DI-21546] - Removed unneccessary components and made changes to the Create Alert forma and Severity Select component

* Upcoming: [DI-21694] - Modified the changes with Severity component, modified and added appropriate types

* Upcoming: [DI-21694] - Added null as empty value for the Severity component, Fixed the Unit Tests for Severity component, fixed styling between components in Create Alert Form

* Merging latest develop changes  (#23)

* feat: [UIE-8194] - DBaaS major and minor upgrades - 4 (linode#11199)

* feat: [M3-8831] - New GPUv2 egress transfer display (linode#11209)

* Add new gpuV2 egress transferlogic

* light cleanup

* adjust e2e s

* Added changeset: New GPUv2 egress transfer helpers

* feedback @coliu-akamai @hkhalil-akamai

* feedback @coliu-akamai @jaalah-akamai

* feedback optimization

* change: [M3-8806] - Disable unsupported images for distributed regions (linode#11206)

## Description 📝
In the Linode Create flow, when a distributed region is selected, images & distros that do not support distributed regions should be disabled

Note: It looks like the distributions are now sorted alphabetically. I don't see any issues with this but just wanted to point that out in case anyone did

## Changes  🔄
List any change relevant to the reviewer.
- Disable unsupported images/distros for distributed regions in Linode Create
- Removed the distributed icon & associated icon text
- Removed the word `currently` in the Add-Ons warning notice for distributed regions
- Added a new generic `ListItemOption` component and refactored `ImageOption`, `PlacementGroupSelectOption`, and `RegionOption` to use new generic component

## Target release date 🗓️
11/12

## How to test 🧪

### Prerequisites
(How to setup test environment)
- Ensure your account has the `new-dc-testing`, `new-dc-testing-gecko`, `edge_testing` and `edge_compute` customer tags

### Verification steps
(How to verify changes)
- Go to the Linode Create page and verify the following on the `OS` tab and `Images` tab:
  - Select a core region -> No Images/distributions should be disabled
  - Select a distributed region -> Images/distributions that do not support distributed regions should be disabled
- There should be no regressions in the components that were refactored
- Ensure unit tests and e2e tests are passing locally/remotely

* fix: [UIE-8246] - DBaaS provisioning 2 node clusters (linode#11218)

* feat : [M3-8528] - Include Object Storage buckets in Support tickets' dropdown (linode#11178)

* feat: [M3-8528] - Include Object Storage in Support Tickets

* query change

* Added changeset: Include Object Storage buckets in Support tickets dropdown

* added link support for object storage

* removed redundant query

* query updation and restructuring request payload

* Added changeset

* Initial Changelog

* refactor: [M3-8646] – Migrate `Divider` to `ui` package  (linode#11205)

* refactor: [M3-8646] – Migrate `Divider` to `ui` package

* Added changeset: Migrate Divider to ui package

* migrating all  imports

* removing redundant hook imports

* updated the import for omittedProps

* UIE-8247: Conditionally give the new docs as the link on database landing page (linode#11227)

* fix: [M3-8764] - Kubernetes UI issues (linode#11217)

* initial clean up

* save progress

* add changeset

* fix type error

* feedback @mjac0bs

* a few more small fixes

* a few more small fixes

---------

Co-authored-by: Banks Nussman <banks@nussman.us>

* upcoming: [DI-21811] - Post processing of missing timestamp data across dimensions in ACLP charts (linode#11225)

* upcoming: [DI-18419] - chart post processing for missing timestamps

* upcoming: [DI-21811] - Code corrections and refactoring

* upcoming: [DI-21811] - Code corrections and refactoring

* upcoming: [DI-21811] - Code corrections and refactoring

* upcoming: [DI-21811] - Added changeset

* upcoming: [DI-21811] - comment updates

* upcoming: [DI-21811] - comment updates

* upcoming: [DI-21811] - comment updates

* upcoming: [DI-21811] - comment updates

* upcoming: [DI-21811] - early returns for empty array

---------

Co-authored-by: vmangalr <vmangalr@akamai.com>

* Update changelog

* refactor: [M3-8650] - Migrate Stack to `@linode/ui` package (linode#11228)

* migrate stack, update organization for divider/icon button

* Added changeset: `Stack` component to `ui` package

* refactor: [M3-8710] - Move `Notice` & `Tooltip` components to UI package and update imports (linode#11174)

* Move Notice to UI package and update imports

* Add test imports

* Add renderWithTheme and other changes to make tests pass

* Fix broken icon imports

* Added changeset: Move `Notice` and `Tooltip` components to UI package

* Feedback @dwiley-akamai: consolidate imports and rename icon exports

* change: [M3-7337] - change Linode Details Summary VPC IPv4 Text to Copy Object. (linode#11172)

* change: [M3-7337] - change Linode Details Summary VPC IPv4 Text to Copy Object.

* Added changeset: change Linode Details Summary VPC IPv4 Text to Copy Object.

* Update changeset description

Co-authored-by: Purvesh Makode <pmakode@akamai.com>

* remove optional chaining

* change Text from "Subnets" to "Subnet"

* remove extra borderTop

* refactor: [M3-7337] - change Linode Details Summary VPC IPv4 Text to Copy Object

* Add descriptive variable name

---------

Co-authored-by: Purvesh Makode <pmakode@akamai.com>

* upcoming: [DI-21814] - ACLP UI - DBaaS instances order by label (linode#11226)

* upcoming: [DI-21814] - DBaaS instances order by label

* upcoming: [DI-21814] - Added changeset

* DI-21814: use map for better readability and optimisations

---------

Co-authored-by: vmangalr <vmangalr@akamai.com>

* UIE-8254: Add tooltip for ipv6 for new db clusters (linode#11231)

* feat: [UIE-8193] - Usable Storage Tooltip for Create/Resize Database table (linode#11232)

* feat: [UIE-8193] - Tooltip for Create/Resize Database table

* feat: [UIE-8193] - Tooltip context for small screens

* feat: [UIE-8193] - Tooltip for Create/Resize Database table (linode#11223)

* feat: [UIE-8193] - Tooltip for Create/Resize Database table

* Added changeset: Tooltip for 'Usable Storage' in Create/Resize Database Table

* feat: [UIE-8193] - Tooltip context for small screens

* DBaaS additions

* GPU egress transfer copy update (linode#11235)

* default behavior when creating new child clusters should match what existed before we enabled IPACL (in other words: disabled by default) (linode#11234)

Co-authored-by: Talmai Oliveira <toliveir@akamai.com>

* Update PULL_REQUEST_TEMPLATE.md (linode#11219)

* change: [M3-8860] - Update unit testing docs to prefer `userEvent` over `fireEvent` (linode#11221)

* Update 08-testing.md for userEvent

* Fix typo

* Address feedback; also further clean up linting issues the doc

* Fix a bad test that was not following good practices

* Added changeset: Update developer docs on unit testing user events

* Update changelog

* Fix LKE create ACL tests (linode#11237)

* feat: [M3-8665] - add option to copy token in LKE details page. (linode#11179)

* feat: [M3-8665] - add option to copy token in LKE details page.

* Added changeset: option to copy token in LKE details page

* Change the "Copy Token" button to use asynchronous functionality

* remove extra styling

* refactor: [M3-8665] - add option to copy token in LKE details page.

* Change cypress test for LKE update spec

* fix: sx styling for Textfield component (linode#11246)

* spread containerProps sx

* spread props.sx as well whoops

* fix: [M3-8894] - Linode Create crash when selected a Linode with a `type` that is `null` (linode#11247)

* don't fetch when `type` is an empty string

* fix and changelog entry

---------

Co-authored-by: Banks Nussman <banks@nussman.us>

* change: [M3-8857] - Update PULL_REQUEST_TEMPLATE (Part 2) (linode#11236)

* Make updates discussed to PR template during retro

* Add changeset

---------

Co-authored-by: corya-akamai <136115382+corya-akamai@users.noreply.github.com>
Co-authored-by: Alban Bailly <130582365+abailly-akamai@users.noreply.github.com>
Co-authored-by: Hana Xu <115299789+hana-akamai@users.noreply.github.com>
Co-authored-by: Harsh Shankar Rao <hrao@akamai.com>
Co-authored-by: Jaalah Ramos <jaalah.ramos@gmail.com>
Co-authored-by: rodonnel-akamai <rodonnel@akamai.com>
Co-authored-by: Banks Nussman <115251059+bnussman-akamai@users.noreply.github.com>
Co-authored-by: Banks Nussman <banks@nussman.us>
Co-authored-by: venkatmano-akamai <chk-Venkatesh@outlook.com>
Co-authored-by: vmangalr <vmangalr@akamai.com>
Co-authored-by: Connie Liu <139280159+coliu-akamai@users.noreply.github.com>
Co-authored-by: Hussain Khalil <122488130+hkhalil-akamai@users.noreply.github.com>
Co-authored-by: hasyed-akamai <hasyed@akamai.com>
Co-authored-by: Purvesh Makode <pmakode@akamai.com>
Co-authored-by: ankitaakamai <ankitaan@akamai.com>
Co-authored-by: mpolotsk-akamai <157619599+mpolotsk-akamai@users.noreply.github.com>
Co-authored-by: Talmai Oliveira <to@talm.ai>
Co-authored-by: Talmai Oliveira <toliveir@akamai.com>
Co-authored-by: John Callahan <114753608+jcallahan-akamai@users.noreply.github.com>
Co-authored-by: Mariah Jacobs <114685994+mjac0bs@users.noreply.github.com>
Co-authored-by: jdamore-linode <97627410+jdamore-linode@users.noreply.github.com>
Co-authored-by: Hana Xu <hxu@akamai.com>

* Revert "Merging latest develop changes  (#23)" (#24)

This reverts commit 2887f18.

* Merging latest changes develop (#25)

* feat: [UIE-8194] - DBaaS major and minor upgrades - 4 (linode#11199)

* feat: [M3-8831] - New GPUv2 egress transfer display (linode#11209)

* Add new gpuV2 egress transferlogic

* light cleanup

* adjust e2e s

* Added changeset: New GPUv2 egress transfer helpers

* feedback @coliu-akamai @hkhalil-akamai

* feedback @coliu-akamai @jaalah-akamai

* feedback optimization

* change: [M3-8806] - Disable unsupported images for distributed regions (linode#11206)

## Description 📝
In the Linode Create flow, when a distributed region is selected, images & distros that do not support distributed regions should be disabled

Note: It looks like the distributions are now sorted alphabetically. I don't see any issues with this but just wanted to point that out in case anyone did

## Changes  🔄
List any change relevant to the reviewer.
- Disable unsupported images/distros for distributed regions in Linode Create
- Removed the distributed icon & associated icon text
- Removed the word `currently` in the Add-Ons warning notice for distributed regions
- Added a new generic `ListItemOption` component and refactored `ImageOption`, `PlacementGroupSelectOption`, and `RegionOption` to use new generic component

## Target release date 🗓️
11/12

## How to test 🧪

### Prerequisites
(How to setup test environment)
- Ensure your account has the `new-dc-testing`, `new-dc-testing-gecko`, `edge_testing` and `edge_compute` customer tags

### Verification steps
(How to verify changes)
- Go to the Linode Create page and verify the following on the `OS` tab and `Images` tab:
  - Select a core region -> No Images/distributions should be disabled
  - Select a distributed region -> Images/distributions that do not support distributed regions should be disabled
- There should be no regressions in the components that were refactored
- Ensure unit tests and e2e tests are passing locally/remotely

* fix: [UIE-8246] - DBaaS provisioning 2 node clusters (linode#11218)

* feat : [M3-8528] - Include Object Storage buckets in Support tickets' dropdown (linode#11178)

* feat: [M3-8528] - Include Object Storage in Support Tickets

* query change

* Added changeset: Include Object Storage buckets in Support tickets dropdown

* added link support for object storage

* removed redundant query

* query updation and restructuring request payload

* Added changeset

* Initial Changelog

* refactor: [M3-8646] – Migrate `Divider` to `ui` package  (linode#11205)

* refactor: [M3-8646] – Migrate `Divider` to `ui` package

* Added changeset: Migrate Divider to ui package

* migrating all  imports

* removing redundant hook imports

* updated the import for omittedProps

* UIE-8247: Conditionally give the new docs as the link on database landing page (linode#11227)

* fix: [M3-8764] - Kubernetes UI issues (linode#11217)

* initial clean up

* save progress

* add changeset

* fix type error

* feedback @mjac0bs

* a few more small fixes

* a few more small fixes

---------

Co-authored-by: Banks Nussman <banks@nussman.us>

* upcoming: [DI-21811] - Post processing of missing timestamp data across dimensions in ACLP charts (linode#11225)

* upcoming: [DI-18419] - chart post processing for missing timestamps

* upcoming: [DI-21811] - Code corrections and refactoring

* upcoming: [DI-21811] - Code corrections and refactoring

* upcoming: [DI-21811] - Code corrections and refactoring

* upcoming: [DI-21811] - Added changeset

* upcoming: [DI-21811] - comment updates

* upcoming: [DI-21811] - comment updates

* upcoming: [DI-21811] - comment updates

* upcoming: [DI-21811] - comment updates

* upcoming: [DI-21811] - early returns for empty array

---------

Co-authored-by: vmangalr <vmangalr@akamai.com>

* Update changelog

* refactor: [M3-8650] - Migrate Stack to `@linode/ui` package (linode#11228)

* migrate stack, update organization for divider/icon button

* Added changeset: `Stack` component to `ui` package

* refactor: [M3-8710] - Move `Notice` & `Tooltip` components to UI package and update imports (linode#11174)

* Move Notice to UI package and update imports

* Add test imports

* Add renderWithTheme and other changes to make tests pass

* Fix broken icon imports

* Added changeset: Move `Notice` and `Tooltip` components to UI package

* Feedback @dwiley-akamai: consolidate imports and rename icon exports

* change: [M3-7337] - change Linode Details Summary VPC IPv4 Text to Copy Object. (linode#11172)

* change: [M3-7337] - change Linode Details Summary VPC IPv4 Text to Copy Object.

* Added changeset: change Linode Details Summary VPC IPv4 Text to Copy Object.

* Update changeset description

Co-authored-by: Purvesh Makode <pmakode@akamai.com>

* remove optional chaining

* change Text from "Subnets" to "Subnet"

* remove extra borderTop

* refactor: [M3-7337] - change Linode Details Summary VPC IPv4 Text to Copy Object

* Add descriptive variable name

---------

Co-authored-by: Purvesh Makode <pmakode@akamai.com>

* upcoming: [DI-21814] - ACLP UI - DBaaS instances order by label (linode#11226)

* upcoming: [DI-21814] - DBaaS instances order by label

* upcoming: [DI-21814] - Added changeset

* DI-21814: use map for better readability and optimisations

---------

Co-authored-by: vmangalr <vmangalr@akamai.com>

* UIE-8254: Add tooltip for ipv6 for new db clusters (linode#11231)

* feat: [UIE-8193] - Usable Storage Tooltip for Create/Resize Database table (linode#11232)

* feat: [UIE-8193] - Tooltip for Create/Resize Database table

* feat: [UIE-8193] - Tooltip context for small screens

* feat: [UIE-8193] - Tooltip for Create/Resize Database table (linode#11223)

* feat: [UIE-8193] - Tooltip for Create/Resize Database table

* Added changeset: Tooltip for 'Usable Storage' in Create/Resize Database Table

* feat: [UIE-8193] - Tooltip context for small screens

* DBaaS additions

* GPU egress transfer copy update (linode#11235)

* default behavior when creating new child clusters should match what existed before we enabled IPACL (in other words: disabled by default) (linode#11234)

Co-authored-by: Talmai Oliveira <toliveir@akamai.com>

* Update PULL_REQUEST_TEMPLATE.md (linode#11219)

* change: [M3-8860] - Update unit testing docs to prefer `userEvent` over `fireEvent` (linode#11221)

* Update 08-testing.md for userEvent

* Fix typo

* Address feedback; also further clean up linting issues the doc

* Fix a bad test that was not following good practices

* Added changeset: Update developer docs on unit testing user events

* Update changelog

* Fix LKE create ACL tests (linode#11237)

* feat: [M3-8665] - add option to copy token in LKE details page. (linode#11179)

* feat: [M3-8665] - add option to copy token in LKE details page.

* Added changeset: option to copy token in LKE details page

* Change the "Copy Token" button to use asynchronous functionality

* remove extra styling

* refactor: [M3-8665] - add option to copy token in LKE details page.

* Change cypress test for LKE update spec

* fix: sx styling for Textfield component (linode#11246)

* spread containerProps sx

* spread props.sx as well whoops

* fix: [M3-8894] - Linode Create crash when selected a Linode with a `type` that is `null` (linode#11247)

* don't fetch when `type` is an empty string

* fix and changelog entry

---------

Co-authored-by: Banks Nussman <banks@nussman.us>

* change: [M3-8857] - Update PULL_REQUEST_TEMPLATE (Part 2) (linode#11236)

* Make updates discussed to PR template during retro

* Add changeset

* refactor: [M3-8900] - Move `RadioGroup` to `@linode/ui` package (linode#11254)

* Move RadioGroup to ui package

* Added changeset: Move `RadioGroup` from `manager` to `ui` package

---------

Co-authored-by: corya-akamai <136115382+corya-akamai@users.noreply.github.com>
Co-authored-by: Alban Bailly <130582365+abailly-akamai@users.noreply.github.com>
Co-authored-by: Hana Xu <115299789+hana-akamai@users.noreply.github.com>
Co-authored-by: Harsh Shankar Rao <hrao@akamai.com>
Co-authored-by: Jaalah Ramos <jaalah.ramos@gmail.com>
Co-authored-by: rodonnel-akamai <rodonnel@akamai.com>
Co-authored-by: Banks Nussman <115251059+bnussman-akamai@users.noreply.github.com>
Co-authored-by: Banks Nussman <banks@nussman.us>
Co-authored-by: venkatmano-akamai <chk-Venkatesh@outlook.com>
Co-authored-by: vmangalr <vmangalr@akamai.com>
Co-authored-by: Connie Liu <139280159+coliu-akamai@users.noreply.github.com>
Co-authored-by: Hussain Khalil <122488130+hkhalil-akamai@users.noreply.github.com>
Co-authored-by: hasyed-akamai <hasyed@akamai.com>
Co-authored-by: Purvesh Makode <pmakode@akamai.com>
Co-authored-by: ankitaakamai <ankitaan@akamai.com>
Co-authored-by: mpolotsk-akamai <157619599+mpolotsk-akamai@users.noreply.github.com>
Co-authored-by: Talmai Oliveira <to@talm.ai>
Co-authored-by: Talmai Oliveira <toliveir@akamai.com>
Co-authored-by: John Callahan <114753608+jcallahan-akamai@users.noreply.github.com>
Co-authored-by: Mariah Jacobs <114685994+mjac0bs@users.noreply.github.com>
Co-authored-by: jdamore-linode <97627410+jdamore-linode@users.noreply.github.com>
Co-authored-by: Hana Xu <hxu@akamai.com>

* upcoming:  [DI-21694] - Added changesets

* upcoming : [DI-21694] - Addressed the review comments

* upcoming: [DI-21694] - Fixed the type safety issue for the AlertSeveritySelect component

* upcoming: [DI-21694] - Fixed the dependency if Button component that was failing the test

---------

Co-authored-by: corya-akamai <136115382+corya-akamai@users.noreply.github.com>
Co-authored-by: Alban Bailly <130582365+abailly-akamai@users.noreply.github.com>
Co-authored-by: Hana Xu <115299789+hana-akamai@users.noreply.github.com>
Co-authored-by: Harsh Shankar Rao <hrao@akamai.com>
Co-authored-by: Jaalah Ramos <jaalah.ramos@gmail.com>
Co-authored-by: rodonnel-akamai <rodonnel@akamai.com>
Co-authored-by: Banks Nussman <115251059+bnussman-akamai@users.noreply.github.com>
Co-authored-by: Banks Nussman <banks@nussman.us>
Co-authored-by: venkatmano-akamai <chk-Venkatesh@outlook.com>
Co-authored-by: vmangalr <vmangalr@akamai.com>
Co-authored-by: Connie Liu <139280159+coliu-akamai@users.noreply.github.com>
Co-authored-by: Hussain Khalil <122488130+hkhalil-akamai@users.noreply.github.com>
Co-authored-by: hasyed-akamai <hasyed@akamai.com>
Co-authored-by: Purvesh Makode <pmakode@akamai.com>
Co-authored-by: ankitaakamai <ankitaan@akamai.com>
Co-authored-by: mpolotsk-akamai <157619599+mpolotsk-akamai@users.noreply.github.com>
Co-authored-by: Talmai Oliveira <to@talm.ai>
Co-authored-by: Talmai Oliveira <toliveir@akamai.com>
Co-authored-by: John Callahan <114753608+jcallahan-akamai@users.noreply.github.com>
Co-authored-by: Mariah Jacobs <114685994+mjac0bs@users.noreply.github.com>
Co-authored-by: jdamore-linode <97627410+jdamore-linode@users.noreply.github.com>
Co-authored-by: Hana Xu <hxu@akamai.com>
  • Loading branch information
1 parent f73af31 commit 65a19f9
Show file tree
Hide file tree
Showing 19 changed files with 543 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/api-v4": Upcoming Features
---

Add POST request endpoint for create alert in `alerts.ts`, add Alert, CreateAlertPayload types that are relevant for the Create Alert workflow ([#11255](https://github.com/linode/manager/pull/11255))
11 changes: 11 additions & 0 deletions packages/api-v4/src/cloudpulse/alerts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createAlertDefinitionSchema } from '@linode/validation';
import Request, { setURL, setMethod, setData } from '../request';
import { Alert, CreateAlertDefinitionPayload } from './types';
import { BETA_API_ROOT as API_ROOT } from 'src/constants';

export const createAlertDefinition = (data: CreateAlertDefinitionPayload) =>
Request<Alert>(
setURL(`${API_ROOT}/monitor/alert-definitions`),
setMethod('POST'),
setData(data, createAlertDefinitionSchema)
);
2 changes: 2 additions & 0 deletions packages/api-v4/src/cloudpulse/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ export * from './types';
export * from './dashboards';

export * from './services';

export * from './alerts';
72 changes: 72 additions & 0 deletions packages/api-v4/src/cloudpulse/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
export type AlertSeverityType = 0 | 1 | 2 | 3 | null;
type MetricAggregationType = 'avg' | 'sum' | 'min' | 'max' | 'count' | null;
type MetricOperatorType = 'eq' | 'gt' | 'lt' | 'gte' | 'lte' | null;
type DimensionFilterOperatorType =
| 'eq'
| 'neq'
| 'startswith'
| 'endswith'
| null;
type AlertDefinitionType = 'default' | 'custom';
type AlertStatusType = 'enabled' | 'disabled';
export interface Dashboard {
id: number;
label: string;
Expand Down Expand Up @@ -132,3 +143,64 @@ export interface ServiceTypes {
export interface ServiceTypesList {
data: ServiceTypes[];
}

export interface CreateAlertDefinitionPayload {
label: string;
description?: string;
resource_ids?: string[];
severity: AlertSeverityType;
rule_criteria: {
rules: MetricCriteria[];
};
triggerCondition: TriggerCondition;
channel_ids: number[];
}
export interface CreateAlertDefinitionForm
extends CreateAlertDefinitionPayload {
region: string;
service_type: string;
engine_type: string;
}
export interface MetricCriteria {
metric: string;
aggregation_type: MetricAggregationType;
operator: MetricOperatorType;
value: number;
dimension_filters: DimensionFilter[];
}

export interface DimensionFilter {
dimension_label: string;
operator: DimensionFilterOperatorType;
value: string;
}

export interface TriggerCondition {
polling_interval_seconds: number;
evaluation_period_seconds: number;
trigger_occurrences: number;
}
export interface Alert {
id: number;
label: string;
description: string;
status: AlertStatusType;
type: AlertDefinitionType;
severity: AlertSeverityType;
service_type: string;
resource_ids: string[];
rule_criteria: {
rules: MetricCriteria[];
};
triggerCondition: TriggerCondition;
channels: {
id: string;
label: string;
url: string;
type: 'channel';
}[];
created_by: string;
updated_by: string;
created: string;
updated: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

Add Create Alert Button, Add Name, Description, Severity components to the Create Alert Form ([#11255](https://github.com/linode/manager/pull/11255))
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Paper } from '@linode/ui';
import * as React from 'react';
import { Route, Switch } from 'react-router-dom';

import { Paper } from '@linode/ui';
import { Typography } from 'src/components/Typography';

import { CreateAlertDefinition } from '../CreateAlert/CreateAlertDefinition';

export const AlertDefinitionLanding = () => {
return (
<Switch>
Expand All @@ -12,6 +14,10 @@ export const AlertDefinitionLanding = () => {
exact
path="/monitor/cloudpulse/alerts/definitions"
/>
<Route
component={() => <CreateAlertDefinition />}
path="/monitor/cloudpulse/alerts/definitions/create"
/>
</Switch>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Button } from '@linode/ui';
import { Box, Paper } from '@linode/ui';
import * as React from 'react';
import {
Redirect,
Route,
Switch,
useHistory,
useLocation,
useRouteMatch,
} from 'react-router-dom';
Expand All @@ -20,6 +22,7 @@ export const AlertsLanding = React.memo(() => {
const flags = useFlags();
const { url } = useRouteMatch();
const { pathname } = useLocation();
const history = useHistory();
const alertTabs = React.useMemo<EnabledAlertTab[]>(
() => [
{
Expand All @@ -44,9 +47,17 @@ export const AlertsLanding = React.memo(() => {
),
[accessibleTabs, pathname]
);
const handleChange = (index: number) => {
history.push(alertTabs[index].tab.routeName);
};

return (
<Paper sx={{ padding: 2 }}>
<Tabs index={activeTabIndex} style={{ width: '100%' }}>
<Tabs
index={activeTabIndex}
onChange={handleChange}
sx={{ width: '100%' }}
>
<Box
sx={{
aligneItems: 'center',
Expand All @@ -57,6 +68,19 @@ export const AlertsLanding = React.memo(() => {
}}
>
<TabLinkList tabs={accessibleTabs} />
{pathname === `${url}/definitions` && (
<Box>
<Button
onClick={() => {
history.push(`${url}/definitions/create`);
}}
buttonType="primary"
variant="contained"
>
Create
</Button>
</Box>
)}
</Box>
<Switch>
<Route
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { fireEvent, screen, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import * as React from 'react';

import { renderWithTheme } from 'src/utilities/testHelpers';

import { CreateAlertDefinition } from './CreateAlertDefinition';
describe('AlertDefinition Create', () => {
it('should render input components', () => {
const { getByLabelText } = renderWithTheme(<CreateAlertDefinition />);

expect(getByLabelText('Name')).toBeVisible();
expect(getByLabelText('Description (optional)')).toBeVisible();
expect(getByLabelText('Severity')).toBeVisible();
});
it('should be able to enter a value in the textbox', () => {
const { getByLabelText } = renderWithTheme(<CreateAlertDefinition />);
const input = getByLabelText('Name');

fireEvent.change(input, { target: { value: 'text' } });
const specificInput = within(screen.getByTestId('alert-name')).getByTestId(
'textfield-input'
);
expect(specificInput).toHaveAttribute('value', 'text');
});
it('should render client side validation errors', async () => {
const { getByText } = renderWithTheme(<CreateAlertDefinition />);

const submitButton = getByText('Submit').closest('button');

await userEvent.click(submitButton!);

expect(getByText('Name is required')).toBeVisible();
expect(getByText('Severity is required')).toBeVisible();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
import { yupResolver } from '@hookform/resolvers/yup';
import { Paper } from '@linode/ui';
import { createAlertDefinitionSchema } from '@linode/validation';
import { useSnackbar } from 'notistack';
import * as React from 'react';
import { Controller, FormProvider, useForm } from 'react-hook-form';
import { useHistory } from 'react-router-dom';

import { ActionsPanel } from 'src/components/ActionsPanel/ActionsPanel';
import { Breadcrumb } from 'src/components/Breadcrumb/Breadcrumb';
import { TextField } from 'src/components/TextField';
import { Typography } from 'src/components/Typography';
import { useCreateAlertDefinition } from 'src/queries/cloudpulse/alerts';

import { CloudPulseAlertSeveritySelect } from './GeneralInformation/AlertSeveritySelect';

import type {
CreateAlertDefinitionForm,
CreateAlertDefinitionPayload,
MetricCriteria,
TriggerCondition,
} from '@linode/api-v4/lib/cloudpulse/types';

const triggerConditionInitialValues: TriggerCondition = {
evaluation_period_seconds: 0,
polling_interval_seconds: 0,
trigger_occurrences: 0,
};
const criteriaInitialValues: MetricCriteria[] = [
{
aggregation_type: null,
dimension_filters: [],
metric: '',
operator: null,
value: 0,
},
];
const initialValues: CreateAlertDefinitionForm = {
channel_ids: [],
engine_type: '',
label: '',
region: '',
resource_ids: [],
rule_criteria: { rules: criteriaInitialValues },
service_type: '',
severity: null,
triggerCondition: triggerConditionInitialValues,
};

const overrides = [
{
label: 'Definitions',
linkTo: '/monitor/cloudpulse/alerts/definitions',
position: 1,
},
{
label: 'Details',
linkTo: `/monitor/cloudpulse/alerts/definitions/create`,
position: 2,
},
];
export const CreateAlertDefinition = () => {
const history = useHistory();
const alertCreateExit = () =>
history.push('/monitor/cloudpulse/alerts/definitions');

const formMethods = useForm<CreateAlertDefinitionPayload>({
defaultValues: initialValues,
mode: 'onBlur',
resolver: yupResolver(createAlertDefinitionSchema),
});

const { control, formState, handleSubmit, setError } = formMethods;
const { enqueueSnackbar } = useSnackbar();
const { mutateAsync: createAlert } = useCreateAlertDefinition();

const onSubmit = handleSubmit(async (values) => {
try {
await createAlert(values);
enqueueSnackbar('Alert successfully created', {
variant: 'success',
});
alertCreateExit();
} catch (errors) {
for (const error of errors) {
if (error.field) {
setError(error.field, { message: error.reason });
} else {
setError('root', { message: error.reason });
}
}
}
});

return (
<Paper sx={{ paddingLeft: 1, paddingRight: 1, paddingTop: 2 }}>
<Breadcrumb crumbOverrides={overrides} pathname="/Definitions/Create" />
<FormProvider {...formMethods}>
<form onSubmit={onSubmit}>
<Typography marginTop={2} variant="h2">
1. General Information
</Typography>
<Controller
render={({ field, fieldState }) => (
<TextField
data-testid="alert-name"
errorText={fieldState.error?.message}
label="Name"
name="label"
onBlur={field.onBlur}
onChange={(e) => field.onChange(e.target.value)}
placeholder="Enter Name"
value={field.value ?? ''}
/>
)}
control={control}
name="label"
/>
<Controller
render={({ field, fieldState }) => (
<TextField
errorText={fieldState.error?.message}
label="Description"
name="description"
onBlur={field.onBlur}
onChange={(e) => field.onChange(e.target.value)}
optional
placeholder="Enter Description"
value={field.value ?? ''}
/>
)}
control={control}
name="description"
/>
<CloudPulseAlertSeveritySelect name="severity" />
<ActionsPanel
primaryButtonProps={{
label: 'Submit',
loading: formState.isSubmitting,
type: 'submit',
}}
secondaryButtonProps={{
label: 'Cancel',
onClick: alertCreateExit,
}}
sx={{ display: 'flex', justifyContent: 'flex-end' }}
/>
</form>
</FormProvider>
</Paper>
);
};
Loading

0 comments on commit 65a19f9

Please sign in to comment.