Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/api-v4": Upcoming Features
---

ACLP-Alerting: added firewall to AlertServiceType for Alerts onboarding ([#12550](https://github.com/linode/manager/pull/12550))
2 changes: 1 addition & 1 deletion packages/api-v4/src/cloudpulse/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { AccountCapability } from 'src/account';
export type AlertSeverityType = 0 | 1 | 2 | 3;
export type MetricAggregationType = 'avg' | 'count' | 'max' | 'min' | 'sum';
export type MetricOperatorType = 'eq' | 'gt' | 'gte' | 'lt' | 'lte';
export type AlertServiceType = 'dbaas' | 'linode';
export type AlertServiceType = 'dbaas' | 'firewall' | 'linode';
export type MetricsServiceType = 'dbaas' | 'linode' | 'nodebalancer';
export type AlertClass = 'dedicated' | 'shared';
export type DimensionFilterOperatorType =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

ACLP-Alerting: Firewall onboarding for Alerting service ([#12550](https://github.com/linode/manager/pull/12550))
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ import {
} from '../Utils/AlertResourceUtils';
import { AlertResourcesFilterRenderer } from './AlertsResourcesFilterRenderer';
import { AlertsResourcesNotice } from './AlertsResourcesNotice';
import { databaseTypeClassMap, serviceToFiltersMap } from './constants';
import {
databaseTypeClassMap,
getSearchPlaceholderText,
serviceToFiltersMap,
} from './constants';
import { DisplayAlertResources } from './DisplayAlertResources';

import type { AlertInstance } from './DisplayAlertResources';
Expand Down Expand Up @@ -382,9 +386,9 @@ export const AlertResources = React.memo((props: AlertResourcesProp) => {
<DebouncedSearchTextField
clearable
hideLabel
label="Search for a Region or Entity"
label={getSearchPlaceholderText(serviceType)}
onSearch={handleSearchTextChange}
placeholder="Search for a Region or Entity"
placeholder={getSearchPlaceholderText(serviceType)}
sx={{
maxHeight: '34px',
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ export const serviceTypeBasedColumns: ServiceColumns<AlertInstance> = {
sortingKey: 'region',
},
],
firewall: [
{
accessor: ({ label }) => label,
label: 'Entity',
sortingKey: 'label',
},
],
};

export const serviceToFiltersMap: Record<
Expand All @@ -66,6 +73,7 @@ export const serviceToFiltersMap: Record<
{ component: AlertsRegionFilter, filterKey: 'region' },
],
linode: [{ component: AlertsRegionFilter, filterKey: 'region' }],
firewall: [],
};
export const applicableAdditionalFilterKeys: AlertAdditionalFilterKey[] = [
'engineType', // Extendable in future for filter keys like 'tags', 'plan', etc.
Expand All @@ -86,3 +94,19 @@ export const databaseTypeClassMap: Record<DatabaseTypeClass, string> = {
premium: 'premium',
standard: 'standard',
};

export const getSearchPlaceholderText = (
serviceType: AlertServiceType | undefined
): string => {
const filters = serviceToFiltersMap[serviceType ?? ''] ?? [];

const hasRegionFilter = filters.some(
({ filterKey }) => filterKey === 'region'
);

if (hasRegionFilter) {
return 'Search for a Region or Entity';
}

return 'Search for an Entity';
};
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const alertDefinitionFormSchema = createAlertDefinitionSchema.concat(
.min(1, 'At least one metric criteria is required.'),
}).required(),
serviceType: string()
.oneOf(['linode', 'dbaas'])
.oneOf(['linode', 'dbaas', 'firewall'])
.required(fieldErrorMessage)
.nullable()
.test('nonNull', fieldErrorMessage, (value) => value !== null),
Expand Down
5 changes: 5 additions & 0 deletions packages/manager/src/mocks/serverHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2861,6 +2861,11 @@ export const handlers = [
regions: 'us-iad,us-east',
alert: serviceAlertFactory.build({ scope: ['entity'] }),
}),
serviceTypesFactory.build({
label: 'Firewalls',
service_type: 'firewall',
alert: serviceAlertFactory.build({ scope: ['entity'] }),
}),
],
};

Expand Down
3 changes: 3 additions & 0 deletions packages/manager/src/queries/cloudpulse/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from '@linode/api-v4';
import {
databaseQueries,
firewallQueries,
getAllLinodesRequest,
volumeQueries,
} from '@linode/queries';
Expand Down Expand Up @@ -113,6 +114,8 @@ export const queryFactory = createQueryKeys(key, {
switch (resourceType) {
case 'dbaas':
return databaseQueries.databases._ctx.all(params, filters);
case 'firewall':
return firewallQueries.firewalls._ctx.all;
case 'linode':
return {
queryFn: () => getAllLinodesRequest(params, filters), // since we don't have query factory implementation, in linodes.ts, once it is ready we will reuse that, untill then we will use same query keys
Expand Down