Skip to content

Commit

Permalink
Merge pull request #8 from mbondyra/typescript_settings_management
Browse files Browse the repository at this point in the history
fix: prevent memory leak
  • Loading branch information
mattkime authored Jan 21, 2020
2 parents 5a8f4bf + e56f4f6 commit f663e22
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<kbn-management-app section="kibana/settings">
<kbn-management-advanced>
<kbn-management-advanced-react route="route"></kbn-management-advanced-react>
<kbn-management-advanced-react query="query"></kbn-management-advanced-react>
</kbn-management-advanced>
</kbn-management-app>
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import React from 'react';
import { AdvancedSettings } from './advanced_settings';
import { i18n } from '@kbn/i18n';
import { getBreadcrumbs } from './breadcrumbs';
import { useEffectOnce } from 'react-use';

uiRoutes.when('/management/kibana/settings/:setting?', {
template: indexTemplate,
Expand All @@ -59,28 +58,22 @@ uiModules.get('apps/management').directive('kbnManagementAdvanced', function($ro
return {
restrict: 'E',
link: function($scope) {
$scope.route = $route;
$scope.query = $route.current.params.setting || '';
$route.updateParams({ setting: null });
},
};
});

const AdvancedSettingsApp = ({ route }) => {
useEffectOnce(() => {
route.updateParams({ setting: null });
});

const AdvancedSettingsApp = ({ query = '' }) => {
return (
<I18nContext>
<AdvancedSettings
query={route.current.params.setting || ''}
enableSaving={capabilities.get().advancedSettings.save}
/>
<AdvancedSettings query={query} enableSaving={capabilities.get().advancedSettings.save} />
</I18nContext>
);
};

uiModules.get('apps/management').directive('kbnManagementAdvancedReact', function(reactDirective) {
return reactDirective(AdvancedSettingsApp, [['route', { watchDepth: 'reference' }]]);
return reactDirective(AdvancedSettingsApp, [['query', { watchDepth: 'reference' }]]);
});

management.getSection('kibana').register('settings', {
Expand Down

0 comments on commit f663e22

Please sign in to comment.