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
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' | 'nodebalancer';
export type AlertServiceType = 'dbaas' | 'firewall' | 'linode' | 'nodebalancer';
export type MetricsServiceType =
| 'dbaas'
| 'firewall'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ import {
} from '../Utils/AlertResourceUtils';
import { AlertSelectedInfoNotice } from '../Utils/AlertSelectedInfoNotice';
import { AlertResourcesFilterRenderer } from './AlertsResourcesFilterRenderer';
import { databaseTypeClassMap, serviceToFiltersMap } from './constants';
import {
databaseTypeClassMap,
getSearchPlaceholderText,
serviceToFiltersMap,
} from './constants';
import { DisplayAlertResources } from './DisplayAlertResources';

import type { SelectDeselectAll } from '../constants';
Expand Down Expand Up @@ -380,9 +384,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 @@ -72,6 +72,13 @@ export const serviceTypeBasedColumns: ServiceColumns<AlertInstance> = {
sortingKey: 'tags',
},
],
firewall: [
{
accessor: ({ label }) => label,
label: 'Entity',
sortingKey: 'label',
},
],
};

export const serviceToFiltersMap: Record<
Expand All @@ -88,6 +95,7 @@ export const serviceToFiltersMap: Record<
{ component: AlertsRegionFilter, filterKey: 'region' },
{ component: AlertsTagFilter, filterKey: 'tags' },
],
firewall: [],
};

export const applicableAdditionalFilterKeys: AlertAdditionalFilterKey[] = [
Expand All @@ -109,3 +117,17 @@ 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((f) => f.filterKey === 'region');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
const hasRegionFilter = filters.some((f) => f.filterKey === 'region');
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 @@ -179,7 +179,7 @@ export const alertDefinitionFormSchema = createAlertDefinitionSchema.concat(
.min(1, 'At least one metric criteria is required.'),
}).required(),
serviceType: string()
.oneOf(['linode', 'dbaas', 'nodebalancer'])
.oneOf(['linode', 'dbaas', 'firewall', 'nodebalancer'])
.required(fieldErrorMessage)
.nullable()
.test('nonNull', fieldErrorMessage, (value) => value !== null),
Expand Down
11 changes: 2 additions & 9 deletions packages/manager/src/queries/cloudpulse/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import {
getCloudPulseServiceTypes,
getDashboardById,
getDashboards,
getFirewalls,
getJWEToken,
getMetricDefinitionsByServiceType,
} from '@linode/api-v4';
import {
databaseQueries,
firewallQueries,
getAllLinodesRequest,
nodebalancerQueries,
volumeQueries,
Expand Down Expand Up @@ -115,14 +115,7 @@ export const queryFactory = createQueryKeys(key, {
case 'dbaas':
return databaseQueries.databases._ctx.all(params, filters);
case 'firewall':
return {
queryFn: async () => {
const response = await getFirewalls(params, filters);
return response.data;
},
queryKey: ['firewalls', params, filters],
};

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