mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
fix(plugin-data-viewer): CB-751 hide empty value panel
This commit is contained in:
@@ -74,17 +74,18 @@ export class DataPresentationService {
|
||||
|
||||
getSupportedList(
|
||||
type: DataPresentationType,
|
||||
dataFormat: ResultDataFormat[],
|
||||
supportedDataFormats: ResultDataFormat[],
|
||||
dataFormat: ResultDataFormat,
|
||||
model: IDatabaseDataModel<any>,
|
||||
resultIndex: number,
|
||||
): IDataPresentation[] {
|
||||
return Array.from(this.dataPresentations.values()).filter(presentation => {
|
||||
if (presentation.type !== type || presentation.hidden?.(null, model, resultIndex)) {
|
||||
if (presentation.type !== type || presentation.hidden?.(dataFormat, model, resultIndex)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return presentation.dataFormat === undefined
|
||||
|| dataFormat.includes(presentation.dataFormat);
|
||||
|| supportedDataFormats.includes(presentation.dataFormat);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -99,6 +100,9 @@ export class DataPresentationService {
|
||||
const presentation = this.dataPresentations.get(presentationId);
|
||||
|
||||
if (presentation) {
|
||||
if (presentation.hidden?.(dataFormat, model, resultIndex)) {
|
||||
return null;
|
||||
}
|
||||
return presentation;
|
||||
}
|
||||
}
|
||||
|
||||
+9
-1
@@ -50,6 +50,7 @@ const styles = composes(
|
||||
interface Props {
|
||||
type: DataPresentationType;
|
||||
presentationId: string | null | undefined;
|
||||
dataFormat: ResultDataFormat;
|
||||
supportedDataFormat: ResultDataFormat[];
|
||||
model: IDatabaseDataModel<any>;
|
||||
resultIndex: number;
|
||||
@@ -61,6 +62,7 @@ export const TablePresentationBar = observer(function TablePresentationBar({
|
||||
type,
|
||||
presentationId,
|
||||
supportedDataFormat,
|
||||
dataFormat,
|
||||
model,
|
||||
resultIndex,
|
||||
className,
|
||||
@@ -68,7 +70,13 @@ export const TablePresentationBar = observer(function TablePresentationBar({
|
||||
}: Props) {
|
||||
const style = useStyles(styles, verticalRotatedTabStyles);
|
||||
const dataPresentationService = useService(DataPresentationService);
|
||||
const presentations = dataPresentationService.getSupportedList(type, supportedDataFormat, model, resultIndex);
|
||||
const presentations = dataPresentationService.getSupportedList(
|
||||
type,
|
||||
supportedDataFormat,
|
||||
dataFormat,
|
||||
model,
|
||||
resultIndex
|
||||
);
|
||||
const Tab = PresentationTab; // alias for styles matching
|
||||
const changePresentation = ({ tabId }: ITabData<any>) => onPresentationChange(tabId);
|
||||
|
||||
|
||||
@@ -205,6 +205,7 @@ export const TableViewer = observer(function TableViewer({
|
||||
<TablePresentationBar
|
||||
type={DataPresentationType.main}
|
||||
presentationId={presentation.id}
|
||||
dataFormat={dataFormat}
|
||||
supportedDataFormat={dataModel.supportedDataFormats}
|
||||
model={dataModel}
|
||||
resultIndex={resultIndex}
|
||||
@@ -258,6 +259,7 @@ export const TableViewer = observer(function TableViewer({
|
||||
<TablePresentationBar
|
||||
type={DataPresentationType.toolsPanel}
|
||||
presentationId={valuePresentationId ?? null}
|
||||
dataFormat={dataFormat}
|
||||
supportedDataFormat={[dataFormat]}
|
||||
model={dataModel}
|
||||
resultIndex={resultIndex}
|
||||
|
||||
+6
-1
@@ -36,7 +36,12 @@ export class DataValuePanelService {
|
||||
}
|
||||
|
||||
getDisplayed(props?: IDataValuePanelProps<any>): Array<ITabInfo<IDataValuePanelProps<any>, IDataValuePanelOptions>> {
|
||||
return this.tabs.getDisplayed(props);
|
||||
return this.tabs.getDisplayed(props).filter(
|
||||
info => (
|
||||
(props?.dataFormat === undefined || props.dataFormat === null)
|
||||
|| info.options?.dataFormat.includes(props.dataFormat)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
add(tabInfo: ITabInfoOptions<IDataValuePanelProps<any>, IDataValuePanelOptions>): void {
|
||||
|
||||
Reference in New Issue
Block a user