mirror of https://github.com/buster-so/buster.git
Remove "mode" from followup
Removed mode from followup asset content. It was logically impossible to have a mode with a metric. Falling back to just asset type.
This commit is contained in:
parent
523a6921b1
commit
e6d4628a5f
|
@ -2,10 +2,11 @@ import React, { useMemo } from 'react';
|
|||
import { useGetMetric } from '@/api/buster_rest/metrics';
|
||||
import { useChatLayoutContextSelector } from '@/layouts/ChatLayout';
|
||||
import { DropdownContent, DropdownItems, type DropdownItem } from '@/components/ui/dropdown';
|
||||
import { History, Star } from '@/components/ui/icons';
|
||||
import { History, Star, WandSparkle } from '@/components/ui/icons';
|
||||
import { Star as StarFilled } from '@/components/ui/icons/NucleoIconFilled';
|
||||
import { useListVersionDropdownItems } from '../versionHistory/useListVersionDropdownItems';
|
||||
import { useFavoriteStar } from '../list';
|
||||
import { FollowUpWithAssetContent } from '../popups/FollowUpWithAsset';
|
||||
|
||||
export const useVersionHistorySelectMenu = ({ metricId }: { metricId: string }): DropdownItem => {
|
||||
const chatId = useChatLayoutContextSelector((x) => x.chatId);
|
||||
|
@ -69,3 +70,23 @@ export const useFavoriteMetricSelectMenu = ({ metricId }: { metricId: string })
|
|||
|
||||
return item;
|
||||
};
|
||||
|
||||
export const useMetricDrilldownItem = ({ metricId }: { metricId: string }): DropdownItem => {
|
||||
return useMemo(
|
||||
() => ({
|
||||
value: 'drilldown',
|
||||
label: 'Drill down & filter',
|
||||
items: [
|
||||
<FollowUpWithAssetContent
|
||||
key="drilldown-and-filter"
|
||||
assetType="metric"
|
||||
assetId={metricId}
|
||||
placeholder="Describe how you want to drill down or filter..."
|
||||
buttonText="Submit request"
|
||||
/>
|
||||
],
|
||||
icon: <WandSparkle />
|
||||
}),
|
||||
[metricId]
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
import React, { useMemo } from 'react';
|
||||
import type { DropdownItem } from '@/components/ui/dropdown';
|
||||
import { WandSparkle } from '@/components/ui/icons';
|
||||
import { FollowUpWithAssetContent } from '@/components/features/popups/FollowUpWithAsset';
|
||||
|
||||
export const useMetricDrilldownItem = ({ metricId }: { metricId: string }): DropdownItem => {
|
||||
return useMemo(
|
||||
() => ({
|
||||
value: 'drilldown',
|
||||
label: 'Drill down & filter',
|
||||
items: [
|
||||
<FollowUpWithAssetContent
|
||||
key="drilldown-and-filter"
|
||||
assetType="metric"
|
||||
assetId={metricId}
|
||||
placeholder="Describe how you want to drill down or filter..."
|
||||
buttonText="Submit request"
|
||||
mode="drilldown"
|
||||
/>
|
||||
],
|
||||
icon: <WandSparkle />
|
||||
}),
|
||||
[metricId]
|
||||
);
|
||||
};
|
|
@ -3,12 +3,10 @@ import { Popover, type PopoverProps } from '../../ui/popover';
|
|||
import { InputCard } from '../../ui/card/InputCard';
|
||||
import type { ShareAssetType } from '@buster/server-shared/share';
|
||||
import { useMemoizedFn } from '../../../hooks';
|
||||
import { useStartChatFromAsset } from '../../../api/buster_rest/chats';
|
||||
import { useStartChatFromAsset } from '@/api/buster_rest/chats';
|
||||
import { AppTooltip } from '../../ui/tooltip';
|
||||
import { useAppLayoutContextSelector } from '@/context/BusterAppLayout';
|
||||
import { assetParamsToRoute } from '../../../lib/assets';
|
||||
|
||||
type FollowUpMode = 'filter' | 'drilldown';
|
||||
import { assetParamsToRoute } from '@/lib/assets';
|
||||
|
||||
type FollowUpWithAssetProps = {
|
||||
assetType: Exclude<ShareAssetType, 'chat' | 'collection'>;
|
||||
|
@ -18,7 +16,6 @@ type FollowUpWithAssetProps = {
|
|||
align?: PopoverProps['align'];
|
||||
placeholder?: string;
|
||||
buttonText?: string;
|
||||
mode?: FollowUpMode;
|
||||
};
|
||||
|
||||
export const FollowUpWithAssetContent: React.FC<{
|
||||
|
@ -26,26 +23,22 @@ export const FollowUpWithAssetContent: React.FC<{
|
|||
assetId: string;
|
||||
placeholder?: string;
|
||||
buttonText?: string;
|
||||
mode?: FollowUpMode;
|
||||
}> = React.memo(
|
||||
({
|
||||
assetType,
|
||||
assetId,
|
||||
placeholder = 'Describe the filter you want to apply',
|
||||
buttonText = 'Apply custom filter',
|
||||
mode
|
||||
buttonText = 'Apply custom filter'
|
||||
}) => {
|
||||
const { mutateAsync: startChatFromAsset, isPending } = useStartChatFromAsset();
|
||||
const onChangePage = useAppLayoutContextSelector((x) => x.onChangePage);
|
||||
|
||||
const transformPrompt = useMemoizedFn((userPrompt: string): string => {
|
||||
if (!mode) return userPrompt;
|
||||
|
||||
if (mode === 'filter') {
|
||||
if (assetType === 'dashboard') {
|
||||
return `Hey Buster. Please recreate this dashboard applying this filter to the metrics on the dashboard: ${userPrompt}`;
|
||||
}
|
||||
|
||||
if (mode === 'drilldown') {
|
||||
if (assetType === 'metric') {
|
||||
return `Hey Buster. Can you filter or drill down into this metric based on the following request: ${userPrompt}`;
|
||||
}
|
||||
|
||||
|
@ -55,12 +48,10 @@ export const FollowUpWithAssetContent: React.FC<{
|
|||
const onSubmit = useMemoizedFn(async (prompt: string) => {
|
||||
if (!prompt || !assetId || !assetType || isPending) return;
|
||||
|
||||
const transformedPrompt = transformPrompt(prompt);
|
||||
|
||||
const res = await startChatFromAsset({
|
||||
asset_id: assetId,
|
||||
asset_type: assetType,
|
||||
prompt: transformedPrompt
|
||||
prompt: transformPrompt(prompt)
|
||||
});
|
||||
const link = assetParamsToRoute({
|
||||
assetId,
|
||||
|
@ -85,16 +76,7 @@ export const FollowUpWithAssetContent: React.FC<{
|
|||
FollowUpWithAssetContent.displayName = 'FollowUpWithAssetContent';
|
||||
|
||||
export const FollowUpWithAssetPopup: React.FC<FollowUpWithAssetProps> = React.memo(
|
||||
({
|
||||
assetType,
|
||||
assetId,
|
||||
side = 'bottom',
|
||||
align = 'end',
|
||||
children,
|
||||
placeholder,
|
||||
buttonText,
|
||||
mode
|
||||
}) => {
|
||||
({ assetType, assetId, side = 'bottom', align = 'end', children, placeholder, buttonText }) => {
|
||||
return (
|
||||
<Popover
|
||||
side={side}
|
||||
|
@ -106,7 +88,6 @@ export const FollowUpWithAssetPopup: React.FC<FollowUpWithAssetProps> = React.me
|
|||
assetId={assetId}
|
||||
placeholder={placeholder}
|
||||
buttonText={buttonText}
|
||||
mode={mode}
|
||||
/>
|
||||
}>
|
||||
<AppTooltip title="Apply custom filter">{children}</AppTooltip>
|
||||
|
|
|
@ -24,9 +24,9 @@ import { useStartChatFromAsset } from '@/api/buster_rest/chats';
|
|||
import { useAppLayoutContextSelector } from '@/context/BusterAppLayout';
|
||||
import {
|
||||
useFavoriteMetricSelectMenu,
|
||||
useVersionHistorySelectMenu
|
||||
useVersionHistorySelectMenu,
|
||||
useMetricDrilldownItem
|
||||
} from '@/components/features/metrics/ThreeDotMenu';
|
||||
import { useMetricDrilldownItem } from '@/components/features/metrics/hooks/useMetricDrilldownItem';
|
||||
|
||||
export const MetricItemCardThreeDotMenu: React.FC<{
|
||||
dashboardId: string;
|
||||
|
|
|
@ -84,7 +84,7 @@ AddContentToDashboardButton.displayName = 'AddContentToDashboardButton';
|
|||
|
||||
const FollowUpWithAssetButton = React.memo(({ dashboardId }: { dashboardId: string }) => {
|
||||
return (
|
||||
<FollowUpWithAssetPopup assetId={dashboardId} assetType="dashboard" mode="filter">
|
||||
<FollowUpWithAssetPopup assetId={dashboardId} assetType="dashboard">
|
||||
<Button variant="ghost" prefix={<BarsFilter />} />
|
||||
</FollowUpWithAssetPopup>
|
||||
);
|
||||
|
|
|
@ -15,12 +15,10 @@ import {
|
|||
import { ASSET_ICONS } from '@/components/features/config/assetIcons';
|
||||
import { useSaveToCollectionsDropdownContent } from '@/components/features/dropdowns/SaveToCollectionsDropdown';
|
||||
import { useSaveToDashboardDropdownContent } from '@/components/features/dropdowns/SaveToDashboardDropdown';
|
||||
import { useFavoriteStar } from '@/components/features/list/FavoriteStar';
|
||||
import { StatusBadgeIndicator } from '@/components/features/metrics/StatusBadgeIndicator';
|
||||
import { useStatusDropdownContent } from '@/components/features/metrics/StatusBadgeIndicator/useStatusDropdownContent';
|
||||
import { getShareAssetConfig } from '@/components/features/ShareMenu/helpers';
|
||||
import { ShareMenuContent } from '@/components/features/ShareMenu/ShareMenuContent';
|
||||
import { useListVersionDropdownItems } from '@/components/features/versionHistory/useListVersionDropdownItems';
|
||||
import { Button } from '@/components/ui/buttons';
|
||||
import {
|
||||
Dropdown,
|
||||
|
@ -32,17 +30,14 @@ import {
|
|||
ArrowUpRight,
|
||||
Dots,
|
||||
Download4,
|
||||
History,
|
||||
Pencil,
|
||||
ShareRight,
|
||||
SquareChart,
|
||||
SquareChartPen,
|
||||
SquareCode,
|
||||
Star,
|
||||
Table,
|
||||
Trash
|
||||
} from '@/components/ui/icons';
|
||||
import { Star as StarFilled } from '@/components/ui/icons/NucleoIconFilled';
|
||||
import { useAppLayoutContextSelector } from '@/context/BusterAppLayout';
|
||||
import { useBusterNotifications } from '@/context/BusterNotifications';
|
||||
import { useUserConfigContextSelector } from '@/context/Users';
|
||||
|
@ -57,13 +52,13 @@ import {
|
|||
import { timeout } from '@/lib';
|
||||
import { downloadElementToImage, exportJSONToCSV } from '@/lib/exportUtils';
|
||||
import { canEdit, getIsEffectiveOwner, getIsOwner } from '@/lib/share';
|
||||
import { BusterRoutes, createBusterRoute } from '@/routes';
|
||||
import { BusterRoutes } from '@/routes';
|
||||
import { assetParamsToRoute } from '@/lib/assets';
|
||||
import {
|
||||
useFavoriteMetricSelectMenu,
|
||||
useVersionHistorySelectMenu
|
||||
useVersionHistorySelectMenu,
|
||||
useMetricDrilldownItem
|
||||
} from '@/components/features/metrics/ThreeDotMenu';
|
||||
import { useMetricDrilldownItem } from '@/components/features/metrics/hooks/useMetricDrilldownItem';
|
||||
|
||||
export const ThreeDotMenuButton = React.memo(
|
||||
({
|
||||
|
|
Loading…
Reference in New Issue