-
Notifications
You must be signed in to change notification settings - Fork 8.3k
/
plugin.ts
55 lines (47 loc) · 1.96 KB
/
plugin.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { i18n } from '@kbn/i18n';
import { CoreSetup, CoreStart, Logger, Plugin, PluginInitializerContext } from 'src/core/server';
import { schema } from '@kbn/config-schema';
import { fileUploadRoutes } from './routes';
import { initFileUploadTelemetry } from './telemetry';
import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/server';
import { UI_SETTING_MAX_FILE_SIZE, MAX_FILE_SIZE } from '../common';
import { StartDeps } from './types';
interface SetupDeps {
usageCollection: UsageCollectionSetup;
}
export class FileUploadPlugin implements Plugin {
private readonly _logger: Logger;
constructor(initializerContext: PluginInitializerContext) {
this._logger = initializerContext.logger.get();
}
async setup(coreSetup: CoreSetup<StartDeps, unknown>, plugins: SetupDeps) {
fileUploadRoutes(coreSetup, this._logger);
coreSetup.uiSettings.register({
[UI_SETTING_MAX_FILE_SIZE]: {
name: i18n.translate('xpack.fileUpload.maxFileSizeUiSetting.name', {
defaultMessage: 'Maximum file upload size',
}),
value: MAX_FILE_SIZE,
description: i18n.translate('xpack.fileUpload.maxFileSizeUiSetting.description', {
defaultMessage:
'Sets the file size limit when importing files. The highest supported value for this setting is 1GB.',
}),
schema: schema.string(),
validation: {
regexString: '\\d+[mMgG][bB]',
message: i18n.translate('xpack.fileUpload.maxFileSizeUiSetting.error', {
defaultMessage: 'Should be a valid data size. e.g. 200MB, 1GB',
}),
},
},
});
initFileUploadTelemetry(coreSetup, plugins.usageCollection);
}
start(core: CoreStart) {}
}