-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] Fix showing incorrect empty-illustration message in Audios expl…
…orer (#2395) * [fix] Fix the issue with rendering incorrect empty-illustration content in Audios explorer
- Loading branch information
1 parent
e01030b
commit 022b766
Showing
25 changed files
with
443 additions
and
73 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as React from 'react'; | ||
|
||
import { PipelineStatusEnum } from 'modules/core/engine/types'; | ||
|
||
export interface IIllustrationProps { | ||
content?: string | React.ReactNode; | ||
image?: React.FunctionComponentElement<React.ReactNode> | HTMLImageElement; | ||
type?: IllustrationType; | ||
className?: string; | ||
size?: 'small' | 'medium' | 'large' | 'xLarge'; | ||
showImage?: boolean; | ||
} | ||
|
||
export type IllustrationType = string | PipelineStatusEnum; |
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,86 @@ | ||
@use '../../styles/abstracts/index' as *; | ||
|
||
.Illustration { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 100%; | ||
height: 100%; | ||
overflow: auto; | ||
flex-direction: column; | ||
&__hidden { | ||
display: none; | ||
} | ||
&__container { | ||
height: fit-content; | ||
overflow: hidden; | ||
padding-bottom: 6 * $space-unit; | ||
&__content { | ||
text-align: center; | ||
.qlAnchor { | ||
color: $primary-color; | ||
text-decoration: none; | ||
margin: 0 $space-xxxs; | ||
&:hover { | ||
text-decoration: underline; | ||
} | ||
} | ||
} | ||
&__img { | ||
& > img { | ||
margin: 0 auto; | ||
display: block; | ||
} | ||
} | ||
|
||
&__small { | ||
&__content { | ||
font-weight: $font-500; | ||
font-size: $text-md; | ||
} | ||
&__img { | ||
padding: $space-xs; | ||
& > img { | ||
width: 3rem; | ||
} | ||
} | ||
} | ||
&__medium { | ||
&__content { | ||
font-weight: $font-500; | ||
font-size: $text-md; | ||
} | ||
&__img { | ||
padding: $space-sm; | ||
& > img { | ||
width: 7.5rem; | ||
} | ||
} | ||
} | ||
&__large { | ||
&__content { | ||
font-weight: $font-500; | ||
font-size: $text-lg; | ||
} | ||
&__img { | ||
padding: $space-sm; | ||
& > img { | ||
width: 14.5rem; | ||
} | ||
} | ||
} | ||
&__xLarge { | ||
&__content { | ||
font-weight: $font-500; | ||
font-size: $text-xl; | ||
margin-bottom: $space-unit; | ||
} | ||
&__img { | ||
padding: $space-unit; | ||
& > img { | ||
width: 19.5rem; | ||
} | ||
} | ||
} | ||
} | ||
} |
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,58 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
import { Text } from 'components/kit'; | ||
|
||
import { | ||
IIllustrationProps, | ||
ILLUSTRATION_TYPES, | ||
ILLUSTRATION_LIST, | ||
getDefaultIllustrationContent, | ||
} from '.'; | ||
|
||
import './Illustration.scss'; | ||
|
||
function Illustration({ | ||
type = ILLUSTRATION_TYPES.Never_Executed, | ||
content = getDefaultIllustrationContent(type), | ||
image, | ||
className = '', | ||
size = 'xLarge', | ||
showImage = true, | ||
}: IIllustrationProps): React.FunctionComponentElement<React.ReactNode> { | ||
const [imgLoaded, setImgLoaded] = React.useState(false); | ||
|
||
return ( | ||
<div | ||
className={classNames('Illustration', { | ||
Illustrations__hidden: showImage && !imgLoaded, | ||
[className]: !!className, | ||
})} | ||
> | ||
<div className='Illustration__container'> | ||
{showImage ? ( | ||
<div | ||
className={`Illustration__container__img Illustration__container__${size}__img `} | ||
> | ||
{image || ( | ||
<img | ||
onLoad={() => setImgLoaded(true)} | ||
src={ILLUSTRATION_LIST[type]} | ||
alt='Illustration' | ||
/> | ||
)} | ||
</div> | ||
) : null} | ||
|
||
<Text | ||
component='p' | ||
className={`Illustration__container__content Illustration__container__${size}__content`} | ||
> | ||
{content} | ||
</Text> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default React.memo(Illustration); |
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,65 @@ | ||
import * as React from 'react'; | ||
|
||
import { PipelineStatusEnum } from 'modules/core/engine/types'; | ||
|
||
import emptyBookmarks from 'assets/illustrations/emptyBookmarks.svg'; | ||
import emptySearch from 'assets/illustrations/emptySearch.svg'; | ||
import exploreData from 'assets/illustrations/exploreData.svg'; | ||
import wrongSearch from 'assets/illustrations/wrongSearch.svg'; | ||
|
||
import { DOCUMENTATIONS } from 'config/references'; | ||
|
||
import { IllustrationType } from '.'; | ||
|
||
const ILLUSTRATION_TYPES: Record<string, IllustrationType> = { | ||
Never_Executed: PipelineStatusEnum.Never_Executed, | ||
Insufficient_Resources: PipelineStatusEnum.Insufficient_Resources, | ||
Empty: PipelineStatusEnum.Empty, | ||
Failed: PipelineStatusEnum.Failed, | ||
Empty_Bookmarks: 'emptyBookmarks', | ||
}; | ||
|
||
const ILLUSTRATION_LIST: Record<IllustrationType, string> = { | ||
[ILLUSTRATION_TYPES.Never_Executed]: exploreData, | ||
[ILLUSTRATION_TYPES.Insufficient_Resources]: exploreData, | ||
[ILLUSTRATION_TYPES.Empty]: emptySearch, | ||
[ILLUSTRATION_TYPES.Failed]: wrongSearch, | ||
[ILLUSTRATION_TYPES.Empty_Bookmarks]: emptyBookmarks, | ||
}; | ||
|
||
function getDefaultIllustrationContent( | ||
type: IllustrationType = ILLUSTRATION_TYPES.Never_Executed, | ||
): React.ReactNode { | ||
const Never_Executed = ( | ||
<> | ||
It’s super easy to search Aim experiments. Just start typing your query in | ||
the search bar above. | ||
<br /> | ||
Look up | ||
<a | ||
className='qlAnchor' | ||
href={DOCUMENTATIONS.EXPLORERS.SEARCH} | ||
target='_blank' | ||
rel='noreferrer' | ||
> | ||
search docs | ||
</a> | ||
to learn more. | ||
</> | ||
); | ||
const Failed = 'Incorrect Query'; | ||
const Insufficient_Resources = "You don't have any tracked data"; | ||
const Empty = 'No Results'; | ||
const Empty_Bookmarks = "You don't have any saved bookmark"; | ||
|
||
const CONTENT = { | ||
[ILLUSTRATION_TYPES.Never_Executed]: Never_Executed, | ||
[ILLUSTRATION_TYPES.Failed]: Failed, | ||
[ILLUSTRATION_TYPES.Insufficient_Resources]: Insufficient_Resources, | ||
[ILLUSTRATION_TYPES.Empty]: Empty, | ||
[ILLUSTRATION_TYPES.Empty_Bookmarks]: Empty_Bookmarks, | ||
}; | ||
return CONTENT[type] || null; | ||
} | ||
|
||
export { ILLUSTRATION_TYPES, ILLUSTRATION_LIST, getDefaultIllustrationContent }; |
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,6 @@ | ||
import Illustration from './Illustration'; | ||
|
||
export * from './Illustration.d'; | ||
export * from './config'; | ||
|
||
export default Illustration; |
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
Oops, something went wrong.