From cd5cecdd8c3d785aa55191a9331c51c1ac2e991c Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Mon, 16 Sep 2019 16:08:20 +0200 Subject: [PATCH 1/4] restructure folders and add readme --- x-pack/legacy/plugins/graph/README.md | 34 +++++++++++++++++++ x-pack/legacy/plugins/graph/public/app.js | 22 ++++++------ .../{graph_listing.tsx => listing.tsx} | 0 .../{graph_save_modal.tsx => save_modal.tsx} | 2 +- .../{graph_settings => settings}/_index.scss | 0 .../_legacy_icon.scss | 0 .../_url_template_list.scss | 0 .../advanced_settings_form.tsx | 4 +-- .../blacklist_form.tsx | 4 +-- .../graph/public/components/settings/index.ts | 7 ++++ .../legacy_icon.tsx | 2 +- .../settings.test.tsx} | 10 +++--- .../settings.tsx} | 6 ++-- .../url_template_form.tsx | 10 ++---- .../url_template_list.tsx | 4 +-- .../use_list_keys.test.tsx | 0 .../use_list_keys.ts | 0 .../{services => helpers}/as_observable.ts | 0 .../{services => helpers}/kql_encoder.test.ts | 0 .../{services => helpers}/kql_encoder.ts | 0 .../{services => helpers}/outlink_encoders.ts | 0 .../{services => helpers}/style_choices.ts | 0 .../{services => helpers}/url_template.ts | 0 .../services/persistence/deserialize.test.ts | 2 +- .../services/persistence/deserialize.ts | 4 +-- .../services/persistence/serialize.test.ts | 2 +- .../graph/public/services/save_modal.tsx | 6 ++-- .../plugins/graph/public/types/app_state.ts | 4 +-- .../graph/public/types/workspace_state.ts | 2 +- 29 files changed, 80 insertions(+), 45 deletions(-) create mode 100644 x-pack/legacy/plugins/graph/README.md rename x-pack/legacy/plugins/graph/public/components/{graph_listing.tsx => listing.tsx} (100%) rename x-pack/legacy/plugins/graph/public/components/{graph_save_modal.tsx => save_modal.tsx} (99%) rename x-pack/legacy/plugins/graph/public/components/{graph_settings => settings}/_index.scss (100%) rename x-pack/legacy/plugins/graph/public/components/{graph_settings => settings}/_legacy_icon.scss (100%) rename x-pack/legacy/plugins/graph/public/components/{graph_settings => settings}/_url_template_list.scss (100%) rename x-pack/legacy/plugins/graph/public/components/{graph_settings => settings}/advanced_settings_form.tsx (97%) rename x-pack/legacy/plugins/graph/public/components/{graph_settings => settings}/blacklist_form.tsx (95%) create mode 100644 x-pack/legacy/plugins/graph/public/components/settings/index.ts rename x-pack/legacy/plugins/graph/public/components/{graph_settings => settings}/legacy_icon.tsx (95%) rename x-pack/legacy/plugins/graph/public/components/{graph_settings/graph_settings.test.tsx => settings/settings.test.tsx} (95%) rename x-pack/legacy/plugins/graph/public/components/{graph_settings/graph_settings.tsx => settings/settings.tsx} (92%) rename x-pack/legacy/plugins/graph/public/components/{graph_settings => settings}/url_template_form.tsx (97%) rename x-pack/legacy/plugins/graph/public/components/{graph_settings => settings}/url_template_list.tsx (94%) rename x-pack/legacy/plugins/graph/public/components/{graph_settings => settings}/use_list_keys.test.tsx (100%) rename x-pack/legacy/plugins/graph/public/components/{graph_settings => settings}/use_list_keys.ts (100%) rename x-pack/legacy/plugins/graph/public/{services => helpers}/as_observable.ts (100%) rename x-pack/legacy/plugins/graph/public/{services => helpers}/kql_encoder.test.ts (100%) rename x-pack/legacy/plugins/graph/public/{services => helpers}/kql_encoder.ts (100%) rename x-pack/legacy/plugins/graph/public/{services => helpers}/outlink_encoders.ts (100%) rename x-pack/legacy/plugins/graph/public/{services => helpers}/style_choices.ts (100%) rename x-pack/legacy/plugins/graph/public/{services => helpers}/url_template.ts (100%) diff --git a/x-pack/legacy/plugins/graph/README.md b/x-pack/legacy/plugins/graph/README.md new file mode 100644 index 0000000000000..92ff29c07ce6f --- /dev/null +++ b/x-pack/legacy/plugins/graph/README.md @@ -0,0 +1,34 @@ +# Graph app + +This is the main source folder of the Graph plugin. It contains all of the Kibana server and client source code. `x-pack/test/functional/apps/graph` contains additional functional tests. + +Graph shows only up in the side bar if your server is running on a platinum or trial license. You can activate a trial license in `Management > License Management`. + +## Common commands + +* Run tests `node x-pack/scripts/jest.js --watch plugins/graph` +* Run type check `node scripts/type_check.js --project=x-pack/tsconfig.json` +* Run linter `node scripts/eslint.js x-pack/legacy/plugins/graph` +* Run functional tests (make sure to stop dev server) + * Server `cd x-pack && node ./scripts/functional_tests_server.js` + * Tests `cd x-pack && node ../scripts/functional_test_runner.js --config ./test/functional/config.js --grep=graph` + +## Folder structure + +### Client `public/` + +Currently most of the state handling is done by a central angular controller. This controller will be broken up into a redux/saga setup step by step. + +* `angular/` contains all code using javascript and angular. Rewriting this code in typescript and react is currently ongoing. When the migration is finished, this folder will go away +* `components/` contains react components for various parts of the interface. Components can hold local UI state (e.g. current form data), everything else should be passed in from the caller. Styles should reside in a component-specific stylesheet +* `hacks/` contains files that need to run before the actual app is started. When moving to the new platform, this folder will go away. +* `services/` contains functions that encapsule other parts of Kibana. Stateful dependencies are passed in from the outside. Components should not rely on services directly but have callbacks passed in. Once the migration to redux/saga is complete, only sagas will use services. +* `helpers/` contains side effect free helper functions that can be imported and used from components and services +* `state_management/` contains reducers, action creators, selectors and sagas. It also exports the central store +* `types/` contains type definitions for unmigrated functions in `angular/` and business objects +* `app.js` is the central entrypoint of the app. It initializes router, state management and root components. This will become `app.tsx` when the migration is complete + + +### Server `server/` + +The Graph server is only forwarding requests to Elasticsearch API and contains very little logic. It will be rewritten soon. \ No newline at end of file diff --git a/x-pack/legacy/plugins/graph/public/app.js b/x-pack/legacy/plugins/graph/public/app.js index 172c59bfeeeac..6ca4eb15d5bb1 100644 --- a/x-pack/legacy/plugins/graph/public/app.js +++ b/x-pack/legacy/plugins/graph/public/app.js @@ -40,8 +40,8 @@ import listingTemplate from './angular/templates/listing_ng_wrapper.html'; import { getReadonlyBadge } from './badge'; import { FormattedMessage } from '@kbn/i18n/react'; -import { GraphListing } from './components/graph_listing'; -import { GraphSettings } from './components/graph_settings/graph_settings'; +import { Listing } from './components/listing'; +import { Settings } from './components/settings'; import './angular/angular_venn_simple.js'; import gws from './angular/graph_client_workspace.js'; @@ -51,17 +51,17 @@ import { colorChoices, iconChoicesByClass, urlTemplateIconChoices, -} from './services/style_choices'; +} from './helpers/style_choices'; import { outlinkEncoders, -} from './services/outlink_encoders'; +} from './helpers/outlink_encoders'; import { getEditUrl, getNewPath, getEditPath, setBreadcrumbs, getHomePath } from './services/url'; import { appStateToSavedWorkspace, savedWorkspaceToAppState, lookupIndexPattern, mapFields } from './services/persistence'; -import { save } from './services/save_modal'; -import { urlTemplateRegex } from './services/url_template'; +import { openSaveModal } from './services/save_modal'; +import { urlTemplateRegex } from './helpers/url_template'; import { asAngularSyncedObservable, -} from './services/as_observable'; +} from './helpers/as_observable'; import './angular/directives/graph_inspect'; @@ -89,7 +89,7 @@ app.directive('focusOn', function () { }); app.directive('graphListing', function (reactDirective) { - return reactDirective(GraphListing); + return reactDirective(Listing); }); if (uiRoutes.enable) { @@ -789,7 +789,7 @@ app.controller('graphuiPlugin', function ( return $scope.allSavingDisabled || $scope.selectedFields.length === 0; }, run: () => { - save({ + openSaveModal({ savePolicy: $scope.graphSavePolicy, hasData: $scope.workspace && ($scope.workspace.nodes.length > 0 || $scope.workspace.blacklistedNodes.length > 0), workspace: $scope.savedWorkspace, @@ -848,9 +848,7 @@ app.controller('graphuiPlugin', function ( allFields: [...$scope.allFields], canEditDrillDownUrls: $scope.canEditDrillDownUrls }), $scope.$digest.bind($scope)); - currentSettingsFlyout = npStart.core.overlays.openFlyout(, { + currentSettingsFlyout = npStart.core.overlays.openFlyout(, { size: 'm', closeButtonAriaLabel: i18n.translate('xpack.graph.settings.closeLabel', { defaultMessage: 'Close' }), 'data-test-subj': 'graphSettingsFlyout', diff --git a/x-pack/legacy/plugins/graph/public/components/graph_listing.tsx b/x-pack/legacy/plugins/graph/public/components/listing.tsx similarity index 100% rename from x-pack/legacy/plugins/graph/public/components/graph_listing.tsx rename to x-pack/legacy/plugins/graph/public/components/listing.tsx diff --git a/x-pack/legacy/plugins/graph/public/components/graph_save_modal.tsx b/x-pack/legacy/plugins/graph/public/components/save_modal.tsx similarity index 99% rename from x-pack/legacy/plugins/graph/public/components/graph_save_modal.tsx rename to x-pack/legacy/plugins/graph/public/components/save_modal.tsx index 654cf473fb03e..451d920b505a6 100644 --- a/x-pack/legacy/plugins/graph/public/components/graph_save_modal.tsx +++ b/x-pack/legacy/plugins/graph/public/components/save_modal.tsx @@ -19,7 +19,7 @@ export interface OnSaveGraphProps extends OnSaveProps { dataConsent: boolean; } -export function GraphSaveModal({ +export function SaveModal({ onSave, onClose, title, diff --git a/x-pack/legacy/plugins/graph/public/components/graph_settings/_index.scss b/x-pack/legacy/plugins/graph/public/components/settings/_index.scss similarity index 100% rename from x-pack/legacy/plugins/graph/public/components/graph_settings/_index.scss rename to x-pack/legacy/plugins/graph/public/components/settings/_index.scss diff --git a/x-pack/legacy/plugins/graph/public/components/graph_settings/_legacy_icon.scss b/x-pack/legacy/plugins/graph/public/components/settings/_legacy_icon.scss similarity index 100% rename from x-pack/legacy/plugins/graph/public/components/graph_settings/_legacy_icon.scss rename to x-pack/legacy/plugins/graph/public/components/settings/_legacy_icon.scss diff --git a/x-pack/legacy/plugins/graph/public/components/graph_settings/_url_template_list.scss b/x-pack/legacy/plugins/graph/public/components/settings/_url_template_list.scss similarity index 100% rename from x-pack/legacy/plugins/graph/public/components/graph_settings/_url_template_list.scss rename to x-pack/legacy/plugins/graph/public/components/settings/_url_template_list.scss diff --git a/x-pack/legacy/plugins/graph/public/components/graph_settings/advanced_settings_form.tsx b/x-pack/legacy/plugins/graph/public/components/settings/advanced_settings_form.tsx similarity index 97% rename from x-pack/legacy/plugins/graph/public/components/graph_settings/advanced_settings_form.tsx rename to x-pack/legacy/plugins/graph/public/components/settings/advanced_settings_form.tsx index 96bf575ec8407..f963d53c639c4 100644 --- a/x-pack/legacy/plugins/graph/public/components/graph_settings/advanced_settings_form.tsx +++ b/x-pack/legacy/plugins/graph/public/components/settings/advanced_settings_form.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { EuiFormRow, EuiFieldNumber, EuiComboBox, EuiSwitch, EuiText } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { GraphSettingsProps } from './graph_settings'; +import { SettingsProps } from './settings'; import { AdvancedSettings } from '../../types'; // Helper type to get all keys of an interface @@ -25,7 +25,7 @@ export function AdvancedSettingsForm({ advancedSettings, updateAdvancedSettings, allFields, -}: Pick) { +}: Pick) { function updateSetting(key: K, value: AdvancedSettings[K]) { updateAdvancedSettings({ ...advancedSettings, [key]: value }); } diff --git a/x-pack/legacy/plugins/graph/public/components/graph_settings/blacklist_form.tsx b/x-pack/legacy/plugins/graph/public/components/settings/blacklist_form.tsx similarity index 95% rename from x-pack/legacy/plugins/graph/public/components/graph_settings/blacklist_form.tsx rename to x-pack/legacy/plugins/graph/public/components/settings/blacklist_form.tsx index 3273c3511a5d6..452cfc8b8bdde 100644 --- a/x-pack/legacy/plugins/graph/public/components/graph_settings/blacklist_form.tsx +++ b/x-pack/legacy/plugins/graph/public/components/settings/blacklist_form.tsx @@ -16,14 +16,14 @@ import { EuiCallOut, } from '@elastic/eui'; -import { GraphSettingsProps } from './graph_settings'; +import { SettingsProps } from './settings'; import { LegacyIcon } from './legacy_icon'; import { useListKeys } from './use_list_keys'; export function BlacklistForm({ blacklistedNodes, unblacklistNode, -}: Pick) { +}: Pick) { const getListKey = useListKeys(blacklistedNodes || []); return ( <> diff --git a/x-pack/legacy/plugins/graph/public/components/settings/index.ts b/x-pack/legacy/plugins/graph/public/components/settings/index.ts new file mode 100644 index 0000000000000..87d5cf67e6965 --- /dev/null +++ b/x-pack/legacy/plugins/graph/public/components/settings/index.ts @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export * from './settings'; diff --git a/x-pack/legacy/plugins/graph/public/components/graph_settings/legacy_icon.tsx b/x-pack/legacy/plugins/graph/public/components/settings/legacy_icon.tsx similarity index 95% rename from x-pack/legacy/plugins/graph/public/components/graph_settings/legacy_icon.tsx rename to x-pack/legacy/plugins/graph/public/components/settings/legacy_icon.tsx index 46adaf86d6542..14ce2f774e66c 100644 --- a/x-pack/legacy/plugins/graph/public/components/graph_settings/legacy_icon.tsx +++ b/x-pack/legacy/plugins/graph/public/components/settings/legacy_icon.tsx @@ -7,7 +7,7 @@ import classNames from 'classnames'; import React from 'react'; import { EuiButtonEmpty } from '@elastic/eui'; -import { FontawesomeIcon } from '../../services/style_choices'; +import { FontawesomeIcon } from '../../helpers/style_choices'; export interface LegacyIconProps { icon: FontawesomeIcon; diff --git a/x-pack/legacy/plugins/graph/public/components/graph_settings/graph_settings.test.tsx b/x-pack/legacy/plugins/graph/public/components/settings/settings.test.tsx similarity index 95% rename from x-pack/legacy/plugins/graph/public/components/graph_settings/graph_settings.test.tsx rename to x-pack/legacy/plugins/graph/public/components/settings/settings.test.tsx index b5623e401e881..31acc08812d5a 100644 --- a/x-pack/legacy/plugins/graph/public/components/graph_settings/graph_settings.test.tsx +++ b/x-pack/legacy/plugins/graph/public/components/settings/settings.test.tsx @@ -8,13 +8,13 @@ import React from 'react'; import { EuiTab, EuiListGroupItem, EuiButton, EuiAccordion, EuiFieldText } from '@elastic/eui'; import * as Rx from 'rxjs'; import { mountWithIntl } from 'test_utils/enzyme_helpers'; -import { GraphSettings, GraphSettingsProps } from './graph_settings'; +import { Settings, SettingsProps } from './settings'; import { act } from 'react-testing-library'; import { ReactWrapper } from 'enzyme'; import { UrlTemplateForm } from './url_template_form'; -describe('graph_settings', () => { - const props: jest.Mocked = { +describe('settings', () => { + const props: jest.Mocked = { advancedSettings: { maxValuesPerDoc: 5, minDocCount: 10, @@ -105,12 +105,12 @@ describe('graph_settings', () => { canEditDrillDownUrls: true, }; - let subject: Rx.BehaviorSubject>; + let subject: Rx.BehaviorSubject>; let instance: ReactWrapper; beforeEach(() => { subject = new Rx.BehaviorSubject(props); - instance = mountWithIntl(); + instance = mountWithIntl(); }); function toTab(tab: string) { diff --git a/x-pack/legacy/plugins/graph/public/components/graph_settings/graph_settings.tsx b/x-pack/legacy/plugins/graph/public/components/settings/settings.tsx similarity index 92% rename from x-pack/legacy/plugins/graph/public/components/graph_settings/graph_settings.tsx rename to x-pack/legacy/plugins/graph/public/components/settings/settings.tsx index 319e7747bbbc9..4cb4b473f7372 100644 --- a/x-pack/legacy/plugins/graph/public/components/graph_settings/graph_settings.tsx +++ b/x-pack/legacy/plugins/graph/public/components/settings/settings.tsx @@ -35,7 +35,7 @@ const tabs = [ }, ]; -export interface GraphSettingsProps { +export interface SettingsProps { advancedSettings: AdvancedSettings; updateAdvancedSettings: (advancedSettings: AdvancedSettings) => void; blacklistedNodes?: WorkspaceNode[]; @@ -51,8 +51,8 @@ interface AsObservable

