Skip to content

Commit

Permalink
do not show unsaved when there is no cahrt
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 committed Jun 18, 2020
1 parent b3fb6e8 commit 2434486
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { WorkspacePanel } from './workspace_panel';
import { Document } from '../../persistence/saved_object_store';
import { RootDragDropProvider } from '../../drag_drop';
import { getSavedObjectFormat } from './save';
import { WorkspacePanelWrapper } from './workspace_panel_wrapper';
import { generateId } from '../../id_generator';
import { Filter, Query, SavedQuery } from '../../../../../../src/plugins/data/public';
import { EditorFrameStartPlugins } from '../service';
Expand Down Expand Up @@ -275,31 +274,20 @@ export function EditorFrame(props: EditorFrameProps) {
}
workspacePanel={
allLoaded && (
<WorkspacePanelWrapper
<WorkspacePanel
title={state.title}
activeDatasourceId={state.activeDatasourceId}
activeVisualizationId={state.visualization.activeId}
datasourceMap={props.datasourceMap}
datasourceStates={state.datasourceStates}
framePublicAPI={framePublicAPI}
dispatch={dispatch}
visualizationState={state.visualization.state}
activeVisualization={
state.visualization.activeId
? props.visualizationMap[state.visualization.activeId]
: undefined
}
>
<WorkspacePanel
activeDatasourceId={state.activeDatasourceId}
activeVisualizationId={state.visualization.activeId}
datasourceMap={props.datasourceMap}
datasourceStates={state.datasourceStates}
framePublicAPI={framePublicAPI}
visualizationState={state.visualization.state}
visualizationMap={props.visualizationMap}
dispatch={dispatch}
ExpressionRenderer={props.ExpressionRenderer}
core={props.core}
plugins={props.plugins}
/>
</WorkspacePanelWrapper>
visualizationMap={props.visualizationMap}
dispatch={dispatch}
ExpressionRenderer={props.ExpressionRenderer}
core={props.core}
plugins={props.plugins}
/>
)
}
suggestionsPanel={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { trackUiEvent } from '../../lens_ui_telemetry';
import { UiActionsStart } from '../../../../../../src/plugins/ui_actions/public';
import { VIS_EVENT_TO_TRIGGER } from '../../../../../../src/plugins/visualizations/public';
import { DataPublicPluginStart } from '../../../../../../src/plugins/data/public';
import { WorkspacePanelWrapper } from './workspace_panel_wrapper';

export interface WorkspacePanelProps {
activeVisualizationId: string | null;
Expand All @@ -56,6 +57,7 @@ export interface WorkspacePanelProps {
ExpressionRenderer: ReactExpressionRendererType;
core: CoreStart | CoreSetup;
plugins: { uiActions?: UiActionsStart; data: DataPublicPluginStart };
title?: string;
}

export const WorkspacePanel = debouncedComponent(InnerWorkspacePanel);
Expand All @@ -73,6 +75,7 @@ export function InnerWorkspacePanel({
core,
plugins,
ExpressionRenderer: ExpressionRendererComponent,
title,
}: WorkspacePanelProps) {
const IS_DARK_THEME = core.uiSettings.get('theme:darkMode');
const emptyStateGraphicURL = IS_DARK_THEME
Expand Down Expand Up @@ -291,13 +294,22 @@ export function InnerWorkspacePanel({
}

return (
<DragDrop
data-test-subj="lnsWorkspace"
draggable={false}
droppable={Boolean(suggestionForDraggedField)}
onDrop={onDrop}
<WorkspacePanelWrapper
title={title}
framePublicAPI={framePublicAPI}
dispatch={dispatch}
emptyExpression={expression === null}
visualizationState={visualizationState}
activeVisualization={activeVisualization}
>
{renderVisualization()}
</DragDrop>
<DragDrop
data-test-subj="lnsWorkspace"
draggable={false}
droppable={Boolean(suggestionForDraggedField)}
onDrop={onDrop}
>
{renderVisualization()}
</DragDrop>
</WorkspacePanelWrapper>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('workspace_panel_wrapper', () => {
framePublicAPI={mockFrameAPI}
visualizationState={{}}
activeVisualization={mockVisualization}
emptyExpression={false}
>
<MyChild />
</WorkspacePanelWrapper>
Expand All @@ -51,6 +52,7 @@ describe('workspace_panel_wrapper', () => {
visualizationState={visState}
children={<span />}
activeVisualization={{ ...mockVisualization, renderToolbar: renderToolbarMock }}
emptyExpression={false}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ export interface WorkspacePanelWrapperProps {
children: React.ReactNode | React.ReactNode[];
framePublicAPI: FramePublicAPI;
visualizationState: unknown;
activeVisualization?: Visualization;
activeVisualization: Visualization | null;
dispatch: (action: Action) => void;
emptyExpression: boolean;
title?: string;
}

Expand All @@ -34,6 +35,7 @@ export function WorkspacePanelWrapper({
activeVisualization,
dispatch,
title,
emptyExpression,
}: WorkspacePanelWrapperProps) {
const setVisualizationState = useCallback(
(newState: unknown) => {
Expand Down Expand Up @@ -65,16 +67,18 @@ export function WorkspacePanelWrapper({
)}
<EuiFlexItem>
<EuiPageContent className="lnsWorkspacePanelWrapper">
<EuiPageContentHeader
className={classNames('lnsWorkspacePanelWrapper__pageContentHeader', {
'lnsWorkspacePanelWrapper__pageContentHeader--unsaved': !title,
})}
>
<span data-test-subj="lns_ChartTitle">
{title ||
i18n.translate('xpack.lens.chartTitle.unsaved', { defaultMessage: 'Unsaved' })}
</span>
</EuiPageContentHeader>
{!emptyExpression && (
<EuiPageContentHeader
className={classNames('lnsWorkspacePanelWrapper__pageContentHeader', {
'lnsWorkspacePanelWrapper__pageContentHeader--unsaved': !title,
})}
>
<span data-test-subj="lns_ChartTitle">
{title ||
i18n.translate('xpack.lens.chartTitle.unsaved', { defaultMessage: 'Unsaved' })}
</span>
</EuiPageContentHeader>
)}
<EuiPageContentBody className="lnsWorkspacePanelWrapper__pageContentBody">
{children}
</EuiPageContentBody>
Expand Down

0 comments on commit 2434486

Please sign in to comment.