Skip to content

Commit b26bf2e

Browse files
Merge pull request #1971 from RedisInsight/fe/feature/RI-4321_tutorial-name
#RI-4321 - show tutorial name by label
2 parents c1c23d7 + 4bf522f commit b26bf2e

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

redisinsight/ui/src/pages/workbench/components/enablement-area/EnablementArea/EnablementArea.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ const EnablementArea = (props: Props) => {
292292
level: number = 0,
293293
) => (
294294
elements?.map((item) => (
295-
<div className="fluid" key={item.id}>
295+
<div className="fluid" key={`${item.id}_${item._key}`}>
296296
{renderSwitch(item, paths, level)}
297297
</div>
298298
)))

redisinsight/ui/src/pages/workbench/components/enablement-area/EnablementArea/components/LazyInternalPage/LazyInternalPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const LazyInternalPage = ({ onClose, title, path, sourcePath, manifest, manifest
9494
manifestPath={manifestPath}
9595
sourcePath={sourcePath}
9696
onClose={onClose}
97-
title={startCase(title || pageData.name)}
97+
title={startCase(title || pageData.label)}
9898
backTitle={startCase(pageData?.parent)}
9999
isLoading={isMarkdownLoading}
100100
content={pageData.content}

redisinsight/ui/src/pages/workbench/components/enablement-area/EnablementArea/utils/getFileInfo.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { EAManifestFirstKey } from 'uiSrc/pages/workbench/components/enablement-
88
export interface IFileInfo {
99
extension: string
1010
name: string
11+
label: string
1112
parent: string
1213
location: string
1314
_key?: Nullable<string>
@@ -17,17 +18,27 @@ export const getFileInfo = (
1718
{ manifestPath, path }: { manifestPath?: Nullable<string>, path: string },
1819
manifest?: Nullable<IEnablementAreaItem[]>
1920
): IFileInfo => {
20-
const defaultResult: IFileInfo = { extension: '', name: '', parent: '', location: '' }
21+
const defaultResult: IFileInfo = { extension: '', name: '', parent: '', location: '', label: '' }
2122
try {
2223
const url = IS_ABSOLUTE_PATH.test(path) ? new URL(path) : new URL(path, API_URL)
2324
const pathNames = url.pathname.split('/')
2425
const file = pathNames.pop() || ''
2526
const markdownParent = manifest ? getParentByManifest(manifest, manifestPath) : null
2627
const [fileName, extension] = file.split('.')
2728

29+
let markdownInfo: Record<string, any> = {}
30+
if (manifestPath && markdownParent?.children) {
31+
markdownInfo = get(
32+
markdownParent.children,
33+
manifestPath.split('/')?.pop() as string || '-1',
34+
{}
35+
)
36+
}
37+
2838
return {
2939
location: pathNames.join('/'),
3040
name: fileName || '',
41+
label: markdownInfo?.label || fileName,
3142
extension: extension || '',
3243
parent: markdownParent ? markdownParent.label : (pathNames.pop() || '').replace(/[-_]+/g, ' '),
3344
_key: manifestPath?.split('/').pop() ?? null

redisinsight/ui/src/pages/workbench/components/enablement-area/EnablementArea/utils/tests/getFileInfo.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,43 +14,43 @@ import {
1414
const getFileInfoTests = [
1515
{
1616
input: [{ path: 'static/workbench/quick-guides/file-name.txt' }],
17-
expected: { name: 'file-name', parent: 'quick guides', extension: 'txt', location: '/static/workbench/quick-guides', _key: null }
17+
expected: { name: 'file-name', parent: 'quick guides', extension: 'txt', location: '/static/workbench/quick-guides', label: 'file-name', _key: null }
1818
},
1919
{
2020
input: [{ path: 'parent_folder\\file_name.txt' }],
21-
expected: { name: 'file_name', parent: 'parent folder', extension: 'txt', location: '/parent_folder', _key: null }
21+
expected: { name: 'file_name', parent: 'parent folder', extension: 'txt', location: '/parent_folder', label: 'file_name', _key: null }
2222
},
2323
{
2424
input: [{ path: 'https://domen.com/workbench/enablement-area/introduction.html' }],
25-
expected: { name: 'introduction', parent: 'enablement area', extension: 'html', location: '/workbench/enablement-area', _key: null }
25+
expected: { name: 'introduction', parent: 'enablement area', extension: 'html', location: '/workbench/enablement-area', label: 'introduction', _key: null }
2626
},
2727
{
2828
input: [{ path: 'https://domen.com/introduction.html' }],
29-
expected: { name: 'introduction', parent: '', extension: 'html', location: '', _key: null }
29+
expected: { name: 'introduction', parent: '', extension: 'html', location: '', label: 'introduction', _key: null }
3030
},
3131
{
3232
input: [{ path: '/introduction.html' }],
33-
expected: { name: 'introduction', parent: '', extension: 'html', location: '', _key: null }
33+
expected: { name: 'introduction', parent: '', extension: 'html', location: '', label: 'introduction', _key: null }
3434
},
3535
{
3636
input: [{ path: '//parent/markdown.md' }],
37-
expected: { name: '', parent: '', extension: '', location: '' }
37+
expected: { name: '', parent: '', extension: '', location: '', label: '', }
3838
},
3939
{
4040
input: [{ path: '/file.txt' }],
41-
expected: { name: 'file', parent: '', extension: 'txt', location: '', _key: null }
41+
expected: { name: 'file', parent: '', extension: 'txt', location: '', label: 'file', _key: null }
4242
},
4343
{
4444
input: [{ path: '' }],
45-
expected: { name: '', parent: '', extension: '', location: '', _key: null }
45+
expected: { name: '', parent: '', extension: '', location: '', label: '', _key: null }
4646
},
4747
{
4848
input: [{ path: '/' }],
49-
expected: { name: '', parent: '', extension: '', location: '', _key: null }
49+
expected: { name: '', parent: '', extension: '', location: '', label: '', _key: null }
5050
},
5151
{
5252
input: [{ manifestPath: 'quick-guides/0/0', path: '/static/workbench/quick-guides/document/learn-more.md' }, MOCK_GUIDES_ITEMS],
53-
expected: { name: 'learn-more', parent: MOCK_GUIDES_ITEMS[0].label, extension: 'md', location: '/static/workbench/quick-guides/document', _key: '0' }
53+
expected: { name: 'learn-more', parent: MOCK_GUIDES_ITEMS[0].label, extension: 'md', location: '/static/workbench/quick-guides/document', label: MOCK_GUIDES_ITEMS[0].children[0].label, _key: '0' }
5454
}
5555
]
5656

0 commit comments

Comments
 (0)