-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support fetching description entity #735
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4f1b5c7
Add Description entity
pingsutw e5de90a
Add Description entity
pingsutw 7d6fc00
Merge branch 'master' of github.com:flyteorg/flyteconsole into doc-hub
pingsutw fc50ab9
nit
pingsutw 724e96a
nit
pingsutw 3149184
nit
pingsutw 05b6326
address comment
pingsutw 49c86b8
test ci
pingsutw 92677a0
test ci
pingsutw 5e28590
test ci
pingsutw 606d54e
test ci
pingsutw 7eacbb0
test ci
pingsutw 7df9357
Merge branch 'master' into doc-hub
jsonporter 5502df9
Merge branch 'master' into doc-hub
jsonporter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason this bit doesn't seem to be working; ran a debugger and verified
hasDescription
isfalse
but it doesn't seem to render the string?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed it.