mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
feat(core-blocks): CB-1199 support for external img
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { isValidUrl } from '@cloudbeaver/core-utils';
|
||||
|
||||
import { Icon } from './Icon';
|
||||
import { StaticImage } from './StaticImage';
|
||||
|
||||
@@ -19,13 +21,13 @@ export interface IconOrImageProps {
|
||||
viewBox?: string;
|
||||
}
|
||||
|
||||
export const IconOrImage = function IconOrImage({ icon, className, title, onClick, viewBox }: IconOrImageProps) {
|
||||
export const IconOrImage: React.FC<IconOrImageProps> = function IconOrImage({ icon, className, title, onClick, viewBox }) {
|
||||
const isStaticIcon = useMemo(
|
||||
() => icon && (icon.startsWith('platform:') || icon.startsWith('/')),
|
||||
[icon]
|
||||
);
|
||||
|
||||
if (isStaticIcon) {
|
||||
if (isStaticIcon || isValidUrl(icon)) {
|
||||
return <StaticImage title={title} icon={icon} className={className} onClick={onClick} />;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
|
||||
import { GlobalConstants } from '@cloudbeaver/core-utils';
|
||||
import { GlobalConstants, isValidUrl } from '@cloudbeaver/core-utils';
|
||||
|
||||
interface Props {
|
||||
icon?: string;
|
||||
@@ -22,7 +22,7 @@ export const StaticImage: React.FC<Props> = function StaticImage({
|
||||
return null;
|
||||
}
|
||||
|
||||
const url = GlobalConstants.absoluteUrl(icon);
|
||||
const url = isValidUrl(icon) ? icon : GlobalConstants.absoluteUrl(icon);
|
||||
|
||||
return <img className={className} src={url} title={title} onClick={onClick} />;
|
||||
};
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ export const AuthConfiguration: React.FC<Props> = observer(function AuthConfigur
|
||||
<TableItemExpand />
|
||||
</TableColumnValue>
|
||||
<TableColumnValue centerContent flex expand>
|
||||
<StaticImage icon={icon} />
|
||||
<StaticImage icon={icon} title={`${configuration.displayName} icon`} />
|
||||
</TableColumnValue>
|
||||
<TableColumnValue expand>{configuration.displayName}</TableColumnValue>
|
||||
<TableColumnValue>{configuration.providerId}</TableColumnValue>
|
||||
|
||||
Reference in New Issue
Block a user