Allow Card field update and card drag on new record board (#3661)

This commit is contained in:
Charles Bochet
2024-01-29 08:59:13 +01:00
committed by GitHub
parent 6eca6dc780
commit 7fdd7119d2
10 changed files with 240 additions and 35 deletions

View File

@ -1,14 +1,14 @@
import { getActivitySummary } from '../getActivitySummary';
describe('getActivitySummary', () => {
it('should work for empty body', () => {
it('should work for empty body ""', () => {
const activityBody = {};
const res = getActivitySummary(JSON.stringify(activityBody));
expect(res).toEqual('');
});
it('should work for empty body', () => {
it('should work for empty body {}', () => {
const activityBody = '';
const res = getActivitySummary(JSON.stringify(activityBody));
@ -109,4 +109,34 @@ describe('getActivitySummary', () => {
expect(res).toEqual('');
});
it('should work for table as first block', () => {
const activityBody = [
{
id: '591c3aa1-9e51-465d-bb59-611ef60344fb',
type: 'table',
props: { textColor: 'default', backgroundColor: 'default' },
content: {
type: 'tableContent',
rows: [{ cells: [[], [], []] }, { cells: [[], [], []] }],
},
children: [],
},
{
id: '1899ab29-0122-4890-bb50-4d7cf2802f98',
type: 'paragraph',
props: {
textColor: 'default',
backgroundColor: 'default',
textAlignment: 'left',
},
content: [],
children: [],
},
];
const res = getActivitySummary(JSON.stringify(activityBody));
expect(res).toEqual('');
});
});

View File

@ -1,9 +1,25 @@
import { isArray } from '@sniptt/guards';
export const getActivitySummary = (activityBody: string) => {
const noteBody = activityBody ? JSON.parse(activityBody) : [];
return (
noteBody[0]?.content?.text ||
noteBody[0]?.content?.map((content: any) => content?.text).join(' ') ||
''
);
if (!noteBody.length) {
return '';
}
const firstNoteBlockContent = noteBody[0].content;
if (!firstNoteBlockContent) {
return '';
}
if (firstNoteBlockContent.text) {
return noteBody[0].content.text;
}
if (isArray(firstNoteBlockContent)) {
return firstNoteBlockContent.map((content: any) => content.text).join(' ');
}
return '';
};