Skip to content

Commit

Permalink
modify descriptions etc
Browse files Browse the repository at this point in the history
  • Loading branch information
clairelin135 committed Mar 9, 2024
1 parent 492b260 commit 104a5dd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import styled from 'styled-components';
import {AssetGlobalLineageButton, AssetPageHeader} from './AssetPageHeader';
import {ASSET_CATALOG_TABLE_QUERY} from './AssetsCatalogTable';
import {fetchRecentlyVisitedAssetsFromLocalStorage} from './RecentlyVisitedAssetsStorage';
import {AssetTableFragment} from './types/AssetTableFragment.types';
import {
AssetCatalogTableQuery,
AssetCatalogTableQueryVariables,
Expand Down Expand Up @@ -69,8 +68,6 @@ export function buildAssetCountBySection(assets: AssetDefinitionMetadata[]): Ass
const assetCountByGroup: Record<string, number> = {};
const assetCountByCodeLocation: Record<string, number> = {};

// TODO guard against the query data not containing the above fields?

assets
.filter((asset) => asset.definition)
.forEach((asset) => {
Expand Down
24 changes: 21 additions & 3 deletions js_modules/dagster-ui/packages/ui-core/src/search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,33 @@ export enum SearchResultType {
Sensor,
Solid,
Resource,
ComputeKind,
CodeLocation,
}

export enum AssetFilterSearchResultType {
// Add types with corresponding strings to distinguish
// between SearchResultType.AssetGroup
ComputeKind = 'AssetFilterSearchResultType.ComputeKind',
CodeLocation = 'AssetFilterSearchResultType.CodeLocation',
Owner = 'AssetFilterSearchResultType.Owner',
AssetGroup = 'AssetFilterSearchResultType.AssetGroup',
}

export function isAssetFilterSearchResultType(
type: SearchResultType | AssetFilterSearchResultType,
): type is AssetFilterSearchResultType {
return (
type === AssetFilterSearchResultType.AssetGroup ||
type === AssetFilterSearchResultType.CodeLocation ||
type === AssetFilterSearchResultType.ComputeKind ||
type === AssetFilterSearchResultType.Owner
);
}

export type SearchResult = {
label: string;
description: string;
href: string;
type: SearchResultType;
type: SearchResultType | AssetFilterSearchResultType;
tags?: string;
numResults?: number;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {gql} from '@apollo/client';
import {useCallback, useEffect, useRef} from 'react';

import {QueryResponse, WorkerSearchResult, createSearchWorker} from './createSearchWorker';
import {SearchResult, SearchResultType} from './types';
import {AssetFilterSearchResultType, SearchResult, SearchResultType} from './types';
import {
SearchPrimaryQuery,
SearchPrimaryQueryVariables,
Expand Down Expand Up @@ -155,8 +155,8 @@ const secondaryDataToSearchResults = (input: {data?: SearchSecondaryQuery}) => {
countsBySection.countsByComputeKind,
).map(([computeKind, count]) => ({
label: computeKind,
description: 'Compute kind',
type: SearchResultType.ComputeKind,
description: '',
type: AssetFilterSearchResultType.ComputeKind,
// TODO display correct link once https://github.com/dagster-io/dagster/pull/20342 lands
href: '/assets',
numResults: count,
Expand All @@ -168,8 +168,8 @@ const secondaryDataToSearchResults = (input: {data?: SearchSecondaryQuery}) => {
codeLocationAssetCount.repoAddress.name,
codeLocationAssetCount.repoAddress.location,
),
description: 'Code location',
type: SearchResultType.CodeLocation,
description: '',
type: AssetFilterSearchResultType.CodeLocation,
// TODO display correct link once https://github.com/dagster-io/dagster/pull/20342 lands
href: '/assets',
numResults: codeLocationAssetCount.assetCount,
Expand All @@ -179,21 +179,19 @@ const secondaryDataToSearchResults = (input: {data?: SearchSecondaryQuery}) => {
const groupResults: SearchResult[] = countsBySection.countPerAssetGroup.map(
(groupAssetCount) => ({
label: groupAssetCount.groupMetadata.groupName,
description: `Asset group in ${buildRepoPathForHuman(
groupAssetCount.groupMetadata.repositoryName,
groupAssetCount.groupMetadata.repositoryLocationName,
)}`,
type: SearchResultType.AssetGroup,
description: '',
type: AssetFilterSearchResultType.AssetGroup,
// TODO display correct link once https://github.com/dagster-io/dagster/pull/20342 lands
href: '/assets',
numResults: groupAssetCount.assetCount,
}),
);

const ownerResults: SearchResult[] = Object.entries(countsBySection.countsByOwner).map(
([owner, count]) => ({
label: owner,
description: 'Owner',
type: SearchResultType.Asset,
description: '',
type: AssetFilterSearchResultType.Owner,
// TODO display correct link once https://github.com/dagster-io/dagster/pull/20342 lands
href: '/assets',
numResults: count,
Expand All @@ -202,12 +200,15 @@ const secondaryDataToSearchResults = (input: {data?: SearchSecondaryQuery}) => {

const assets = nodes
.filter(({definition}) => definition !== null)
.map(({key}) => {
.map(({key, definition}) => {
return {
label: displayNameForAssetKey(key),
href: assetDetailsPathForKey(key),
segments: key.path,
description: 'Asset',
description: `Asset in ${buildRepoPathForHuman(
definition!.repository.name,
definition!.repository.location.name,
)}`,
type: SearchResultType.Asset,
};
});
Expand Down

0 comments on commit 104a5dd

Please sign in to comment.