File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
app/pages/DashBoardPage/components/WidgetManager/utils Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ import type {
27
27
import { Widget } from 'app/pages/DashBoardPage/types/widgetTypes' ;
28
28
import type { ChartStyleConfig } from 'app/types/ChartConfig' ;
29
29
import { getInitialLocale } from 'locales/utils' ;
30
- import { uuidv4 } from 'utils/utils' ;
30
+ import { universalUUID } from 'utils/utils' ;
31
31
32
32
export const initTitleTpl = ( ) => {
33
33
const titleTpl : ChartStyleConfig = {
@@ -472,7 +472,7 @@ export const initFreeWidgetRect = (): RectConfig => ({
472
472
473
473
export const widgetTpl = ( ) : Widget => {
474
474
return {
475
- id : uuidv4 ( ) ,
475
+ id : universalUUID ( ) ,
476
476
dashboardId : '' ,
477
477
datachartId : '' ,
478
478
relations : [ ] ,
@@ -502,7 +502,7 @@ export const widgetTpl = (): Widget => {
502
502
} ;
503
503
504
504
export const initClientId = ( ) => {
505
- return 'client_' + uuidv4 ( ) ;
505
+ return 'client_' + universalUUID ( ) ;
506
506
} ;
507
507
export const initWidgetName = ( i18nMap : object , local ?: string ) => {
508
508
if ( local && i18nMap [ local ] ) {
Original file line number Diff line number Diff line change @@ -10,10 +10,18 @@ import {
10
10
FONT_WEIGHT_REGULAR ,
11
11
} from 'styles/StyleConstants' ;
12
12
import { APIResponse } from 'types' ;
13
+ import { default as uuidv4 } from 'uuid/dist/umd/uuidv4.min' ;
13
14
import { SaveFormModel } from '../app/pages/MainPage/pages/VizPage/SaveFormContext' ;
14
15
import { removeToken } from './auth' ;
15
16
16
- export { default as uuidv4 } from 'uuid/dist/umd/uuidv4.min' ;
17
+ export { uuidv4 } ;
18
+
19
+ // For environments that do not support crypto.getRandomValues, such as nashorn.
20
+ export function universalUUID ( ) {
21
+ return typeof crypto === 'undefined'
22
+ ? `_${ Math . random ( ) . toString ( 36 ) . substring ( 2 ) } `
23
+ : uuidv4 ( ) ;
24
+ }
17
25
18
26
export function errorHandle ( error ) {
19
27
if ( error ?. response ) {
You can’t perform that action at this time.
0 commit comments