Skip to content

Commit b895477

Browse files
authored
fix: disable version info for control plane, add sync for tenant alerting settings (#3659)
* fix: disable version info for control plane, add sync for tenant alerting settings * fix: on conflict for alerting settings
1 parent b39548c commit b895477

4 files changed

Lines changed: 54 additions & 0 deletions

File tree

frontend/app/src/pages/main/info/components/version-info.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
import { Spinner } from '@/components/v1/ui/loading';
22
import useCloud from '@/hooks/use-cloud';
3+
import useControlPlane from '@/hooks/use-control-plane';
34
import { queries } from '@/lib/api';
45
import { useQuery } from '@tanstack/react-query';
56
import React from 'react';
67

78
export const VersionInfo: React.FC = () => {
9+
const { isControlPlaneEnabled } = useControlPlane();
810
const { data, isLoading, isError, error } = useQuery({
911
...queries.info.getVersion,
12+
enabled: !isControlPlaneEnabled,
1013
});
1114

1215
const { isCloudEnabled } = useCloud();
1316

17+
if (isControlPlaneEnabled) {
18+
return null;
19+
}
20+
1421
if (isLoading) {
1522
return (
1623
<div className="flex items-center justify-center">

pkg/repository/sqlcv1/sync.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,11 @@ SET
147147
"role" = @role::"TenantMemberRole"
148148
WHERE "id" = @id::uuid
149149
RETURNING *;
150+
151+
-- name: SyncUpsertTenantAlertingSettings :one
152+
INSERT INTO "TenantAlertingSettings" ("id", "tenantId")
153+
VALUES (@id::uuid, @tenantId::uuid)
154+
ON CONFLICT ("id") DO UPDATE
155+
-- dummy update to avoid "ON CONFLICT DO NOTHING" which doesn't return the row
156+
SET "tenantId" = EXCLUDED."tenantId"
157+
RETURNING *;

pkg/repository/sqlcv1/sync.sql.go

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/repository/sync.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ type SyncRepository interface {
4040
SyncUpsertTenantMember(ctx context.Context, db sqlcv1.DBTX, arg sqlcv1.SyncUpsertTenantMemberParams) (*sqlcv1.TenantMember, error)
4141
SyncUpdateTenantMember(ctx context.Context, db sqlcv1.DBTX, arg sqlcv1.SyncUpdateTenantMemberParams) (*sqlcv1.TenantMember, error)
4242
SyncDeleteTenantMember(ctx context.Context, db sqlcv1.DBTX, id uuid.UUID) error
43+
44+
SyncUpsertTenantAlertingSettings(ctx context.Context, db sqlcv1.DBTX, arg sqlcv1.SyncUpsertTenantAlertingSettingsParams) (*sqlcv1.TenantAlertingSettings, error)
4345
}
4446

4547
type syncRepository struct {
@@ -99,3 +101,7 @@ func (r *syncRepository) SyncUpdateTenantMember(ctx context.Context, db sqlcv1.D
99101
func (r *syncRepository) SyncDeleteTenantMember(ctx context.Context, db sqlcv1.DBTX, id uuid.UUID) error {
100102
return r.queries.DeleteTenantMember(ctx, db, id)
101103
}
104+
105+
func (r *syncRepository) SyncUpsertTenantAlertingSettings(ctx context.Context, db sqlcv1.DBTX, arg sqlcv1.SyncUpsertTenantAlertingSettingsParams) (*sqlcv1.TenantAlertingSettings, error) {
106+
return r.queries.SyncUpsertTenantAlertingSettings(ctx, db, arg)
107+
}

0 commit comments

Comments
 (0)