mirror of
				https://github.com/strapi/strapi.git
				synced 2025-11-03 19:36:20 +00:00 
			
		
		
		
	Merge pull request #13705 from strapi/fix/cm-relations-permissions
CellContent: Fix relations, if a user does not have read permissions
This commit is contained in:
		
						commit
						e2a285cfa1
					
				@ -45,7 +45,7 @@ export default function hasContent(type, content, metadatas, fieldSchema) {
 | 
			
		||||
      return !isEmpty(content);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return content.count > 0;
 | 
			
		||||
    return content?.count > 0;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* 
 | 
			
		||||
 | 
			
		||||
@ -227,20 +227,27 @@ describe('hasContent', () => {
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  describe('relations', () => {
 | 
			
		||||
    it('extracts content from multiple relations with content', () => {
 | 
			
		||||
    it('extracts content from multiple relations with count=1', () => {
 | 
			
		||||
      const normalizedContent = hasContent('relation', { count: 1 }, undefined, {
 | 
			
		||||
        relation: 'manyToMany',
 | 
			
		||||
      });
 | 
			
		||||
      expect(normalizedContent).toEqual(true);
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    it('extracts content from multiple relations without content', () => {
 | 
			
		||||
    it('extracts content from multiple relations with count=0', () => {
 | 
			
		||||
      const normalizedContent = hasContent('relation', { count: 0 }, undefined, {
 | 
			
		||||
        relation: 'manyToMany',
 | 
			
		||||
      });
 | 
			
		||||
      expect(normalizedContent).toEqual(false);
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    it('extracts content from multiple relations without content', () => {
 | 
			
		||||
      const normalizedContent = hasContent('relation', undefined, undefined, {
 | 
			
		||||
        relation: 'manyToMany',
 | 
			
		||||
      });
 | 
			
		||||
      expect(normalizedContent).toEqual(false);
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    it('extracts content from single relations with content', () => {
 | 
			
		||||
      const normalizedContent = hasContent('relation', { id: 1 }, undefined, {
 | 
			
		||||
        relation: 'oneToOne',
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user