Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

1.6 KB
Raw Blame
import { MissingWidgetFrame, WidgetRendererById } from '@workbench/widget-frame';
import { areWidgetRenderInstancesEqual } from '@workbench/widget-frame/widgetRenderInstance';
import { resolveWidgetLabel } from '@workbench/widgetLabels';
import { getWidgetById } from '@workbench/widgetRegistry';
import { useActiveProjectSelector } from '@workbench/WorkbenchContext';
import { useTranslation } from 'react-i18next';

export const BottomPanel = () => {
  const { t } = useTranslation();
  const panels = useActiveProjectSelector((project) => project.layout.panels);
  const bottomRegion = useActiveProjectSelector((project) => project.widgetRegions.bottom);
  const instance = useActiveProjectSelector(
    (project) => project.widgetInstances[bottomRegion.activeInstanceId],
    areWidgetRenderInstancesEqual
  );
  const widget = instance ? getWidgetById(instance.typeId) : undefined;
  const canShowBottomPanel =
    panels.isBottomOpen &&
    !bottomRegion.isCollapsed &&
    bottomRegion.instanceIds.includes(bottomRegion.activeInstanceId) &&
    widget?.status === 'enabled' &&
    widget.manifest.bottomPanel !== 'tooltip' &&
    widget.manifest.bottomPanel !== 'popover';

  if (!canShowBottomPanel) {
    return null;
  }

  if (!instance || !widget) {
    return (
      <MissingWidgetFrame
        instanceId={bottomRegion.activeInstanceId}
        label={widget ? resolveWidgetLabel(widget.manifest, t) : bottomRegion.activeInstanceId}
        region="bottom"
        typeId={instance?.typeId}
      />
    );
  }

  return <WidgetRendererById instanceId={instance.id} widget={widget} presentation="expanded" region="bottom" />;
};