Skip to content

Commit

Permalink
Mobile push dynamic setting (#1967)
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantinov-Innokentii authored May 18, 2023
1 parent 11abfc3 commit ac2f6ed
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
8 changes: 8 additions & 0 deletions engine/apps/api/views/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,12 @@ def _get_enabled_features(self, request):
if is_webhooks_enabled_for_organization(request.auth.organization.pk):
enabled_features.append(FEATURE_WEBHOOKS2)

enabled_mobile_test_push = DynamicSetting.objects.get_or_create(
name="enabled_mobile_test_push",
defaults={"boolean_value": False},
)[0]

if enabled_mobile_test_push.boolean_value:
enabled_features.append(FEATURE_MOBILE_TEST_PUSH)

return enabled_features
Original file line number Diff line number Diff line change
Expand Up @@ -200,28 +200,26 @@ const MobileAppConnection = observer(({ userPk }: Props) => {
{content}
</Block>
</div>
{false && // temporary disable test notifications
mobileAppIsCurrentlyConnected &&
isCurrentUser && (
<div className={cx('notification-buttons')}>
<HorizontalGroup spacing={'md'} justify={'flex-end'}>
<Button
variant="secondary"
onClick={() => onSendTestNotification()}
disabled={isAttemptingTestNotification}
>
Send Test Push notification
</Button>
<Button
variant="destructive"
onClick={() => onSendTestNotification(true)}
disabled={isAttemptingTestNotification}
>
Send Critical Test Push notification
</Button>
</HorizontalGroup>
</div>
)}
{store.hasFeature(AppFeature.MobileTestPush) && mobileAppIsCurrentlyConnected && isCurrentUser && (
<div className={cx('notification-buttons')}>
<HorizontalGroup spacing={'md'} justify={'flex-end'}>
<Button
variant="secondary"
onClick={() => onSendTestNotification()}
disabled={isAttemptingTestNotification}
>
Send Test Push notification
</Button>
<Button
variant="destructive"
onClick={() => onSendTestNotification(true)}
disabled={isAttemptingTestNotification}
>
Send Critical Test Push notification
</Button>
</HorizontalGroup>
</div>
)}
</VerticalGroup>
</WithPermissionControlDisplay>
);
Expand Down
1 change: 1 addition & 0 deletions grafana-plugin/src/state/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export enum AppFeature {
CloudConnection = 'grafana_cloud_connection',
WebSchedules = 'web_schedules',
Webhooks2 = 'webhooks2',
MobileTestPush = 'mobile_test_push',
}

0 comments on commit ac2f6ed

Please sign in to comment.