import React from 'react';
import { Icon } from '@teambit/design.elements.icon';
import { Tooltip } from '@teambit/design.ui.tooltip';
import { useCompareData } from '@teambit/component.ui.component-compare.component-compare';
import styles from './base-source-indicator.module.scss';
export type BaseSourceIndicatorProps = {
/** the compare-side id of the pair, used to look up the bulk-compare load state for this base */
compareId: string;
};
/**
* Surfaces that a component's compared base was pulled from the remote scope (rather than already
* being in the workspace), plus its load state. The caller renders this only for remote-sourced
* bases; workspace-resolved bases show nothing.
* - spinner: the base diff is still being fetched from the remote.
* - error: the base diff failed to load from the remote.
* - cloud: the base was resolved from the remote scope and its diff is ready.
*/
export function BaseSourceIndicator({ compareId }: BaseSourceIndicatorProps) {
const compareData = useCompareData();
const data = compareData?.compareDataFor(compareId);
const loading = Boolean(compareData?.loading) && data === undefined;
if (loading) {
return (
);
}
if (data === null) {
return (
);
}
return (
);
}