## Description Query response tab UI update. Fixes #35290 ## Automation /ok-to-test tags="@tag.All" ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new `QueryResponseTab` component for managing query responses in the plugin action editor. - Added new icons for better visual representation in the application. - Enhanced the `NoResponse` component for improved layout and messaging. - Added a new constant for clearer user instructions on obtaining responses. - **Improvements** - Updated button labels and component structures for clarity and usability. - Refined validation logic and error handling across various components. - Enhanced styling and layout behavior in the `Table` and `ActionExecutionInProgressView` components. - Streamlined the `EntityBottomTabs` component's styling for consistency. - Adjusted the height of the response container during action execution. - **Bug Fixes** - Adjusted test cases to ensure accurate validation of response handling and UI elements. - **Chores** - Deprecated older methods and constants to streamline code and enhance maintainability. - Removed unused components to simplify the codebase. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
105 lines
2.6 KiB
TypeScript
105 lines
2.6 KiB
TypeScript
import React from "react";
|
|
import AnalyticsUtil from "ee/utils/AnalyticsUtil";
|
|
import { DEBUGGER_TAB_KEYS } from "./Debugger/constants";
|
|
import { Tab, TabPanel, Tabs, TabsList } from "@appsmith/ads";
|
|
import styled from "styled-components";
|
|
import { LIST_HEADER_HEIGHT, FOOTER_MARGIN } from "./Debugger/DebuggerLogs";
|
|
import type { RefObject } from "react";
|
|
|
|
const TabPanelWrapper = styled(TabPanel)`
|
|
margin-top: 0;
|
|
height: calc(100% - ${LIST_HEADER_HEIGHT});
|
|
|
|
&.ads-v2-tabs__panel {
|
|
overflow: auto;
|
|
}
|
|
|
|
& .t--code-editor-wrapper.codeWrapper {
|
|
height: calc(100% - ${FOOTER_MARGIN});
|
|
|
|
& .CodeMirror-scroll {
|
|
box-sizing: border-box;
|
|
}
|
|
}
|
|
`;
|
|
|
|
const TabsListWrapper = styled(TabsList)`
|
|
&& {
|
|
padding: var(--ads-v2-spaces-2);
|
|
padding-bottom: var(--ads-v2-spaces-1);
|
|
}
|
|
`;
|
|
|
|
export interface BottomTab {
|
|
key: string;
|
|
title: string;
|
|
count?: number;
|
|
panelComponent: React.ReactNode;
|
|
}
|
|
|
|
interface EntityBottomTabsProps {
|
|
className?: string;
|
|
tabs: Array<BottomTab>;
|
|
onSelect?: (tab: string) => void;
|
|
selectedTabKey: string;
|
|
isCollapsed?: boolean;
|
|
}
|
|
|
|
type CollapsibleEntityBottomTabsProps = EntityBottomTabsProps & {
|
|
// Reference to container for collapsing or expanding content
|
|
containerRef: RefObject<HTMLDivElement>;
|
|
// height of container when expanded( usually the default height of the tab component)
|
|
expandedHeight: string;
|
|
};
|
|
|
|
// Using this if there are debugger related tabs
|
|
function EntityBottomTabs(
|
|
props: EntityBottomTabsProps | CollapsibleEntityBottomTabsProps,
|
|
) {
|
|
const onTabSelect = (key: string) => {
|
|
const tab = props.tabs.find((tab) => tab.key === key);
|
|
|
|
if (tab) {
|
|
props.onSelect && props.onSelect(tab.key);
|
|
|
|
if (Object.values<string>(DEBUGGER_TAB_KEYS).includes(tab.key)) {
|
|
AnalyticsUtil.logEvent("DEBUGGER_TAB_SWITCH", {
|
|
tabName: tab.key,
|
|
});
|
|
}
|
|
}
|
|
};
|
|
|
|
return (
|
|
<Tabs
|
|
className="h-full"
|
|
defaultValue={props.selectedTabKey}
|
|
onValueChange={onTabSelect}
|
|
value={props.isCollapsed ? "" : props.selectedTabKey}
|
|
>
|
|
<TabsListWrapper>
|
|
{props.tabs.map((tab) => {
|
|
return (
|
|
<Tab
|
|
data-testid={"t--tab-" + tab.key}
|
|
id={`debugger-tab-${tab.key}`}
|
|
key={tab.key}
|
|
notificationCount={tab.count}
|
|
value={tab.key}
|
|
>
|
|
{tab.title}
|
|
</Tab>
|
|
);
|
|
})}
|
|
</TabsListWrapper>
|
|
{props.tabs.map((tab) => (
|
|
<TabPanelWrapper key={tab.key} value={tab.key}>
|
|
{tab.panelComponent}
|
|
</TabPanelWrapper>
|
|
))}
|
|
</Tabs>
|
|
);
|
|
}
|
|
|
|
export default EntityBottomTabs;
|