Skip to content

Commit

Permalink
Don't pass start services to all share-to-space components
Browse files Browse the repository at this point in the history
  • Loading branch information
jportner committed Oct 1, 2020
1 parent c55dca3 commit 64a5b84
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { CoreStart } from 'src/core/public';
import { NoSpacesAvailable } from './no_spaces_available';
import { useKibana } from '../../../../../../src/plugins/kibana_react/public';
import { ALL_SPACES_ID, UNKNOWN_SPACE } from '../../../common/constants';
import { DocumentationLinksService } from '../../lib';
import { SpaceAvatar } from '../../space_avatar';
import { SpaceTarget } from '../types';

interface Props {
coreStart: CoreStart;
spaces: SpaceTarget[];
selectedSpaceIds: string[];
onChange: (selectedSpaceIds: string[]) => void;
Expand All @@ -43,8 +42,9 @@ const activeSpaceProps = {
};

export const SelectableSpacesControl = (props: Props) => {
const { coreStart, spaces, selectedSpaceIds, onChange } = props;
const { application, docLinks } = coreStart;
const { spaces, selectedSpaceIds, onChange } = props;
const { services } = useKibana();
const { application, docLinks } = services;

const isGlobalControlChecked = selectedSpaceIds.includes(ALL_SPACES_ID);
const options = spaces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ import {
EuiTitle,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { CoreStart } from 'src/core/public';
import { SelectableSpacesControl } from './selectable_spaces_control';
import { ALL_SPACES_ID } from '../../../common/constants';
import { SpaceTarget } from '../types';

interface Props {
coreStart: CoreStart;
spaces: SpaceTarget[];
canShareToAllSpaces: boolean;
selectedSpaceIds: string[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { ToastsStart, StartServicesAccessor, CoreStart } from 'src/core/public';
import { SavedObjectsManagementRecord } from '../../../../../../src/plugins/saved_objects_management/public';
import { createKibanaReactContext } from '../../../../../../src/plugins/kibana_react/public';
import { ALL_SPACES_ID, UNKNOWN_SPACE } from '../../../common/constants';
import { Space } from '../../../common/model/space';
import { SpacesManager } from '../../spaces_manager';
Expand Down Expand Up @@ -207,17 +208,23 @@ export const ShareSavedObjectsToSpaceFlyout = (props: Props) => {
const activeSpace = spaces.find((x) => x.isActiveSpace)!;
const showShareWarning =
spaces.length > 1 && arraysAreEqual(currentNamespaces, [activeSpace.id]);
const { application, docLinks } = coreStart!;
const { Provider: KibanaReactContextProvider } = createKibanaReactContext({
application,
docLinks,
});
// Step 2: Share has not been initiated yet; User must fill out form to continue.
return (
<ShareToSpaceForm
coreStart={coreStart!}
spaces={spaces}
shareOptions={shareOptions}
onUpdate={setShareOptions}
showShareWarning={showShareWarning}
canShareToAllSpaces={canShareToAllSpaces}
makeCopy={() => setShowMakeCopy(true)}
/>
<KibanaReactContextProvider>
<ShareToSpaceForm
spaces={spaces}
shareOptions={shareOptions}
onUpdate={setShareOptions}
showShareWarning={showShareWarning}
canShareToAllSpaces={canShareToAllSpaces}
makeCopy={() => setShowMakeCopy(true)}
/>
</KibanaReactContextProvider>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ import './share_to_space_form.scss';
import React, { Fragment } from 'react';
import { EuiHorizontalRule, EuiCallOut, EuiLink } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { CoreStart } from 'src/core/public';
import { ShareOptions, SpaceTarget } from '../types';
import { ShareModeControl } from './share_mode_control';

interface Props {
coreStart: CoreStart;
spaces: SpaceTarget[];
onUpdate: (shareOptions: ShareOptions) => void;
shareOptions: ShareOptions;
Expand All @@ -23,15 +21,7 @@ interface Props {
}

export const ShareToSpaceForm = (props: Props) => {
const {
coreStart,
spaces,
onUpdate,
shareOptions,
showShareWarning,
canShareToAllSpaces,
makeCopy,
} = props;
const { spaces, onUpdate, shareOptions, showShareWarning, canShareToAllSpaces, makeCopy } = props;

const setSelectedSpaceIds = (selectedSpaceIds: string[]) =>
onUpdate({ ...shareOptions, selectedSpaceIds });
Expand Down Expand Up @@ -79,7 +69,6 @@ export const ShareToSpaceForm = (props: Props) => {
{getShareWarning()}

<ShareModeControl
coreStart={coreStart}
spaces={spaces}
canShareToAllSpaces={canShareToAllSpaces}
selectedSpaceIds={shareOptions.selectedSpaceIds}
Expand Down

0 comments on commit 64a5b84

Please sign in to comment.