Skip to content

Commit ca27a58

Browse files
authored
Merge pull request #2648 from RedisInsight/feature/RI-4943_rework-tutorials
WIP #RI-4943 - move tutorials to database pages
2 parents c02659f + cfd42bc commit ca27a58

File tree

651 files changed

+9030
-5838
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

651 files changed

+9030
-5838
lines changed

redisinsight/__mocks__/monacoMock.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect } from 'react';
1+
import React, { useEffect } from 'react'
22

33
export default function MonacoEditor(props) {
44
useEffect(() => {
@@ -22,7 +22,7 @@ export default function MonacoEditor(props) {
2222
},
2323
// monaco
2424
{
25-
Range: jest.fn().mockImplementation(() => { return {} }),
25+
Range: jest.fn().mockImplementation(() => ({})),
2626
languages: {
2727
getLanguages: jest.fn(),
2828
register: jest.fn(),
@@ -35,20 +35,23 @@ export default function MonacoEditor(props) {
3535
setLanguageConfiguration: jest.fn(),
3636
setMonarchTokensProvider: jest.fn(),
3737
json: {
38-
jsonDefaults:{
38+
jsonDefaults: {
3939
setDiagnosticsOptions: jest.fn()
4040
}
4141
}
4242
},
4343
KeyMod: {},
4444
KeyCode: {}
45-
})
45+
}
46+
)
4647
}, [])
47-
return <textarea
48-
{...props}
49-
onChange={(e) => props.onChange && props.onChange(e.target.value)}
50-
data-testid={props['data-testid'] ? props['data-testid'] : 'monaco'}
51-
/>;
48+
return (
49+
<textarea
50+
{...props}
51+
onChange={(e) => props.onChange && props.onChange(e.target.value)}
52+
data-testid={props['data-testid'] ? props['data-testid'] : 'monaco'}
53+
/>
54+
)
5255
}
5356

