-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support fetching description entity (#735)
* Add Description entity Signed-off-by: Kevin Su <[email protected]> * Add Description entity Signed-off-by: Kevin Su <[email protected]> * nit Signed-off-by: Kevin Su <[email protected]> * nit Signed-off-by: Kevin Su <[email protected]> * nit Signed-off-by: Kevin Su <[email protected]> * address comment Signed-off-by: Kevin Su <[email protected]> * test ci Signed-off-by: Kevin Su <[email protected]> * test ci Signed-off-by: Kevin Su <[email protected]> * test ci Signed-off-by: Kevin Su <[email protected]> * test ci Signed-off-by: Kevin Su <[email protected]> * test ci Signed-off-by: Kevin Su <[email protected]> --------- Signed-off-by: Kevin Su <[email protected]> Co-authored-by: Jason Porter <[email protected]> Signed-off-by: Carina Ursu <[email protected]>
- Loading branch information
1 parent
76ed376
commit 687cdb9
Showing
15 changed files
with
191 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {Identifier, IdentifierScope, RequestConfig} from "../../models"; | ||
import {useFetchableData} from "./useFetchableData"; | ||
import {getDescriptionEntity, listDescriptionEntities} from "../../models/DescriptionEntity/api"; | ||
import {DescriptionEntity} from "../../models/DescriptionEntity/types"; | ||
import {FetchableData} from "./types"; | ||
import {useAPIContext} from "../data/apiContext"; | ||
import {usePagination} from "./usePagination"; | ||
|
||
|
||
/** A hook for fetching a description entity */ | ||
export function useDescriptionEntity(id: Identifier): FetchableData<DescriptionEntity> { | ||
const { getDescriptionEntity } = useAPIContext(); | ||
return useFetchableData<DescriptionEntity, Identifier>( | ||
{ | ||
useCache: true, | ||
debugName: 'DescriptionEntity', | ||
defaultValue: {} as DescriptionEntity, | ||
doFetch: async descriptionEntityId => (await getDescriptionEntity(descriptionEntityId)) as DescriptionEntity, | ||
}, | ||
id, | ||
); | ||
} | ||
|
||
/** A hook for fetching a paginated list of description entities */ | ||
export function useDescriptionEntityList(scope: IdentifierScope, config: RequestConfig) { | ||
const { listDescriptionEntities } = useAPIContext(); | ||
return usePagination<DescriptionEntity, IdentifierScope>( | ||
{ ...config, cacheItems: true, fetchArg: scope }, | ||
listDescriptionEntities, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Admin } from '@flyteorg/flyteidl-types'; | ||
import { | ||
getAdminEntity, | ||
} from 'models/AdminEntity/AdminEntity'; | ||
import { defaultPaginationConfig } from 'models/AdminEntity/constants'; | ||
import { RequestConfig } from 'models/AdminEntity/types'; | ||
import { Identifier, IdentifierScope } from 'models/Common/types'; | ||
import { DescriptionEntity } from './types'; | ||
import { makeDescriptionPath, descriptionEntityListTransformer } from './utils'; | ||
|
||
/** Fetches a list of `DescriptionEntity` records matching the provided `scope` */ | ||
export const listDescriptionEntities = (scope: IdentifierScope, config?: RequestConfig) => | ||
getAdminEntity( | ||
{ | ||
path: makeDescriptionPath(scope), | ||
messageType: Admin.DescriptionEntityList, | ||
transform: descriptionEntityListTransformer, | ||
}, | ||
{ ...defaultPaginationConfig, ...config }, | ||
); | ||
|
||
/** Fetches an individual `DescriptionEntity` record */ | ||
export const getDescriptionEntity = (id: Identifier, config?: RequestConfig) => | ||
getAdminEntity<Admin.DescriptionEntity, DescriptionEntity>( | ||
{ | ||
path: makeDescriptionPath(id), | ||
messageType: Admin.DescriptionEntity, | ||
}, | ||
config, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Admin } from '@flyteorg/flyteidl-types'; | ||
import { Identifier } from 'models/Common/types'; | ||
|
||
|
||
/** Optional link to source code used to define this entity */ | ||
export interface SourceCode extends Admin.ISourceCode { | ||
link?: string | ||
} | ||
|
||
/** Full user description with formatting preserved */ | ||
export interface LongDescription extends Admin.IDescription { | ||
value: string; | ||
uri: string; | ||
format: Admin.DescriptionFormat | ||
iconLink?: string | ||
} | ||
|
||
/* | ||
DescriptionEntity contains detailed description for the task/workflow. | ||
Documentation could provide insight into the algorithms, business use case, etc | ||
*/ | ||
export interface DescriptionEntity extends Admin.IDescriptionEntity { | ||
id: Identifier; | ||
shortDescription: string; | ||
longDescription: LongDescription | ||
sourceCode?: SourceCode | ||
tags?: string[] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Admin } from '@flyteorg/flyteidl-types'; | ||
import { createPaginationTransformer } from 'models/AdminEntity/utils'; | ||
import { endpointPrefixes } from 'models/Common/constants'; | ||
import { IdentifierScope } from 'models/Common/types'; | ||
import { makeDescriptionEntityPath } from 'models/Common/utils'; | ||
import { DescriptionEntity } from './types'; | ||
|
||
/** Generate the correct path for retrieving a DescriptionEntity or list of DescriptionEntities based on the | ||
* given scope. | ||
*/ | ||
export function makeDescriptionPath(scope: IdentifierScope) { | ||
return makeDescriptionEntityPath(endpointPrefixes.descriptionEntity, scope); | ||
} | ||
|
||
/** Transformer to coerce an `Admin.DescriptionEntityList` into a standard shape */ | ||
export const descriptionEntityListTransformer = createPaginationTransformer< | ||
DescriptionEntity, | ||
Admin.DescriptionEntityList | ||
>('descriptionEntities'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters