Skip to content

Commit

Permalink
Remove reporting config behavior from Canvas since it's no longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
poffdeluxe committed Jan 24, 2020
1 parent 25b4646 commit ad15369
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 106 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { jobCompletionNotifications } from '../../../../../reporting/public/lib/
// @ts-ignore Untyped local
import { getWorkpad, getPages } from '../../../state/selectors/workpad';
// @ts-ignore Untyped local
import { getHasReporting } from '../../../state/selectors/app';
// @ts-ignore Untyped local
import { notify } from '../../../lib/notify';
import { getWindow } from '../../../lib/get_window';
// @ts-ignore Untyped local
Expand All @@ -34,7 +32,6 @@ const { WorkpadHeaderWorkpadExport: strings } = ComponentStrings;
const mapStateToProps = (state: State) => ({
workpad: getWorkpad(state),
pageCount: getPages(state).length,
enabled: getHasReporting(state),
});

const getAbsoluteUrl = (path: string) => {
Expand All @@ -51,15 +48,13 @@ const getAbsoluteUrl = (path: string) => {
interface Props {
workpad: CanvasWorkpad;
pageCount: number;
enabled: boolean;
}

export const WorkpadExport = compose<ComponentProps, {}>(
connect(mapStateToProps),
withKibana,
withProps(
({ workpad, pageCount, enabled, kibana }: Props & WithKibanaProps): ComponentProps => ({
enabled,
({ workpad, pageCount, kibana }: Props & WithKibanaProps): ComponentProps => ({
getExportUrl: type => {
if (type === 'pdf') {
const pdfUrl = getPdfUrl(workpad, { pageCount }, kibana.services.http.basePath.prepend);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import PropTypes from 'prop-types';
import { EuiButtonIcon, EuiContextMenu, EuiIcon } from '@elastic/eui';
// @ts-ignore Untyped local
import { Popover } from '../../popover';
import { DisabledPanel } from './disabled_panel';
import { PDFPanel } from './pdf_panel';
import { ShareWebsiteFlyout } from './flyout';

Expand All @@ -29,8 +28,6 @@ export type OnCloseFn = (type: CloseTypes) => void;
export type GetExportUrlFn = (type: ExportUrlTypes) => string;

export interface Props {
/** True if exporting is enabled, false otherwise. */
enabled: boolean;
/** Handler to invoke when an export URL is copied to the clipboard. */
onCopy: OnCopyFn;
/** Handler to invoke when an end product is exported. */
Expand All @@ -42,12 +39,7 @@ export interface Props {
/**
* The Menu for Exporting a Workpad from Canvas.
*/
export const WorkpadExport: FunctionComponent<Props> = ({
enabled,
onCopy,
onExport,
getExportUrl,
}) => {
export const WorkpadExport: FunctionComponent<Props> = ({ onCopy, onExport, getExportUrl }) => {
const [showFlyout, setShowFlyout] = useState(false);

const onClose = () => {
Expand Down Expand Up @@ -106,16 +98,7 @@ export const WorkpadExport: FunctionComponent<Props> = ({
panel: {
id: 1,
title: strings.getShareDownloadPDFTitle(),
content: enabled ? (
getPDFPanel(closePopover)
) : (
<DisabledPanel
onCopy={() => {
onCopy('reportingConfig');
closePopover();
}}
/>
),
content: getPDFPanel(closePopover),
},
},
{
Expand Down Expand Up @@ -160,7 +143,6 @@ export const WorkpadExport: FunctionComponent<Props> = ({
};

WorkpadExport.propTypes = {
enabled: PropTypes.bool.isRequired,
onCopy: PropTypes.func.isRequired,
onExport: PropTypes.func.isRequired,
getExportUrl: PropTypes.func.isRequired,
Expand Down
10 changes: 1 addition & 9 deletions x-pack/legacy/plugins/canvas/public/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,7 @@ const shimCoreSetup = {
const shimCoreStart = {
...npStart.core,
};
const shimSetupPlugins = {
// When the frontend Canvas plugin is moved to NP, we can declare reporting as an optional dependency
// and enable exports based on existence of the plugin.
// For now, use an injected config to mimic this behavior in the meantime.
reporting:
npSetup.core && npSetup.core.injectedMetadata.getInjectedVar('reportingBrowserType')
? {}
: undefined,
};
const shimSetupPlugins = {};

const shimStartPlugins: CanvasStartDeps = {
...npStart.plugins,
Expand Down
5 changes: 1 addition & 4 deletions x-pack/legacy/plugins/canvas/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ export { CoreStart };
* @internal
*/
// This interface will be built out as we require other plugins for setup
export interface CanvasSetupDeps {
reporting?: {};
}
export interface CanvasSetupDeps {} // eslint-disable-line @typescript-eslint/no-empty-interface
export interface CanvasStartDeps {
reporting?: {};
__LEGACY: {
absoluteToParsedUrl: (url: string, basePath: string) => any;
formatMsg: any;
Expand Down
4 changes: 0 additions & 4 deletions x-pack/legacy/plugins/canvas/public/state/selectors/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ export function getBasePath(state: State): State['app']['basePath'] {
return state.app.basePath;
}

export function getHasReporting(state: State): State['app']['hasReporting'] {
return state.app.hasReporting;
}

// return true only when the required parameters are in the state
export function isAppReady(state: State): boolean {
const appReady = getAppReady(state);
Expand Down
2 changes: 0 additions & 2 deletions x-pack/legacy/plugins/canvas/public/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ export async function createStore(core: CoreSetup, plugins: CanvasSetupDeps) {
const initialState = getInitialState();

const basePath = core.http.basePath.get();
const hasReporting = !!plugins.reporting;

// Retrieve server functions
const serverFunctionsResponse = await core.http.get(`/api/interpreter/fns`);
const serverFunctions = Object.values(serverFunctionsResponse);

initialState.app = {
basePath,
hasReporting,
serverFunctions,
ready: false,
};
Expand Down
10 changes: 0 additions & 10 deletions x-pack/legacy/plugins/canvas/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,8 @@ export class Plugin {
plugins.interpreter.register({ serverFunctions: functions });

core.injectUiAppVars('canvas', async () => {
const config = core.getServerConfig();
const reportingBrowserType = (() => {
const configKey = 'xpack.reporting.capture.browser.type';
if (!config.has(configKey)) {
return null;
}
return config.get(configKey);
})();

return {
...plugins.kibana.injectedUiAppVars,
reportingBrowserType,
};
});

Expand Down
1 change: 0 additions & 1 deletion x-pack/legacy/plugins/canvas/types/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export interface AppState {

interface StoreAppState {
basePath: string;
hasReporting: boolean;
// TODO: These server functions are actually missing the fn because they are serialized from the server
serverFunctions: CanvasFunction[];
ready: boolean;
Expand Down

0 comments on commit ad15369

Please sign in to comment.