浏览代码

reuse deprecationWarning

ryan 6 年之前
父节点
当前提交
f7f124c56b

+ 2 - 2
packages/grafana-ui/src/components/ColorPicker/warnAboutColorPickerPropsDeprecation.ts

@@ -1,9 +1,9 @@
-import propDeprecationWarning from '../../utils/propDeprecationWarning';
+import deprecationWarning from '../../utils/deprecationWarning';
 import { ColorPickerProps } from './ColorPickerPopover';
 import { ColorPickerProps } from './ColorPickerPopover';
 
 
 export const warnAboutColorPickerPropsDeprecation = (componentName: string, props: ColorPickerProps) => {
 export const warnAboutColorPickerPropsDeprecation = (componentName: string, props: ColorPickerProps) => {
   const { onColorChange } = props;
   const { onColorChange } = props;
   if (onColorChange) {
   if (onColorChange) {
-    propDeprecationWarning(componentName, 'onColorChange', 'onChange');
+    deprecationWarning(componentName, 'onColorChange', 'onChange');
   }
   }
 };
 };

+ 6 - 0
packages/grafana-ui/src/utils/deprecationWarning.ts

@@ -0,0 +1,6 @@
+const deprecationWarning = (file: string, oldName: string, newName: string) => {
+  const message = `[Deprecation warning] ${file}: ${oldName} is deprecated. Use ${newName} instead`;
+  console.warn(message);
+};
+
+export default deprecationWarning;

+ 1 - 0
packages/grafana-ui/src/utils/index.ts

@@ -3,4 +3,5 @@ export * from './valueFormats/valueFormats';
 export * from './colors';
 export * from './colors';
 export * from './namedColorsPalette';
 export * from './namedColorsPalette';
 export * from './string';
 export * from './string';
+export * from './deprecationWarning';
 export { getMappedValue } from './valueMappings';
 export { getMappedValue } from './valueMappings';

+ 0 - 6
packages/grafana-ui/src/utils/propDeprecationWarning.ts

@@ -1,6 +0,0 @@
-const propDeprecationWarning = (componentName: string, propName: string, newPropName: string) => {
-  const message = `[Deprecation warning] ${componentName}: ${propName} is deprecated. Use ${newPropName} instead`;
-  console.warn(message);
-};
-
-export default propDeprecationWarning;

+ 2 - 1
public/app/core/utils/kbn.ts

@@ -1,5 +1,6 @@
 import _ from 'lodash';
 import _ from 'lodash';
 import { getValueFormat, getValueFormatterIndex, getValueFormats, stringToJsRegex } from '@grafana/ui';
 import { getValueFormat, getValueFormatterIndex, getValueFormats, stringToJsRegex } from '@grafana/ui';
+import deprecationWarning from '@grafana/ui/src/utils/deprecationWarning';
 
 
 const kbn: any = {};
 const kbn: any = {};
 
 
@@ -230,7 +231,7 @@ kbn.slugifyForUrl = str => {
 
 
 /** deprecated since 6.1, use grafana/ui */
 /** deprecated since 6.1, use grafana/ui */
 kbn.stringToJsRegex = str => {
 kbn.stringToJsRegex = str => {
-  console.warn('Migrate stringToJsRegex to grafana/ui, ');
+  deprecationWarning('kbn.ts', 'kbn.stringToJsRegex()', '@grafana/ui');
   return stringToJsRegex(str);
   return stringToJsRegex(str);
 };
 };