-
Notifications
You must be signed in to change notification settings - Fork 309
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
Maxim/bring heartbeats back to UI #2550
Changes from 8 commits
2141de7
4c71c95
15ce793
6e3ce04
fea5507
e28e413
30c8c89
b0925d8
1675544
c8b3d30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { test, Page, expect, Locator } from '../fixtures'; | ||
|
||
import { generateRandomValue, selectDropdownValue } from '../utils/forms'; | ||
import { createIntegration } from '../utils/integrations'; | ||
|
||
test.describe("updating an integration's heartbeat interval works", async () => { | ||
test.slow(); | ||
|
||
const _openIntegrationSettingsPopup = async (page: Page): Promise<Locator> => { | ||
const integrationSettingsPopupElement = page.getByTestId('integration-settings-context-menu'); | ||
await integrationSettingsPopupElement.click(); | ||
return integrationSettingsPopupElement; | ||
}; | ||
|
||
const _openHeartbeatSettingsForm = async (page: Page) => { | ||
const integrationSettingsPopupElement = await _openIntegrationSettingsPopup(page); | ||
|
||
await integrationSettingsPopupElement.click(); | ||
|
||
await page.getByTestId('integration-heartbeat-settings').click(); | ||
}; | ||
|
||
test('"change heartbeat interval', async ({ adminRolePage: { page } }) => { | ||
const integrationName = generateRandomValue(); | ||
await createIntegration(page, integrationName); | ||
|
||
await _openHeartbeatSettingsForm(page); | ||
|
||
const heartbeatSettingsForm = page.getByTestId('heartbeat-settings-form'); | ||
|
||
const value = '30 minutes'; | ||
|
||
await selectDropdownValue({ | ||
page, | ||
startingLocator: heartbeatSettingsForm, | ||
selectType: 'grafanaSelect', | ||
value, | ||
optionExactMatch: false, | ||
}); | ||
|
||
await heartbeatSettingsForm.getByTestId('update-heartbeat').click(); | ||
|
||
await _openHeartbeatSettingsForm(page); | ||
|
||
const heartbeatIntervalValue = await heartbeatSettingsForm | ||
.locator('div[class*="grafana-select-value-container"] > div[class*="-singleValue"]') | ||
.textContent(); | ||
|
||
expect(heartbeatIntervalValue).toEqual(value); | ||
}); | ||
|
||
test('"send heartbeat', async ({ adminRolePage: { page } }) => { | ||
const integrationName = generateRandomValue(); | ||
await createIntegration(page, integrationName); | ||
|
||
await _openHeartbeatSettingsForm(page); | ||
|
||
const heartbeatSettingsForm = page.getByTestId('heartbeat-settings-form'); | ||
|
||
const endpoint = await heartbeatSettingsForm | ||
.getByTestId('input-wrapper') | ||
.locator('input[class*="input-input"]') | ||
.inputValue(); | ||
|
||
await page.goto(endpoint); | ||
|
||
await page.goBack(); | ||
|
||
const heartbeatBadge = await page.getByTestId('heartbeat-badge'); | ||
|
||
await expect(heartbeatBadge).toHaveClass(/--success/); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.instruction { | ||
ol, | ||
ul { | ||
padding: 0; | ||
margin: 0; | ||
list-style: none; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,11 +91,14 @@ export class AlertReceiveChannelStore extends BaseStore { | |
async loadItem(id: AlertReceiveChannel['id'], skipErrorHandling = false): Promise<AlertReceiveChannel> { | ||
const alertReceiveChannel = await this.getById(id, skipErrorHandling); | ||
|
||
// @ts-ignore | ||
this.items = { | ||
...this.items, | ||
[id]: alertReceiveChannel, | ||
[id]: omit(alertReceiveChannel, 'heartbeat'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we store There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in my mind heartbeat is a separate entity (it even has it's own id and ideally it should have separate endpoint), that's why we have 'models/heartbeat', we need |
||
}; | ||
|
||
this.populateHearbeats([alertReceiveChannel]); | ||
|
||
return alertReceiveChannel; | ||
} | ||
|
||
|
@@ -116,33 +119,9 @@ export class AlertReceiveChannelStore extends BaseStore { | |
), | ||
}; | ||
|
||
this.searchResult = results.map((item: AlertReceiveChannel) => item.id); | ||
|
||
const heartbeats = results.reduce((acc: any, alertReceiveChannel: AlertReceiveChannel) => { | ||
if (alertReceiveChannel.heartbeat) { | ||
acc[alertReceiveChannel.heartbeat.id] = alertReceiveChannel.heartbeat; | ||
} | ||
this.populateHearbeats(results); | ||
|
||
return acc; | ||
}, {}); | ||
|
||
this.rootStore.heartbeatStore.items = { | ||
...this.rootStore.heartbeatStore.items, | ||
...heartbeats, | ||
}; | ||
|
||
const alertReceiveChannelToHeartbeat = results.reduce((acc: any, alertReceiveChannel: AlertReceiveChannel) => { | ||
if (alertReceiveChannel.heartbeat) { | ||
acc[alertReceiveChannel.id] = alertReceiveChannel.heartbeat.id; | ||
} | ||
|
||
return acc; | ||
}, {}); | ||
|
||
this.alertReceiveChannelToHeartbeat = { | ||
...this.alertReceiveChannelToHeartbeat, | ||
...alertReceiveChannelToHeartbeat, | ||
}; | ||
this.searchResult = results.map((item: AlertReceiveChannel) => item.id); | ||
|
||
this.updateCounters(); | ||
|
||
|
@@ -164,13 +143,20 @@ export class AlertReceiveChannelStore extends BaseStore { | |
), | ||
}; | ||
|
||
this.paginatedSearchResult = results.map((item: AlertReceiveChannel) => item.id); | ||
this.populateHearbeats(results); | ||
|
||
this.paginatedSearchResult = { | ||
count, | ||
results: results.map((item: AlertReceiveChannel) => item.id), | ||
}; | ||
|
||
const heartbeats = results.reduce((acc: any, alertReceiveChannel: AlertReceiveChannel) => { | ||
this.updateCounters(); | ||
|
||
return results; | ||
} | ||
|
||
populateHearbeats(alertReceiveChannels: AlertReceiveChannel[]) { | ||
const heartbeats = alertReceiveChannels.reduce((acc: any, alertReceiveChannel: AlertReceiveChannel) => { | ||
if (alertReceiveChannel.heartbeat) { | ||
acc[alertReceiveChannel.heartbeat.id] = alertReceiveChannel.heartbeat; | ||
} | ||
|
@@ -183,22 +169,21 @@ export class AlertReceiveChannelStore extends BaseStore { | |
...heartbeats, | ||
}; | ||
|
||
const alertReceiveChannelToHeartbeat = results.reduce((acc: any, alertReceiveChannel: AlertReceiveChannel) => { | ||
if (alertReceiveChannel.heartbeat) { | ||
acc[alertReceiveChannel.id] = alertReceiveChannel.heartbeat.id; | ||
} | ||
const alertReceiveChannelToHeartbeat = alertReceiveChannels.reduce( | ||
(acc: any, alertReceiveChannel: AlertReceiveChannel) => { | ||
if (alertReceiveChannel.heartbeat) { | ||
acc[alertReceiveChannel.id] = alertReceiveChannel.heartbeat.id; | ||
} | ||
|
||
return acc; | ||
}, {}); | ||
return acc; | ||
}, | ||
{} | ||
); | ||
|
||
this.alertReceiveChannelToHeartbeat = { | ||
...this.alertReceiveChannelToHeartbeat, | ||
...alertReceiveChannelToHeartbeat, | ||
}; | ||
|
||
this.updateCounters(); | ||
|
||
return results; | ||
} | ||
|
||
@action | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This instructions are moved to the docs. No need to add them here as they will be removed from the API https://grafana.com/docs/oncall/latest/integrations/alertmanager/#configuring-oncall-heartbeats-optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed