mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-01 20:04:52 +00:00
fix(ui): pick right mode env production / dev (#23272)
* fix(ui): pick right mode env production / dev * fix unit tests
This commit is contained in:
parent
b6f9ed4a5b
commit
cb5bcdbb9c
@ -144,3 +144,7 @@ jest.mock('./utils/AdvancedSearchClassBase', () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
jest.mock('./utils/EnvironmentUtils', () => ({
|
||||||
|
isDev: jest.fn().mockReturnValue('test'),
|
||||||
|
}));
|
||||||
|
@ -11,10 +11,15 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import process from 'process';
|
const development: boolean = (() => {
|
||||||
|
// Use Vite's import.meta.env which is properly typed now
|
||||||
|
if (typeof import.meta !== 'undefined' && import.meta.env) {
|
||||||
|
return import.meta.env.MODE === 'development';
|
||||||
|
}
|
||||||
|
|
||||||
const development: boolean =
|
// Fallback to process.env (defined by Vite's define option)
|
||||||
!process.env.NODE_ENV || process.env.NODE_ENV === 'development';
|
return !process.env.NODE_ENV || process.env.NODE_ENV === 'development';
|
||||||
|
})();
|
||||||
|
|
||||||
export const isDev = (): boolean => {
|
export const isDev = (): boolean => {
|
||||||
return development;
|
return development;
|
||||||
|
@ -371,7 +371,7 @@ class ServiceUtilClassBase {
|
|||||||
return EntityType.TABLE;
|
return EntityType.TABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getServiceLogo(type: string) {
|
public getServiceLogo(type: string): string {
|
||||||
const serviceTypes = this.getSupportedServiceFromList();
|
const serviceTypes = this.getSupportedServiceFromList();
|
||||||
switch (toLower(type)) {
|
switch (toLower(type)) {
|
||||||
case this.DatabaseServiceTypeSmallCase.CustomDatabase:
|
case this.DatabaseServiceTypeSmallCase.CustomDatabase:
|
||||||
@ -684,7 +684,7 @@ class ServiceUtilClassBase {
|
|||||||
|
|
||||||
public getServiceTypeLogo(
|
public getServiceTypeLogo(
|
||||||
searchSource: SearchSuggestions[number] | SearchSourceAlias
|
searchSource: SearchSuggestions[number] | SearchSourceAlias
|
||||||
) {
|
): string {
|
||||||
const type = get(searchSource, 'serviceType', '');
|
const type = get(searchSource, 'serviceType', '');
|
||||||
const entityType = get(searchSource, 'entityType', '');
|
const entityType = get(searchSource, 'entityType', '');
|
||||||
|
|
||||||
|
@ -57,9 +57,9 @@ export const formatDateTimeLong = (timestamp?: number, format?: string) => {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return DateTime.fromMillis(toNumber(timestamp), { locale: i18next.language }).toFormat(
|
return DateTime.fromMillis(toNumber(timestamp), {
|
||||||
format ?? DATE_TIME_WITH_OFFSET_FORMAT
|
locale: i18next.language,
|
||||||
);
|
}).toFormat(format ?? DATE_TIME_WITH_OFFSET_FORMAT);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -121,9 +121,9 @@ export const customFormatDateTime = (
|
|||||||
return formatDateTime(milliseconds);
|
return formatDateTime(milliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DateTime.fromMillis(milliseconds, { locale: i18next.language }).toFormat(
|
return DateTime.fromMillis(milliseconds, {
|
||||||
format
|
locale: i18next.language,
|
||||||
);
|
}).toFormat(format);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -133,7 +133,9 @@ export const customFormatDateTime = (
|
|||||||
*/
|
*/
|
||||||
export const getRelativeTime = (timeStamp?: number): string => {
|
export const getRelativeTime = (timeStamp?: number): string => {
|
||||||
return !isNil(timeStamp)
|
return !isNil(timeStamp)
|
||||||
? DateTime.fromMillis(timeStamp, { locale: i18next.language }).toRelative() ?? ''
|
? DateTime.fromMillis(timeStamp, {
|
||||||
|
locale: i18next.language,
|
||||||
|
}).toRelative() ?? ''
|
||||||
: '';
|
: '';
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -176,7 +178,9 @@ export const getRelativeCalendar = (
|
|||||||
baseTimeStamp?: number
|
baseTimeStamp?: number
|
||||||
): string => {
|
): string => {
|
||||||
return capitalize(
|
return capitalize(
|
||||||
DateTime.fromMillis(timeStamp, { locale: i18next.language }).toRelativeCalendar({
|
DateTime.fromMillis(timeStamp, {
|
||||||
|
locale: i18next.language,
|
||||||
|
}).toRelativeCalendar({
|
||||||
base: baseTimeStamp
|
base: baseTimeStamp
|
||||||
? DateTime.fromMillis(baseTimeStamp, { locale: i18next.language })
|
? DateTime.fromMillis(baseTimeStamp, { locale: i18next.language })
|
||||||
: DateTime.now(),
|
: DateTime.now(),
|
||||||
|
26
openmetadata-ui/src/main/resources/ui/src/vite-env.d.ts
vendored
Normal file
26
openmetadata-ui/src/main/resources/ui/src/vite-env.d.ts
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2025 Collate.
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
// eslint-disable-next-line spaced-comment
|
||||||
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
|
interface ImportMetaEnv {
|
||||||
|
readonly MODE: string;
|
||||||
|
readonly BASE_URL: string;
|
||||||
|
readonly PROD: boolean;
|
||||||
|
readonly DEV: boolean;
|
||||||
|
// Add other env variables as needed
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ImportMeta {
|
||||||
|
readonly env: ImportMetaEnv;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user