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

v1.8.1 #4630

Merged
merged 9 commits into from
Jul 8, 2024
Merged

v1.8.1 #4630

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 Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ docker_build_sub(
"localhost:63628/oncall/engine:dev",
context="./engine",
cache_from=["grafana/oncall:latest", "grafana/oncall:dev"],
ignore=["./test-results/", "./grafana-plugin/dist/", "./grafana-plugin/e2e-tests/"],
ignore=["./test-results/", "./grafana-plugin/dist/", "./grafana-plugin/e2e-tests/", "./grafana-plugin/node_modules/"],
child_context=".",
target="dev",
extra_cmds=["ADD ./grafana-plugin/src/plugin.json /etc/grafana-plugin/src/plugin.json"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The above command returns JSON structured in the following way:
| ----------- | :------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `user_id` | Yes | User ID |
| `position` | Optional | Personal notification rules execute one after another starting from `position=0`. `Position=-1` will put the escalation policy to the end of the list. A new escalation policy created with a position of an existing escalation policy will move the old one (and all following) down on the list. |
| `type` | Yes | One of: `wait`, `notify_by_slack`, `notify_by_sms`, `notify_by_phone_call`, `notify_by_telegram`, `notify_by_email`, `notify_by_mobile_app`, `notify_by_mobile_app_critical`. |
| `type` | Yes | One of: `wait`, `notify_by_slack`, `notify_by_sms`, `notify_by_phone_call`, `notify_by_telegram`, `notify_by_email`, `notify_by_mobile_app`, `notify_by_mobile_app_critical`, or `notify_by_msteams` (**NOTE** `notify_by_msteams` is only available on Grafana Cloud). |
| `duration` | Optional | A time in seconds to wait (when `type=wait`). Can be one of 60, 300, 900, 1800, or 3600. |
| `important` | Optional | Boolean value indicates if a rule is "important". Default is `false`. |

Expand Down
10 changes: 6 additions & 4 deletions engine/apps/alerts/tasks/notify_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ def notify_user_task(

# Here we collect a brief overview of notification steps configured for user to send it to thread.
collected_steps_ids = []
for notification_policy in notification_policies:
if notification_policy.step == UserNotificationPolicy.Step.NOTIFY:
if notification_policy.notify_by not in collected_steps_ids:
collected_steps_ids.append(notification_policy.notify_by)
for next_notification_policy in notification_policies:
if next_notification_policy.step == UserNotificationPolicy.Step.NOTIFY:
if next_notification_policy.notify_by not in collected_steps_ids:
collected_steps_ids.append(next_notification_policy.notify_by)

notification_policy = notification_policies[0]

collected_steps = ", ".join(
UserNotificationPolicy.NotificationChannel(step_id).label for step_id in collected_steps_ids
Expand Down
41 changes: 41 additions & 0 deletions engine/apps/api/views/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ class UserView(
"send_test_sms": [RBACPermission.Permissions.USER_SETTINGS_WRITE],
"export_token": [RBACPermission.Permissions.USER_SETTINGS_WRITE],
"upcoming_shifts": [RBACPermission.Permissions.USER_SETTINGS_READ],
"filters": [RBACPermission.Permissions.USER_SETTINGS_READ],
}

rbac_object_permissions = {
Expand Down Expand Up @@ -846,6 +847,46 @@ def export_token(self, request, pk) -> Response:
return Response(status=status.HTTP_204_NO_CONTENT)
return Response(status=status.HTTP_405_METHOD_NOT_ALLOWED)

@extend_schema(
responses=inline_serializer(
name="UserFilters",
fields={
"name": serializers.CharField(),
"type": serializers.CharField(),
"href": serializers.CharField(required=False),
"global": serializers.BooleanField(required=False),
"default": serializers.JSONField(required=False),
"description": serializers.CharField(required=False),
"options": inline_serializer(
name="UserFiltersOptions",
fields={
"value": serializers.CharField(),
"display_name": serializers.IntegerField(),
},
),
},
many=True,
)
)
@action(methods=["get"], detail=False)
def filters(self, request):
filter_name = request.query_params.get("search", None)
api_root = "/api/internal/v1/"

filter_options = [
{
"name": "team",
"type": "team_select",
"href": api_root + "teams/",
"global": True,
},
]

if filter_name is not None:
filter_options = list(filter(lambda f: filter_name in f["name"], filter_options))

return Response(filter_options)


def handle_phone_notificator_failed(exc: BaseFailed) -> Response:
if exc.graceful_msg:
Expand Down
2 changes: 1 addition & 1 deletion engine/apps/chatops_proxy/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def start_sync_org_with_chatops_proxy():
organization_qs = Organization.objects.all()
organization_pks = organization_qs.values_list("pk", flat=True)

max_countdown = 60 * 30 # 30 minutes, feel free to adjust
max_countdown = 12 * 60 * 60 # 12 hours, feel free to adjust
for idx, organization_pk in enumerate(organization_pks):
countdown = idx % max_countdown
sync_org_with_chatops_proxy.apply_async(kwargs={"org_id": organization_pk}, countdown=countdown)
Expand Down
8 changes: 7 additions & 1 deletion engine/apps/email/inbound.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,13 @@ def get_integration_token_from_request(self, request) -> Optional[str]:
# First try envelope_recipient field.
# According to AnymailInboundMessage it's provided not by all ESPs.
if message.envelope_recipient:
token, domain = message.envelope_recipient.split("@")
try:
token, domain = message.envelope_recipient.split("@")
except ValueError:
logger.error(
f"get_integration_token_from_request: envelope_recipient field has unexpected format: {message.envelope_recipient}"
)
return None
if domain == live_settings.INBOUND_EMAIL_DOMAIN:
return token
else:
Expand Down
4 changes: 2 additions & 2 deletions engine/settings/celery_task_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@
"apps.chatops_proxy.tasks.unlink_slack_team_async": {"queue": "default"},
"apps.chatops_proxy.tasks.register_oncall_tenant_async": {"queue": "default"},
"apps.chatops_proxy.tasks.unregister_oncall_tenant_async": {"queue": "default"},
"apps.chatops_proxy.tasks.start_sync_org_with_chatops_proxy": {"queue": "default"},
"apps.chatops_proxy.tasks.sync_org_with_chatops_proxy": {"queue": "default"},
# CRITICAL
"apps.alerts.tasks.acknowledge_reminder.acknowledge_reminder_task": {"queue": "critical"},
"apps.alerts.tasks.acknowledge_reminder.unacknowledge_timeout_task": {"queue": "critical"},
Expand Down Expand Up @@ -141,6 +139,8 @@
"apps.alerts.tasks.check_escalation_finished.check_escalation_finished_task": {"queue": "long"},
"apps.alerts.tasks.check_escalation_finished.check_alert_group_personal_notifications_task": {"queue": "long"},
"apps.alerts.tasks.check_escalation_finished.check_personal_notifications_task": {"queue": "long"},
"apps.chatops_proxy.tasks.start_sync_org_with_chatops_proxy": {"queue": "long"},
"apps.chatops_proxy.tasks.sync_org_with_chatops_proxy": {"queue": "long"},
"apps.grafana_plugin.tasks.sync.cleanup_organization_async": {"queue": "long"},
"apps.grafana_plugin.tasks.sync.cleanup_empty_deleted_integrations": {"queue": "long"},
"apps.grafana_plugin.tasks.sync.start_cleanup_organizations": {"queue": "long"},
Expand Down
10 changes: 7 additions & 3 deletions grafana-plugin/e2e-tests/users/usersActions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ test.describe('Users screen actions', () => {

await page.waitForTimeout(2000);

const searchInput = page.locator(`[data-testid="search-users"]`);

await searchInput.fill(userName);
await page
.locator('div')
.filter({ hasText: /^Search or filter results\.\.\.$/ })
.nth(1)
.click();
await page.keyboard.insertText(userName);
await page.keyboard.press('Enter');
await page.waitForTimeout(2000);

const result = page.locator(`[data-testid="users-username"]`);
Expand Down
21 changes: 8 additions & 13 deletions grafana-plugin/src/components/GTable/GTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface GTableProps<RecordType = unknown> extends TableProps<RecordType
expandable?: {
expandedRowKeys: string[];
expandedRowRender: (item: any) => React.ReactNode;
onExpandedRowsChange: (rows: string[]) => void;
onExpandedRowsChange?: (rows: string[]) => void;
expandRowByClick: boolean;
expandIcon?: (props: { expanded: boolean; record: any }) => React.ReactNode;
onExpand?: (expanded: boolean, item: any) => void;
Expand Down Expand Up @@ -47,7 +47,7 @@ export const GTable = <RT extends DefaultRecordType = DefaultRecordType>(props:
const { expanded, record } = props;
return (
<Icon
style={{ cursor: 'pointer' }}
className={styles.expandIcon}
name={expanded ? 'angle-down' : 'angle-right'}
onClick={(event) => {
event.stopPropagation();
Expand All @@ -61,8 +61,8 @@ export const GTable = <RT extends DefaultRecordType = DefaultRecordType>(props:
newExpandedRowKeys.splice(index, 1);
}

expandable.onExpand && expandable.onExpand(newExpanded, record);
expandable.onExpandedRowsChange(newExpandedRowKeys);
expandable.onExpand?.(newExpanded, record);
expandable.onExpandedRowsChange?.(newExpandedRowKeys);
}}
/>
);
Expand Down Expand Up @@ -135,7 +135,7 @@ export const GTable = <RT extends DefaultRecordType = DefaultRecordType>(props:
}, [rowSelection, columnsProp, data]);

return (
<div className={cx(styles.root, { [styles.fixed]: props.tableLayout === 'fixed' })} data-testid="test__gTable">
<div className={styles.root} data-testid="test__gTable">
<Table<RT>
expandable={expandable}
rowKey={rowKey}
Expand All @@ -161,18 +161,13 @@ const getGTableStyles = () => ({
width: 100%;
}
`,

fixed: css`
table {
table-layout: fixed;
}
`,

pagination: css`
margin-top: 20px;
`,

checkbox: css`
display: inline-flex;
`,
expandIcon: css`
cursor: pointer;
`,
});
4 changes: 2 additions & 2 deletions grafana-plugin/src/components/Policy/EscalationPolicy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ class _EscalationPolicy extends React.Component<EscalationPolicyProps, any> {
<Select
menuShouldPortal
disabled={isDisabled}
placeholder="Select Wait Delay"
placeholder="Select or type"
className={cx(styles.select, styles.control)}
value={waitDelayInSeconds ? waitDelayOptionItem : undefined}
onChange={(option: SelectableValue) =>
Expand Down Expand Up @@ -335,7 +335,7 @@ class _EscalationPolicy extends React.Component<EscalationPolicyProps, any> {
<Select
menuShouldPortal
disabled={isDisabled}
placeholder="Period"
placeholder="Select or type"
className={cx(styles.select, styles.control)}
value={num_minutes_in_window ? optionValue : undefined}
onChange={this.getOnSelectChangeHandler('num_minutes_in_window')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ export class NotificationPolicy extends React.Component<NotificationPolicyProps,
<div className={this.styles.container}>
<Select
key="wait-delay"
placeholder="Wait Delay"
className={cx(this.styles.delay, this.styles.control)}
value={wait_delay ? optionValue : undefined}
disabled={disabled}
Expand Down
2 changes: 1 addition & 1 deletion grafana-plugin/src/components/Policy/Policy.consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ export const POLICY_DURATION_LIST_MINUTES: SelectableValue[] = [...POLICY_DURATI
export const CUSTOM_SILENCE_VALUE = -100;

export const SILENCE_DURATION_LIST: SelectableValue[] = [
{ value: CUSTOM_SILENCE_VALUE, label: 'Custom' },
{ value: 30 * 60, label: '30 minutes' },
{ value: 1 * 60 * 60, label: '1 hour' },
{ value: 2 * 60 * 60, label: '2 hours' },
{ value: 6 * 60 * 60, label: '6 hours' },
{ value: 12 * 60 * 60, label: '12 hours' },
{ value: 24 * 60 * 60, label: '24 hours' },
{ value: -1, label: 'Forever' },
{ value: CUSTOM_SILENCE_VALUE, label: 'Custom' },
];
54 changes: 0 additions & 54 deletions grafana-plugin/src/components/Table/Table.styles.ts

This file was deleted.

74 changes: 0 additions & 74 deletions grafana-plugin/src/components/Table/Table.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ function prepareForSave(rawData: Partial<ApiSchemas['Webhook']>, selectedPreset:
delete data[field];
});

if (data.forward_all) {
data.data = null;
}

return data;
}

Expand Down
Loading
Loading