Allow Card field update and card drag on new record board (#3661)
This commit is contained in:
@ -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('');
|
||||
});
|
||||
});
|
||||
|
||||
@ -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 '';
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user