5457
export const languages = {
@@ -61,5 +64,10 @@ export const languages = {
6164
}
6265

6366
export const monaco = {
64-
Selection: jest.fn().mockImplementation(() => { return {} })
67+
Selection: jest.fn().mockImplementation(() => ({})),
68+
editor: {
69+
colorize: jest.fn().mockImplementation((data) => Promise.resolve(data)),
70+
defineTheme: jest.fn(),
71+
setTheme: jest.fn()
72+
}
6573
}

redisinsight/api/config/default.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ export default {
2929
pluginsAssets: join(staticDir, 'resources', 'plugins'),
3030
commands: join(homedir, 'commands'),
3131
defaultCommandsDir: join(defaultsDir, 'commands'),
32-
guides: process.env.RI_GUIDES_PATH || join(homedir, 'guides'),
33-
defaultGuides: join(defaultsDir, 'guides'),
3432
tutorials: process.env.RI_TUTORIALS_PATH || join(homedir, 'tutorials'),
3533
defaultTutorials: join(defaultsDir, 'tutorials'),
3634
content: process.env.RI_CONTENT_PATH || join(homedir, 'content'),
@@ -47,7 +45,6 @@ export default {
4745
globalPrefix: 'api',
4846
customPluginsUri: '/plugins',
4947
staticUri: '/static',
50-
guidesUri: '/static/guides',
5148
tutorialsUri: '/static/tutorials',
5249
customTutorialsUri: '/static/custom-tutorials',
5350
contentUri: '/static/content',
@@ -110,23 +107,16 @@ export default {
110107
plugins: {
111108
stateMaxSize: parseInt(process.env.RI_PLUGIN_STATE_MAX_SIZE, 10) || 1024 * 1024,
112109
},
113-
guides: {
114-
updateUrl: process.env.RI_GUIDES_UPDATE_URL
115-
|| 'https://github.com/RedisInsight/Guides/releases/download/2.x.x',
116-
zip: process.env.RI_GUIDES_ZIP || dataZipFileName,
117-
buildInfo: process.env.RI_GUIDES_INFO || buildInfoFileName,
118-
devMode: !!process.env.RI_GUIDES_PATH,
119-
},
120110
tutorials: {
121111
updateUrl: process.env.RI_TUTORIALS_UPDATE_URL
122-
|| 'https://github.com/RedisInsight/Tutorials/releases/download/2.x.x',
112+
|| 'https://github.com/RedisInsight/Tutorials/releases/download/2.42',
123113
zip: process.env.RI_TUTORIALS_ZIP || dataZipFileName,
124114
buildInfo: process.env.RI_TUTORIALS_INFO || buildInfoFileName,
125115
devMode: !!process.env.RI_TUTORIALS_PATH,
126116
},
127117
content: {
128118
updateUrl: process.env.RI_CONTENT_UPDATE_URL
129-
|| 'https://github.com/RedisInsight/Statics/releases/download/latest',
119+
|| 'https://github.com/RedisInsight/Statics/releases/download/2.42',
130120
zip: process.env.RI_CONTENT_ZIP || dataZipFileName,
131121
buildInfo: process.env.RI_CONTENT_INFO || buildInfoFileName,
132122
devMode: !!process.env.RI_CONTENT_PATH,

redisinsight/api/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@
1010
},
1111
"scripts": {
1212
"build:defaults:commands": "ts-node ./scripts/default-commands.ts",
13-
"build:defaults:guides": "ts-node ./scripts/default-guides.ts",
1413
"build:defaults:tutorials": "ts-node ./scripts/default-tutorials.ts",
1514
"build:defaults:content": "ts-node ./scripts/default-content.ts",
16-
"build:defaults": "yarn build:defaults:guides && yarn build:defaults:commands && yarn build:defaults:content && yarn build:defaults:tutorials",
15+
"build:defaults": "yarn build:defaults:commands && yarn build:defaults:content && yarn build:defaults:tutorials",
1716
"prebuild": "rimraf dist",
1817
"build": "nest build",
1918
"build:prod": "rimraf dist && nest build -p ./tsconfig.build.prod.json && cross-env NODE_ENV=production",

redisinsight/api/scripts/default-guides.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

redisinsight/api/src/__mocks__/custom-tutorial.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export const mockCustomTutorialManifestJson = {
7474
type: CustomTutorialManifestType.InternalLink,
7575
id: 'introduction',
7676
label: 'introduction',
77+
summary: 'Introduction summary',
7778
args: {
7879
path: '/ct-folder-1/ct-sub-folder-1/introduction.md',
7980
},

redisinsight/api/src/init-helper.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,16 @@ export const migrateHomeFolder = async () => {
3838
// continue initialization even without migration
3939
}
4040
};
41+
42+
/**
43+
* Remove old guides folder
44+
*/
45+
export const removeGuidesFolder = async () => {
46+
try {
47+
if (await fs.pathExists(PATH_CONFIG.guides)) {
48+
await fs.rm(PATH_CONFIG.guides, { recursive: true, force: true });
49+
}
50+
} catch (e) {
51+
// continue initialization even without migration
52+
}
53+
};

redisinsight/api/src/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as bodyParser from 'body-parser';
77
import { WinstonModule } from 'nest-winston';
88
import { GlobalExceptionFilter } from 'src/exceptions/global-exception.filter';
99
import { get, Config } from 'src/utils';
10-
import { migrateHomeFolder } from 'src/init-helper';
10+
import { migrateHomeFolder, removeGuidesFolder } from 'src/init-helper';
1111
import { LogFileProvider } from 'src/modules/profiler/providers/log-file.provider';
1212
import { WindowsAuthAdapter } from 'src/modules/auth/window-auth/adapters/window-auth.adapter';
1313
import { AppModule } from './app.module';
@@ -24,6 +24,7 @@ interface IApp {
2424

2525
export default async function bootstrap(apiPort?: number): Promise<IApp> {
2626
await migrateHomeFolder();
27+
await removeGuidesFolder();
2728

2829
const { port, host } = serverConfig;
2930
const logger = WinstonModule.createLogger(LOGGER_CONFIG);

redisinsight/api/src/modules/custom-tutorial/models/custom-tutorial.manifest.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ export class CustomTutorialManifest {
6262
@IsNotEmpty()
6363
label: string;
6464

65+
@ApiProperty({ type: String })
66+
@IsOptional()
67+
@Expose()
68+
@IsString()
69+
@IsNotEmpty()
70+
summary?: string;
71+
6572
@ApiPropertyOptional({ type: CustomTutorialManifestArgs })
6673
@IsOptional()
6774
@Expose()

redisinsight/api/src/modules/statics-management/providers/auto-updated-statics.provider.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import config from 'src/utils/config';
44
import { AutoUpdatedStaticsProvider } from './auto-updated-statics.provider';
55

66
const PATH_CONFIG = config.get('dir_path');
7-
const GUIDES = config.get('guides');
7+
const TUTORIALS = config.get('tutorials');
88

99
jest.mock('axios');
1010
const mockedAxios = axios as jest.Mocked<typeof axios>;
@@ -26,13 +26,13 @@ describe('AutoUpdatedStaticsProvider', () => {
2626
jest.mock('adm-zip', () => jest.fn().mockImplementation(() => mockedAdmZip));
2727

2828
service = new AutoUpdatedStaticsProvider({
29-
name: 'GuidesProvider',
30-
destinationPath: PATH_CONFIG.guides,
31-
defaultSourcePath: PATH_CONFIG.defaultGuides,
32-
updateUrl: GUIDES.updateUrl,
33-
buildInfo: GUIDES.buildInfo,
34-
zip: GUIDES.zip,
35-
devMode: GUIDES.devMode,
29+
name: 'TutorialsProvider',
30+
destinationPath: PATH_CONFIG.tutorials,
31+
defaultSourcePath: PATH_CONFIG.defaultTutorials,
32+
updateUrl: TUTORIALS.updateUrl,
33+
buildInfo: TUTORIALS.buildInfo,
34+
zip: TUTORIALS.zip,
35+
devMode: TUTORIALS.devMode,
3636
});
3737
});
3838

redisinsight/api/src/modules/statics-management/statics-management.module.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,12 @@ import { AutoUpdatedStaticsProvider } from './providers/auto-updated-statics.pro
66

77
const SERVER_CONFIG = config.get('server') as Config['server'];
88
const PATH_CONFIG = config.get('dir_path') as Config['dir_path'];
9-
const GUIDES_CONFIG = config.get('guides') as Config['guides'];
109
const TUTORIALS_CONFIG = config.get('tutorials') as Config['tutorials'];
1110

1211
const CONTENT_CONFIG = config.get('content');
1312

1413
@Module({
1514
imports: [
16-
ServeStaticModule.forRoot({
17-
serveRoot: SERVER_CONFIG.guidesUri,
18-
rootPath: join(PATH_CONFIG.guides),
19-
serveStaticOptions: {
20-
fallthrough: false,
21-
},
22-
}),
2315
ServeStaticModule.forRoot({
2416
serveRoot: SERVER_CONFIG.tutorialsUri,
2517
rootPath: join(PATH_CONFIG.tutorials),
@@ -64,15 +56,6 @@ const CONTENT_CONFIG = config.get('content');
6456
}),
6557
],
6658
providers: [
67-
{
68-
provide: 'GuidesProvider',
69-
useFactory: () => new AutoUpdatedStaticsProvider({
70-
name: 'GuidesProvider',
71-
destinationPath: PATH_CONFIG.guides,
72-
defaultSourcePath: PATH_CONFIG.defaultGuides,
73-
...GUIDES_CONFIG,
74-
}),
75-
},
7659
{
7760
provide: 'TutorialsProvider',
7861
useFactory: () => new AutoUpdatedStaticsProvider({

0 commit comments

Comments
 (0)