mirror of https://github.com/buster-so/buster.git
lint build test fixes
This commit is contained in:
parent
55cf4ea98c
commit
0428552454
|
@ -1,9 +1,6 @@
|
||||||
import { getUserOrganizationId, updateReport } from '@buster/database';
|
import { getUserOrganizationId, updateReport } from '@buster/database';
|
||||||
import type { ShareUpdateResponse, UpdateReportResponse } from '@buster/server-shared/reports';
|
import type { ShareUpdateResponse, UpdateReportResponse } from '@buster/server-shared/reports';
|
||||||
import {
|
import { type ShareUpdateRequest, ShareUpdateRequestSchema } from '@buster/server-shared/share';
|
||||||
type ShareUpdateRequest,
|
|
||||||
ShareUpdateRequestSchema,
|
|
||||||
} from '@buster/server-shared/share';
|
|
||||||
import { zValidator } from '@hono/zod-validator';
|
import { zValidator } from '@hono/zod-validator';
|
||||||
import { Hono } from 'hono';
|
import { Hono } from 'hono';
|
||||||
import { HTTPException } from 'hono/http-exception';
|
import { HTTPException } from 'hono/http-exception';
|
||||||
|
@ -45,31 +42,27 @@ async function updateReportShareHandler(
|
||||||
return updatedReport;
|
return updatedReport;
|
||||||
}
|
}
|
||||||
|
|
||||||
const app = new Hono().put(
|
const app = new Hono().put('/', zValidator('json', ShareUpdateRequestSchema), async (c) => {
|
||||||
'/',
|
const reportId = c.req.param('id');
|
||||||
zValidator('json', ShareUpdateRequestSchema),
|
const request = c.req.valid('json');
|
||||||
async (c) => {
|
const user = c.get('busterUser');
|
||||||
const reportId = c.req.param('id');
|
|
||||||
const request = c.req.valid('json');
|
|
||||||
const user = c.get('busterUser');
|
|
||||||
|
|
||||||
if (!reportId) {
|
if (!reportId) {
|
||||||
throw new HTTPException(404, { message: 'Report not found' });
|
throw new HTTPException(404, { message: 'Report not found' });
|
||||||
}
|
|
||||||
|
|
||||||
const userOrg = await getUserOrganizationId(user.id);
|
|
||||||
|
|
||||||
if (!userOrg) {
|
|
||||||
throw new HTTPException(403, { message: 'User is not associated with an organization' });
|
|
||||||
}
|
|
||||||
|
|
||||||
const updatedReport: ShareUpdateResponse = await updateReportShareHandler(reportId, request, {
|
|
||||||
id: user.id,
|
|
||||||
organizationId: userOrg.organizationId,
|
|
||||||
});
|
|
||||||
|
|
||||||
return c.json(updatedReport);
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
const userOrg = await getUserOrganizationId(user.id);
|
||||||
|
|
||||||
|
if (!userOrg) {
|
||||||
|
throw new HTTPException(403, { message: 'User is not associated with an organization' });
|
||||||
|
}
|
||||||
|
|
||||||
|
const updatedReport: ShareUpdateResponse = await updateReportShareHandler(reportId, request, {
|
||||||
|
id: user.id,
|
||||||
|
organizationId: userOrg.organizationId,
|
||||||
|
});
|
||||||
|
|
||||||
|
return c.json(updatedReport);
|
||||||
|
});
|
||||||
|
|
||||||
export default app;
|
export default app;
|
||||||
|
|
|
@ -234,7 +234,9 @@ export const useUpdateCollectionShare = () => {
|
||||||
return create(previousData, (draft) => {
|
return create(previousData, (draft) => {
|
||||||
draft.individual_permissions = (
|
draft.individual_permissions = (
|
||||||
draft.individual_permissions?.map((t) => {
|
draft.individual_permissions?.map((t) => {
|
||||||
const found = params.users?.find((v: { email: string; role: string }) => v.email === t.email);
|
const found = params.users?.find(
|
||||||
|
(v: { email: string; role: string }) => v.email === t.email
|
||||||
|
);
|
||||||
if (found) return { ...t, ...found };
|
if (found) return { ...t, ...found };
|
||||||
return t;
|
return t;
|
||||||
}) || []
|
}) || []
|
||||||
|
|
|
@ -28,10 +28,10 @@ export const MetricDataTruncatedWarning: React.FC<MetricDataTruncatedWarningProp
|
||||||
});
|
});
|
||||||
|
|
||||||
// Race between the API call and the timeout
|
// Race between the API call and the timeout
|
||||||
const response = await Promise.race([
|
const response = (await Promise.race([
|
||||||
downloadMetricFile(metricId),
|
downloadMetricFile(metricId),
|
||||||
timeoutPromise
|
timeoutPromise
|
||||||
]) as Awaited<ReturnType<typeof downloadMetricFile>>;
|
])) as Awaited<ReturnType<typeof downloadMetricFile>>;
|
||||||
|
|
||||||
// Simply navigate to the download URL
|
// Simply navigate to the download URL
|
||||||
// The response-content-disposition header will force a download
|
// The response-content-disposition header will force a download
|
||||||
|
@ -56,14 +56,12 @@ export const MetricDataTruncatedWarning: React.FC<MetricDataTruncatedWarningProp
|
||||||
)}>
|
)}>
|
||||||
<div className="flex flex-col space-y-1">
|
<div className="flex flex-col space-y-1">
|
||||||
<Text className="font-medium">
|
<Text className="font-medium">
|
||||||
{hasError
|
{hasError ? 'Download failed' : 'This request returned more than 5,000 records'}
|
||||||
? 'Download failed'
|
|
||||||
: 'This request returned more than 5,000 records'}
|
|
||||||
</Text>
|
</Text>
|
||||||
<Text size="xs" variant={hasError ? 'danger' : 'secondary'}>
|
<Text size="xs" variant={hasError ? 'danger' : 'secondary'}>
|
||||||
{hasError
|
{hasError
|
||||||
? 'The download took too long or encountered an error. Please try again.'
|
? 'The download took too long or encountered an error. Please try again.'
|
||||||
: 'To see all records, you\'ll need to download the results.'}
|
: "To see all records, you'll need to download the results."}
|
||||||
</Text>
|
</Text>
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { describe, expect, it } from 'vitest';
|
import { describe, expect, it } from 'vitest';
|
||||||
import { ShareIndividualSchema } from '../share';
|
import { AssetPermissionRoleSchema, ShareIndividualSchema } from '../share';
|
||||||
import {
|
import {
|
||||||
AssetPermissionRoleSchema,
|
|
||||||
type ChatCreateHandlerRequest,
|
type ChatCreateHandlerRequest,
|
||||||
ChatCreateHandlerRequestSchema,
|
ChatCreateHandlerRequestSchema,
|
||||||
type ChatCreateRequest,
|
type ChatCreateRequest,
|
||||||
|
@ -11,7 +10,7 @@ import {
|
||||||
|
|
||||||
describe('AssetPermissionRoleSchema', () => {
|
describe('AssetPermissionRoleSchema', () => {
|
||||||
it('should accept valid role values', () => {
|
it('should accept valid role values', () => {
|
||||||
const validRoles = ['viewer', 'editor', 'owner'];
|
const validRoles = ['owner', 'viewer', 'full_access', 'can_edit', 'can_filter', 'can_view'];
|
||||||
|
|
||||||
for (const role of validRoles) {
|
for (const role of validRoles) {
|
||||||
const result = AssetPermissionRoleSchema.safeParse(role);
|
const result = AssetPermissionRoleSchema.safeParse(role);
|
||||||
|
@ -23,7 +22,7 @@ describe('AssetPermissionRoleSchema', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reject invalid role values', () => {
|
it('should reject invalid role values', () => {
|
||||||
const invalidRoles = ['admin', 'user', 'guest', '', 'VIEWER'];
|
const invalidRoles = ['admin', 'user', 'guest', '', 'VIEWER', 'editor'];
|
||||||
|
|
||||||
for (const role of invalidRoles) {
|
for (const role of invalidRoles) {
|
||||||
const result = AssetPermissionRoleSchema.safeParse(role);
|
const result = AssetPermissionRoleSchema.safeParse(role);
|
||||||
|
|
Loading…
Reference in New Issue