{ observable: Readonly>; } -export function GraphSettings({ observable }: AsObservable) { - const [currentProps, setCurrentProps] = useState(undefined); +export function Settings({ observable }: AsObservable) { + const [currentProps, setCurrentProps] = useState(undefined); const [activeTab, setActiveTab] = useState(0); useEffect(() => { diff --git a/x-pack/legacy/plugins/graph/public/components/graph_settings/url_template_form.tsx b/x-pack/legacy/plugins/graph/public/components/settings/url_template_form.tsx similarity index 97% rename from x-pack/legacy/plugins/graph/public/components/graph_settings/url_template_form.tsx rename to x-pack/legacy/plugins/graph/public/components/settings/url_template_form.tsx index 9e1c686ccc012..c01c3166f3dcf 100644 --- a/x-pack/legacy/plugins/graph/public/components/graph_settings/url_template_form.tsx +++ b/x-pack/legacy/plugins/graph/public/components/settings/url_template_form.tsx @@ -20,13 +20,9 @@ import { i18n } from '@kbn/i18n'; import classNames from 'classnames'; import { UrlTemplate } from '../../types'; import { LegacyIcon } from './legacy_icon'; -import { outlinkEncoders } from '../../services/outlink_encoders'; -import { urlTemplateIconChoices } from '../../services/style_choices'; -import { - isUrlTemplateValid, - isKibanaUrl, - replaceKibanaUrlParam, -} from '../../services/url_template'; +import { outlinkEncoders } from '../../helpers/outlink_encoders'; +import { urlTemplateIconChoices } from '../../helpers/style_choices'; +import { isUrlTemplateValid, isKibanaUrl, replaceKibanaUrlParam } from '../../helpers/url_template'; export interface NewFormProps { onSubmit: (template: UrlTemplate) => void; diff --git a/x-pack/legacy/plugins/graph/public/components/graph_settings/url_template_list.tsx b/x-pack/legacy/plugins/graph/public/components/settings/url_template_list.tsx similarity index 94% rename from x-pack/legacy/plugins/graph/public/components/graph_settings/url_template_list.tsx rename to x-pack/legacy/plugins/graph/public/components/settings/url_template_list.tsx index 4b0869ea95d87..2e41f78bb9403 100644 --- a/x-pack/legacy/plugins/graph/public/components/graph_settings/url_template_list.tsx +++ b/x-pack/legacy/plugins/graph/public/components/settings/url_template_list.tsx @@ -7,7 +7,7 @@ import React, { useState } from 'react'; import { EuiText, EuiSpacer, EuiTextAlign, EuiButton, htmlIdGenerator } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { GraphSettingsProps } from './graph_settings'; +import { SettingsProps } from './settings'; import { UrlTemplateForm } from './url_template_form'; import { useListKeys } from './use_list_keys'; @@ -17,7 +17,7 @@ export function UrlTemplateList({ removeUrlTemplate, saveUrlTemplate, urlTemplates, -}: Pick) { +}: Pick) { const [uncommittedForms, setUncommittedForms] = useState([]); const getListKey = useListKeys(urlTemplates); diff --git a/x-pack/legacy/plugins/graph/public/components/graph_settings/use_list_keys.test.tsx b/x-pack/legacy/plugins/graph/public/components/settings/use_list_keys.test.tsx similarity index 100% rename from x-pack/legacy/plugins/graph/public/components/graph_settings/use_list_keys.test.tsx rename to x-pack/legacy/plugins/graph/public/components/settings/use_list_keys.test.tsx diff --git a/x-pack/legacy/plugins/graph/public/components/graph_settings/use_list_keys.ts b/x-pack/legacy/plugins/graph/public/components/settings/use_list_keys.ts similarity index 100% rename from x-pack/legacy/plugins/graph/public/components/graph_settings/use_list_keys.ts rename to x-pack/legacy/plugins/graph/public/components/settings/use_list_keys.ts diff --git a/x-pack/legacy/plugins/graph/public/services/as_observable.ts b/x-pack/legacy/plugins/graph/public/helpers/as_observable.ts similarity index 100% rename from x-pack/legacy/plugins/graph/public/services/as_observable.ts rename to x-pack/legacy/plugins/graph/public/helpers/as_observable.ts diff --git a/x-pack/legacy/plugins/graph/public/services/kql_encoder.test.ts b/x-pack/legacy/plugins/graph/public/helpers/kql_encoder.test.ts similarity index 100% rename from x-pack/legacy/plugins/graph/public/services/kql_encoder.test.ts rename to x-pack/legacy/plugins/graph/public/helpers/kql_encoder.test.ts diff --git a/x-pack/legacy/plugins/graph/public/services/kql_encoder.ts b/x-pack/legacy/plugins/graph/public/helpers/kql_encoder.ts similarity index 100% rename from x-pack/legacy/plugins/graph/public/services/kql_encoder.ts rename to x-pack/legacy/plugins/graph/public/helpers/kql_encoder.ts diff --git a/x-pack/legacy/plugins/graph/public/services/outlink_encoders.ts b/x-pack/legacy/plugins/graph/public/helpers/outlink_encoders.ts similarity index 100% rename from x-pack/legacy/plugins/graph/public/services/outlink_encoders.ts rename to x-pack/legacy/plugins/graph/public/helpers/outlink_encoders.ts diff --git a/x-pack/legacy/plugins/graph/public/services/style_choices.ts b/x-pack/legacy/plugins/graph/public/helpers/style_choices.ts similarity index 100% rename from x-pack/legacy/plugins/graph/public/services/style_choices.ts rename to x-pack/legacy/plugins/graph/public/helpers/style_choices.ts diff --git a/x-pack/legacy/plugins/graph/public/services/url_template.ts b/x-pack/legacy/plugins/graph/public/helpers/url_template.ts similarity index 100% rename from x-pack/legacy/plugins/graph/public/services/url_template.ts rename to x-pack/legacy/plugins/graph/public/helpers/url_template.ts diff --git a/x-pack/legacy/plugins/graph/public/services/persistence/deserialize.test.ts b/x-pack/legacy/plugins/graph/public/services/persistence/deserialize.test.ts index 53a826faf7ca5..ddf2dc1b1cc66 100644 --- a/x-pack/legacy/plugins/graph/public/services/persistence/deserialize.test.ts +++ b/x-pack/legacy/plugins/graph/public/services/persistence/deserialize.test.ts @@ -8,7 +8,7 @@ import { GraphWorkspaceSavedObject } from '../../types'; import { savedWorkspaceToAppState } from './deserialize'; import { IndexPattern } from 'src/legacy/core_plugins/data/public'; import { createWorkspace } from '../../angular/graph_client_workspace'; -import { outlinkEncoders } from '../outlink_encoders'; +import { outlinkEncoders } from '../../helpers/outlink_encoders'; describe('deserialize', () => { let savedWorkspace: GraphWorkspaceSavedObject; diff --git a/x-pack/legacy/plugins/graph/public/services/persistence/deserialize.ts b/x-pack/legacy/plugins/graph/public/services/persistence/deserialize.ts index 4a30f21cef335..003f0b5e48141 100644 --- a/x-pack/legacy/plugins/graph/public/services/persistence/deserialize.ts +++ b/x-pack/legacy/plugins/graph/public/services/persistence/deserialize.ts @@ -19,13 +19,13 @@ import { Workspace, SerializedField, } from '../../types'; -import { outlinkEncoders } from '../outlink_encoders'; +import { outlinkEncoders } from '../../helpers/outlink_encoders'; import { urlTemplateIconChoicesByClass, getSuitableIcon, colorChoices, iconChoicesByClass, -} from '../style_choices'; +} from '../../helpers/style_choices'; const defaultAdvancedSettings: AdvancedSettings = { useSignificance: true, diff --git a/x-pack/legacy/plugins/graph/public/services/persistence/serialize.test.ts b/x-pack/legacy/plugins/graph/public/services/persistence/serialize.test.ts index 1f4f608f95c61..eb6e2f48ac68b 100644 --- a/x-pack/legacy/plugins/graph/public/services/persistence/serialize.test.ts +++ b/x-pack/legacy/plugins/graph/public/services/persistence/serialize.test.ts @@ -12,7 +12,7 @@ import { WorkspaceEdge, AppState, } from '../../types'; -import { outlinkEncoders } from '../outlink_encoders'; +import { outlinkEncoders } from '../../helpers/outlink_encoders'; describe('serialize', () => { let appState: AppState; diff --git a/x-pack/legacy/plugins/graph/public/services/save_modal.tsx b/x-pack/legacy/plugins/graph/public/services/save_modal.tsx index 7680cdaa085e9..6b078bcdde66f 100644 --- a/x-pack/legacy/plugins/graph/public/services/save_modal.tsx +++ b/x-pack/legacy/plugins/graph/public/services/save_modal.tsx @@ -7,9 +7,9 @@ import React from 'react'; import { showSaveModal, SaveResult } from 'ui/saved_objects/show_saved_object_save_modal'; import { GraphWorkspaceSavedObject, GraphSavePolicy } from '../types'; -import { GraphSaveModal, OnSaveGraphProps } from '../components/graph_save_modal'; +import { SaveModal, OnSaveGraphProps } from '../components/save_modal'; -export function save({ +export function openSaveModal({ savePolicy, hasData, workspace, @@ -55,7 +55,7 @@ export function save({ }); }; showSaveModal( - Date: Mon, 16 Sep 2019 17:58:15 +0200 Subject: [PATCH 2/4] fix import bugs --- x-pack/legacy/plugins/graph/public/components/_index.scss | 2 +- x-pack/legacy/plugins/graph/public/components/listing.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/x-pack/legacy/plugins/graph/public/components/_index.scss b/x-pack/legacy/plugins/graph/public/components/_index.scss index a40afaffce41b..a7a4f65f648a7 100644 --- a/x-pack/legacy/plugins/graph/public/components/_index.scss +++ b/x-pack/legacy/plugins/graph/public/components/_index.scss @@ -1 +1 @@ -@import './graph_settings/index'; +@import './settings/index'; diff --git a/x-pack/legacy/plugins/graph/public/components/listing.tsx b/x-pack/legacy/plugins/graph/public/components/listing.tsx index 65394bdfe9086..2a83b5b79ec9a 100644 --- a/x-pack/legacy/plugins/graph/public/components/listing.tsx +++ b/x-pack/legacy/plugins/graph/public/components/listing.tsx @@ -13,7 +13,7 @@ import { EuiEmptyPrompt, EuiLink, EuiButton } from '@elastic/eui'; import { TableListView } from '../../../../../../src/legacy/core_plugins/kibana/public/table_list_view/table_list_view'; import { GraphWorkspaceSavedObject } from '../types'; -export interface GraphListingProps { +export interface ListingProps { createItem: () => void; findItems: (query: string, limit: number) => Promise; deleteItems: (ids: string[]) => Promise; @@ -25,7 +25,7 @@ export interface GraphListingProps { initialFilter: string; } -export function GraphListing(props: GraphListingProps) { +export function Listing(props: ListingProps) { return ( Date: Tue, 17 Sep 2019 12:11:07 +0200 Subject: [PATCH 3/4] do not import stateful dependencies directly --- x-pack/legacy/plugins/graph/public/app.js | 4 +++- x-pack/legacy/plugins/graph/public/services/save_modal.tsx | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/x-pack/legacy/plugins/graph/public/app.js b/x-pack/legacy/plugins/graph/public/app.js index 36ca2ca6b4039..b91e72740fa0a 100644 --- a/x-pack/legacy/plugins/graph/public/app.js +++ b/x-pack/legacy/plugins/graph/public/app.js @@ -32,6 +32,7 @@ import { KibanaParsedUrl } from 'ui/url/kibana_parsed_url'; import { npStart } from 'ui/new_platform'; import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry'; import { capabilities } from 'ui/capabilities'; +import { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal'; import { xpackInfo } from 'plugins/xpack_main/services/xpack_info'; @@ -792,7 +793,8 @@ app.controller('graphuiPlugin', function ( savePolicy: $scope.graphSavePolicy, hasData: $scope.workspace && ($scope.workspace.nodes.length > 0 || $scope.workspace.blacklistedNodes.length > 0), workspace: $scope.savedWorkspace, - saveWorkspace: $scope.saveWorkspace + saveWorkspace: $scope.saveWorkspace, + showSaveModal }); }, testId: 'graphSaveButton', diff --git a/x-pack/legacy/plugins/graph/public/services/save_modal.tsx b/x-pack/legacy/plugins/graph/public/services/save_modal.tsx index 6b078bcdde66f..bb453bd95df5e 100644 --- a/x-pack/legacy/plugins/graph/public/services/save_modal.tsx +++ b/x-pack/legacy/plugins/graph/public/services/save_modal.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { showSaveModal, SaveResult } from 'ui/saved_objects/show_saved_object_save_modal'; +import { SaveResult } from 'ui/saved_objects/show_saved_object_save_modal'; import { GraphWorkspaceSavedObject, GraphSavePolicy } from '../types'; import { SaveModal, OnSaveGraphProps } from '../components/save_modal'; @@ -14,6 +14,7 @@ export function openSaveModal({ hasData, workspace, saveWorkspace, + showSaveModal, }: { savePolicy: GraphSavePolicy; hasData: boolean; @@ -26,6 +27,7 @@ export function openSaveModal({ }, dataConsent: boolean ) => Promise; + showSaveModal: (el: React.ReactNode) => void; }) { const currentTitle = workspace.title; const currentDescription = workspace.description; From af8901cc7f6d1a95c4d734299b50711fda71e22e Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Tue, 17 Sep 2019 12:33:25 +0200 Subject: [PATCH 4/4] fix loading bug --- x-pack/legacy/plugins/graph/public/app.js | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/x-pack/legacy/plugins/graph/public/app.js b/x-pack/legacy/plugins/graph/public/app.js index b91e72740fa0a..43d6919997fe2 100644 --- a/x-pack/legacy/plugins/graph/public/app.js +++ b/x-pack/legacy/plugins/graph/public/app.js @@ -311,17 +311,6 @@ app.controller('graphuiPlugin', function ( $scope.closeMenus(); }; - $scope.setAllFieldStatesToDefault = function () { - $scope.selectedFields = []; - $scope.basicModeSelectedSingleField = null; - $scope.liveResponseFields = []; - - // Default field state is not selected - $scope.allFields.forEach(function (fieldDef) { - fieldDef.selected = false; - }); - }; - $scope.addFieldToSelection = function () { $scope.selectedField.selected = true; if ($scope.selectedFields.indexOf($scope.selectedField) < 0) { @@ -892,16 +881,15 @@ app.controller('graphuiPlugin', function ( const { urlTemplates, advancedSettings, - workspace, allFields, selectedFields, } = savedWorkspaceToAppState($scope.savedWorkspace, indexPattern, $scope.workspace); // wire up stuff to angular $scope.allFields = allFields; - $scope.selectedFields = selectedFields; - $scope.workspace = workspace; + $scope.selectedFields.push(...selectedFields); $scope.exploreControls = advancedSettings; + $scope.workspace.options.exploreControls = advancedSettings; $scope.urlTemplates = urlTemplates; $scope.updateLiveResponseFields(); $scope.workspace.runLayout();