mirror of https://github.com/buster-so/buster.git
update
This commit is contained in:
parent
ffeee17365
commit
c6834bdfeb
|
@ -61,8 +61,8 @@ export const ShareMenuContentPublish: React.FC<ShareMenuContentBodyProps> = Reac
|
|||
id: assetId,
|
||||
params: {
|
||||
publicly_accessible: v === undefined ? true : !!v,
|
||||
public_password: _password || null,
|
||||
public_expiry_date: linkExp
|
||||
public_password: _password || undefined,
|
||||
public_expiry_date: linkExp || undefined
|
||||
}
|
||||
};
|
||||
if (assetType === 'metric') {
|
||||
|
|
|
@ -32,7 +32,7 @@ export const ShareMenuInvite: React.FC<ShareMenuInviteProps> = React.memo(
|
|||
const [inputValue, setInputValue] = React.useState<string>('');
|
||||
|
||||
const [defaultPermissionLevel, setDefaultPermissionLevel] =
|
||||
React.useState<ShareRole>('canView');
|
||||
React.useState<ShareRole>('can_view');
|
||||
|
||||
const debouncedInputValue = useDebounce(inputValue, { wait: 100 });
|
||||
const { data: usersData } = useGetUserToOrganization({
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
import { getNow, isDateAfter, isDateBefore, isDateSame } from '@/lib/date';
|
||||
|
||||
type ListItem = {
|
||||
type ListItem<K extends string = 'last_edited'> = {
|
||||
id: string;
|
||||
last_edited: string;
|
||||
};
|
||||
} & Record<K, string>;
|
||||
|
||||
export const createChatRecord = <T extends ListItem>(
|
||||
data: T[]
|
||||
export const createChatRecord = <
|
||||
T extends Record<string, any>,
|
||||
K extends keyof T
|
||||
>(
|
||||
data: T[],
|
||||
dateKey: K & (T[K] extends string ? K : never) = 'last_edited' as K
|
||||
): {
|
||||
TODAY: T[];
|
||||
YESTERDAY: T[];
|
||||
|
|
|
@ -33,7 +33,7 @@ describe('useOriginalMetricStore', () => {
|
|||
updated_at: '2024-01-01T00:00:00Z',
|
||||
sent_by_id: 'user-1',
|
||||
sent_by_name: 'Test User',
|
||||
permission: 'canView',
|
||||
permission: 'can_view',
|
||||
sent_by_avatar_url: null,
|
||||
dashboards: [],
|
||||
collections: [],
|
||||
|
|
|
@ -33,7 +33,7 @@ export const ReportItemsContainer: React.FC<{
|
|||
const reportsByDate: BusterListRowItem<ReportListItem>[] = useMemo(() => {
|
||||
return Object.entries(reportsRecord).flatMap<BusterListRowItem<ReportListItem>>(
|
||||
([key, reports]) => {
|
||||
const records = reports.map((report) => ({
|
||||
const records = reports.map<BusterListRowItem<ReportListItem>>((report) => ({
|
||||
id: report.id,
|
||||
data: report,
|
||||
link: createBusterRoute({ route: BusterRoutes.APP_REPORTS_ID, reportId: report.id })
|
||||
|
|
|
@ -6,6 +6,14 @@ import { reportFiles } from '../../schema';
|
|||
import { workspaceSharingEnum } from '../../schema';
|
||||
import { ReportElementSchema, type ReportElements } from '../../schema-types';
|
||||
|
||||
// Type for updating reportFiles - excludes read-only fields
|
||||
type UpdateReportData = Partial<
|
||||
Omit<
|
||||
typeof reportFiles.$inferInsert,
|
||||
'id' | 'organizationId' | 'createdBy' | 'createdAt' | 'deletedAt'
|
||||
>
|
||||
>;
|
||||
|
||||
const WorkspaceSharingSchema = z.enum(workspaceSharingEnum.enumValues);
|
||||
|
||||
// Input validation schema for updating a report
|
||||
|
@ -18,8 +26,8 @@ const UpdateReportInputSchema = z.object({
|
|||
content: z.lazy(() => z.array(ReportElementSchema)).optional() as z.ZodOptional<
|
||||
z.ZodType<ReportElements>
|
||||
>,
|
||||
public_expiry_date: z.string().optional(),
|
||||
public_password: z.string().optional(),
|
||||
public_expiry_date: z.string().nullable().optional(),
|
||||
public_password: z.string().nullable().optional(),
|
||||
workspace_sharing: WorkspaceSharingSchema.optional(),
|
||||
});
|
||||
|
||||
|
@ -46,18 +54,7 @@ export const updateReport = async (params: UpdateReportInput): Promise<void> =>
|
|||
|
||||
try {
|
||||
// Build update data - only include fields that are provided
|
||||
const updateData: {
|
||||
updatedAt: string;
|
||||
name?: string;
|
||||
publiclyAccessible?: boolean;
|
||||
publiclyEnabledBy?: string | null;
|
||||
content?: ReportElements;
|
||||
publicExpiryDate?: string;
|
||||
publicPassword?: string;
|
||||
workspaceSharing?: 'none' | 'can_view' | 'can_edit' | 'full_access';
|
||||
workspaceSharingEnabledBy?: string | null;
|
||||
workspaceSharingEnabledAt?: string | null;
|
||||
} = {
|
||||
const updateData: UpdateReportData = {
|
||||
updatedAt: new Date().toISOString(),
|
||||
};
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ describe('ShareIndividualSchema', () => {
|
|||
it('should handle optional name field', () => {
|
||||
const individualWithoutName = {
|
||||
email: 'test@example.com',
|
||||
role: 'canView', // Changed from 'viewer' to match ShareRoleSchema
|
||||
role: 'can_view', // Changed from 'viewer' to match ShareRoleSchema
|
||||
};
|
||||
|
||||
const result = ShareIndividualSchema.safeParse(individualWithoutName);
|
||||
|
@ -61,7 +61,7 @@ describe('ShareIndividualSchema', () => {
|
|||
|
||||
if (result.success) {
|
||||
expect(result.data.email).toBe('test@example.com');
|
||||
expect(result.data.role).toBe('canView');
|
||||
expect(result.data.role).toBe('can_view');
|
||||
expect(result.data.name).toBeUndefined();
|
||||
}
|
||||
});
|
||||
|
@ -72,7 +72,7 @@ describe('ShareIndividualSchema', () => {
|
|||
for (const email of invalidEmails) {
|
||||
const individual = {
|
||||
email,
|
||||
role: 'canView', // Changed from 'viewer' to match ShareRoleSchema
|
||||
role: 'can_view', // Changed from 'viewer' to match ShareRoleSchema
|
||||
};
|
||||
|
||||
const result = ShareIndividualSchema.safeParse(individual);
|
||||
|
|
|
@ -113,7 +113,7 @@ describe('MetricSchema', () => {
|
|||
public_enabled_by: null,
|
||||
publicly_accessible: false,
|
||||
public_password: null,
|
||||
permission: 'canView',
|
||||
permission: 'can_view',
|
||||
workspace_sharing: null,
|
||||
workspace_member_count: null,
|
||||
// chart_config is omitted, should get default
|
||||
|
@ -356,7 +356,7 @@ describe('MetricSchema', () => {
|
|||
public_enabled_by: null, // nullable
|
||||
publicly_accessible: false,
|
||||
public_password: null, // nullable
|
||||
permission: 'canView',
|
||||
permission: 'can_view',
|
||||
workspace_sharing: null,
|
||||
workspace_member_count: null,
|
||||
};
|
||||
|
|
|
@ -15,8 +15,8 @@ export type SharePostRequest = z.infer<typeof SharePostRequestSchema>;
|
|||
//Used for updating share permissions for a report, collection, or metric
|
||||
export const ShareUpdateRequestSchema = z.object({
|
||||
publicly_accessible: z.boolean().optional(),
|
||||
public_expiry_date: z.string().optional(),
|
||||
public_password: z.string().optional(),
|
||||
public_expiry_date: z.string().nullable().optional(),
|
||||
public_password: z.string().nullable().optional(),
|
||||
workspace_sharing: WorkspaceShareRoleSchema.optional(),
|
||||
users: z
|
||||
.array(
|
||||
|
|
|
@ -91,7 +91,7 @@ describe('ShareIndividualSchema', () => {
|
|||
it('should handle optional name field', () => {
|
||||
const individualWithoutName = {
|
||||
email: 'test@example.com',
|
||||
role: 'canView',
|
||||
role: 'can_view',
|
||||
};
|
||||
|
||||
const result = ShareIndividualSchema.safeParse(individualWithoutName);
|
||||
|
@ -99,7 +99,7 @@ describe('ShareIndividualSchema', () => {
|
|||
|
||||
if (result.success) {
|
||||
expect(result.data.email).toBe('test@example.com');
|
||||
expect(result.data.role).toBe('canView');
|
||||
expect(result.data.role).toBe('can_view');
|
||||
expect(result.data.name).toBeUndefined();
|
||||
}
|
||||
});
|
||||
|
@ -110,7 +110,7 @@ describe('ShareIndividualSchema', () => {
|
|||
for (const email of invalidEmails) {
|
||||
const individual = {
|
||||
email,
|
||||
role: 'canView',
|
||||
role: 'can_view',
|
||||
};
|
||||
|
||||
const result = ShareIndividualSchema.safeParse(individual);
|
||||
|
@ -177,7 +177,7 @@ describe('ShareConfigSchema', () => {
|
|||
},
|
||||
{
|
||||
email: 'user2@example.com',
|
||||
role: 'canView',
|
||||
role: 'can_view',
|
||||
},
|
||||
],
|
||||
public_expiry_date: '2024-12-31T23:59:59Z',
|
||||
|
@ -208,7 +208,7 @@ describe('ShareConfigSchema', () => {
|
|||
public_enabled_by: null,
|
||||
publicly_accessible: false,
|
||||
public_password: null,
|
||||
permission: 'canView',
|
||||
permission: 'can_view',
|
||||
workspace_sharing: null,
|
||||
workspace_member_count: null,
|
||||
};
|
||||
|
@ -222,7 +222,7 @@ describe('ShareConfigSchema', () => {
|
|||
expect(result.data.public_enabled_by).toBeNull();
|
||||
expect(result.data.publicly_accessible).toBe(false);
|
||||
expect(result.data.public_password).toBeNull();
|
||||
expect(result.data.permission).toBe('canView');
|
||||
expect(result.data.permission).toBe('can_view');
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue