mirror of
				https://github.com/datahub-project/datahub.git
				synced 2025-11-04 12:51:23 +00:00 
			
		
		
		
	fix(ui): pass createdBy to highlight query column (#14042)
This commit is contained in:
		
							parent
							
								
									fe56b0f41e
								
							
						
					
					
						commit
						14b9bed58d
					
				@ -55,6 +55,14 @@ public class QueryPropertiesMapper
 | 
			
		||||
    created.setActor(input.getCreated().getActor(GetMode.NULL).toString());
 | 
			
		||||
    result.setCreated(created);
 | 
			
		||||
 | 
			
		||||
    // Map created resolved audit stamp
 | 
			
		||||
    ResolvedAuditStamp createdOn = new ResolvedAuditStamp();
 | 
			
		||||
    createdOn.setTime(input.getCreated().getTime());
 | 
			
		||||
    final CorpUser createdUser = new CorpUser();
 | 
			
		||||
    createdUser.setUrn(input.getCreated().getActor().toString());
 | 
			
		||||
    createdOn.setActor(createdUser);
 | 
			
		||||
    result.setCreatedOn(createdOn);
 | 
			
		||||
 | 
			
		||||
    // Map last modified audit stamp
 | 
			
		||||
    AuditStamp lastModified = new AuditStamp();
 | 
			
		||||
    lastModified.setTime(input.getLastModified().getTime());
 | 
			
		||||
 | 
			
		||||
@ -12565,6 +12565,11 @@ type QueryProperties {
 | 
			
		||||
  """
 | 
			
		||||
  created: AuditStamp!
 | 
			
		||||
 | 
			
		||||
  """
 | 
			
		||||
  A Resolved Audit Stamp corresponding to the creation of this resource
 | 
			
		||||
  """
 | 
			
		||||
  createdOn: ResolvedAuditStamp!
 | 
			
		||||
 | 
			
		||||
  """
 | 
			
		||||
  An Audit Stamp corresponding to the update of this resource
 | 
			
		||||
  """
 | 
			
		||||
 | 
			
		||||
@ -121,6 +121,10 @@ public class QueryPropertiesMapperTest {
 | 
			
		||||
    assertEquals(result.getLastModified().getTime().longValue(), 2000L);
 | 
			
		||||
    assertEquals(result.getLastModified().getActor(), userUrn.toString());
 | 
			
		||||
 | 
			
		||||
    // Verify createdOn resolved stamp
 | 
			
		||||
    assertEquals(result.getCreatedOn().getTime().longValue(), 1000L);
 | 
			
		||||
    assertEquals(result.getCreatedOn().getActor().getUrn(), userUrn.toString());
 | 
			
		||||
 | 
			
		||||
    // Verify optional fields
 | 
			
		||||
    assertEquals(result.getName(), "Test Query");
 | 
			
		||||
    assertEquals(result.getDescription(), "Test Description");
 | 
			
		||||
 | 
			
		||||
@ -11,8 +11,7 @@ import { Query } from '@app/entityV2/shared/tabs/Dataset/Queries/types';
 | 
			
		||||
import { useEntityRegistryV2 } from '@app/useEntityRegistry';
 | 
			
		||||
import MarkdownViewer from '@src/app/entity/shared/components/legacy/MarkdownViewer';
 | 
			
		||||
 | 
			
		||||
import { useDeleteQueryMutation } from '@graphql/query.generated';
 | 
			
		||||
import { CorpUser, EntityType } from '@types';
 | 
			
		||||
import { ActorWithDisplayNameFragment, useDeleteQueryMutation } from '@graphql/query.generated';
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Description Column
 | 
			
		||||
@ -68,7 +67,7 @@ export const QueryDescription = ({ description }: DescriptionProps) => {
 | 
			
		||||
const INGESTION_URN = 'urn:li:corpuser:_ingestion';
 | 
			
		||||
 | 
			
		||||
interface CreatedByProps {
 | 
			
		||||
    createdBy?: CorpUser;
 | 
			
		||||
    createdBy?: ActorWithDisplayNameFragment;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export const QueryCreatedBy = ({ createdBy }: CreatedByProps) => {
 | 
			
		||||
@ -76,17 +75,16 @@ export const QueryCreatedBy = ({ createdBy }: CreatedByProps) => {
 | 
			
		||||
 | 
			
		||||
    if (!createdBy || createdBy.urn === INGESTION_URN) return null;
 | 
			
		||||
 | 
			
		||||
    const userName = entityRegistry.getDisplayName(EntityType.CorpUser, createdBy);
 | 
			
		||||
    const userName = entityRegistry.getDisplayName(createdBy.type, createdBy);
 | 
			
		||||
    const photoUrl = createdBy?.editableProperties?.pictureLink || createdBy?.editableInfo?.pictureLink || undefined;
 | 
			
		||||
 | 
			
		||||
    return (
 | 
			
		||||
        <div>
 | 
			
		||||
            <ActorAvatar
 | 
			
		||||
                size={26}
 | 
			
		||||
                name={userName}
 | 
			
		||||
                url={`/${entityRegistry.getPathName(EntityType.CorpUser)}/${createdBy.urn}`}
 | 
			
		||||
                photoUrl={
 | 
			
		||||
                    createdBy?.editableProperties?.pictureLink || createdBy?.editableInfo?.pictureLink || undefined
 | 
			
		||||
                }
 | 
			
		||||
                url={`/${entityRegistry.getPathName(createdBy.type)}/${createdBy.urn}`}
 | 
			
		||||
                photoUrl={photoUrl}
 | 
			
		||||
            />
 | 
			
		||||
        </div>
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
@ -1,3 +1,4 @@
 | 
			
		||||
import { ActorWithDisplayNameFragment } from '@graphql/query.generated';
 | 
			
		||||
import { CorpUser, Entity, SchemaFieldEntity } from '@types';
 | 
			
		||||
 | 
			
		||||
export type QueryBuilderState = {
 | 
			
		||||
@ -14,7 +15,7 @@ export type Query = {
 | 
			
		||||
    description?: string;
 | 
			
		||||
    lastRun?: number;
 | 
			
		||||
    createdTime?: number;
 | 
			
		||||
    createdBy?: CorpUser | null;
 | 
			
		||||
    createdBy?: ActorWithDisplayNameFragment | null;
 | 
			
		||||
    poweredEntity?: Entity;
 | 
			
		||||
    usedBy?: CorpUser[];
 | 
			
		||||
    columns?: SchemaFieldEntity[];
 | 
			
		||||
 | 
			
		||||
@ -15,6 +15,7 @@ import { EntityLink } from '@app/homeV2/reference/sections/EntityLink';
 | 
			
		||||
import { Sorting } from '@app/sharedV2/sorting/useSorting';
 | 
			
		||||
import { useEntityRegistryV2 } from '@app/useEntityRegistry';
 | 
			
		||||
 | 
			
		||||
import { ActorWithDisplayNameFragment } from '@graphql/query.generated';
 | 
			
		||||
import { CorpUser, Entity } from '@types';
 | 
			
		||||
 | 
			
		||||
const UsersWrapper = styled.div`
 | 
			
		||||
@ -108,7 +109,7 @@ export default function useQueryTableColumns({
 | 
			
		||||
                  const createdByB = entityRegistry.getDisplayName(queryB.createdBy.type, queryB.createdBy);
 | 
			
		||||
                  return createdByA.localeCompare(createdByB);
 | 
			
		||||
              },
 | 
			
		||||
        render: (createdBy: CorpUser) => {
 | 
			
		||||
        render: (createdBy: ActorWithDisplayNameFragment) => {
 | 
			
		||||
            return <QueryCreatedBy createdBy={createdBy} />;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
@ -17,6 +17,7 @@ export function mapQuery({ queryEntity, entityUrn, siblingUrn, poweredEntity }:
 | 
			
		||||
        description: queryEntity.properties?.description || undefined,
 | 
			
		||||
        query: queryEntity.properties?.statement?.value || '',
 | 
			
		||||
        createdTime: queryEntity?.properties?.created?.time,
 | 
			
		||||
        createdBy: queryEntity?.properties?.createdOn?.actor,
 | 
			
		||||
        columns: queryEntity.subjects
 | 
			
		||||
            ?.filter((s) => !!s.schemaField)
 | 
			
		||||
            ?.filter((s) => {
 | 
			
		||||
 | 
			
		||||
@ -8,6 +8,18 @@ query getQuery($urn: String!) {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fragment ActorWithDisplayName on CorpUser {
 | 
			
		||||
    urn
 | 
			
		||||
    type
 | 
			
		||||
    ...entityDisplayNameFields
 | 
			
		||||
    editableProperties {
 | 
			
		||||
        pictureLink
 | 
			
		||||
    }
 | 
			
		||||
    editableInfo {
 | 
			
		||||
        pictureLink
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fragment query on QueryEntity {
 | 
			
		||||
    urn
 | 
			
		||||
    properties {
 | 
			
		||||
@ -22,6 +34,12 @@ fragment query on QueryEntity {
 | 
			
		||||
            time
 | 
			
		||||
            actor
 | 
			
		||||
        }
 | 
			
		||||
        createdOn {
 | 
			
		||||
            time
 | 
			
		||||
            actor {
 | 
			
		||||
                ...ActorWithDisplayName
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        lastModified {
 | 
			
		||||
            time
 | 
			
		||||
            actor
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user