Skip to content

Commit

Permalink
Remove app / component to add sample data (#56)
Browse files Browse the repository at this point in the history
Signed-off-by: yenienserrano <[email protected]>
  • Loading branch information
yenienserrano committed Jun 9, 2023
1 parent faf68b3 commit 27e01b6
Show file tree
Hide file tree
Showing 16 changed files with 69 additions and 483 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions src/plugins/home/public/application/components/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import {
import { HOME_APP_BASE_PATH } from '../../../common/constants';
import { FeatureCatalogueCategory } from '../../services';
import { getServices } from '../opensearch_dashboards_services';
import { AddData } from './add_data';
import { ManageData } from './manage_data';
import { SolutionsSection } from './solutions_section';
import { Welcome } from './welcome';
Expand Down Expand Up @@ -76,7 +75,10 @@ export class Home extends Component {

componentDidMount() {
this._isMounted = true;
this.fetchIsNewOpenSearchDashboardsInstance();
// is commented and the skipWelcome function is added to avoid loading
// the add sample data page the first time the application is accessed.
// this.fetchIsNewOpenSearchDashboardsInstance();
this.skipWelcome();

const homeTitle = i18n.translate('home.breadcrumbs.homeTitle', { defaultMessage: 'Home' });
getServices().chrome.setBreadcrumbs([{ text: homeTitle }]);
Expand Down Expand Up @@ -173,10 +175,6 @@ export class Home extends Component {
: 'homData--expanded'
}`}
>
<EuiFlexItem>
<AddData addBasePath={addBasePath} features={addDataFeatures} />
</EuiFlexItem>

<EuiFlexItem>
<ManageData addBasePath={addBasePath} features={manageDataFeatures} />
</EuiFlexItem>
Expand Down
3 changes: 0 additions & 3 deletions src/plugins/home/public/application/components/home.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,6 @@ describe('home', () => {
find: () => Promise.resolve({ total: 0 }),
});

component.instance().skipWelcome();
component.update();

sinon.assert.calledWith(defaultProps.localStorage.setItem, 'home:welcome:show', 'false');

expect(component).toMatchSnapshot();
Expand Down
39 changes: 1 addition & 38 deletions src/plugins/home/public/application/components/home_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ import { I18nProvider } from '@osd/i18n/react';
import PropTypes from 'prop-types';
import { Home } from './home';
import { FeatureDirectory } from './feature_directory';
import { TutorialDirectory } from './tutorial_directory';
import { Tutorial } from './tutorial/tutorial';
import { HashRouter as Router, Switch, Route } from 'react-router-dom';
import { getTutorial } from '../load_tutorials';
import { replaceTemplateStrings } from './tutorial/replace_template_strings';
import { getServices } from '../opensearch_dashboards_services';
import { useMount } from 'react-use';

Expand All @@ -50,45 +46,12 @@ const RedirectToDefaultApp = () => {
};

export function HomeApp({ directories, solutions }) {
const {
savedObjectsClient,
getBasePath,
addBasePath,
environmentService,
telemetry,
} = getServices();
const environment = environmentService.getEnvironment();
const isCloudEnabled = environment.cloud;

const renderTutorialDirectory = (props) => {
return (
<TutorialDirectory
addBasePath={addBasePath}
openTab={props.match.params.tab}
isCloudEnabled={isCloudEnabled}
/>
);
};

const renderTutorial = (props) => {
return (
<Tutorial
addBasePath={addBasePath}
isCloudEnabled={isCloudEnabled}
getTutorial={getTutorial}
replaceTemplateStrings={replaceTemplateStrings}
tutorialId={props.match.params.id}
bulkCreate={savedObjectsClient.bulkCreate}
/>
);
};
const { savedObjectsClient, getBasePath, addBasePath, telemetry } = getServices();

return (
<I18nProvider>
<Router>
<Switch>
<Route path="/tutorial/:id" render={renderTutorial} />
<Route path="/tutorial_directory/:tab?" render={renderTutorialDirectory} />
<Route exact path="/feature_directory">
<FeatureDirectory addBasePath={addBasePath} directories={directories} />
</Route>
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/home/public/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('HomePublicPlugin', () => {
category: 'data',
icon: 'indexOpen',
id: 'home_tutorial_directory',
showOnHomePage: true,
showOnHomePage: false,
})
);
});
Expand Down
8 changes: 6 additions & 2 deletions src/plugins/home/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ export class HomePublicPlugin
urlForwarding.forwardApp('home', 'home');

const featureCatalogue = { ...this.featuresCatalogueRegistry.setup() };

// Disable sample data in home/view app directory
// To activate it again, remove visible() and change showOnHomePage to true.
featureCatalogue.register({
id: 'home_tutorial_directory',
title: i18n.translate('home.tutorialDirectory.featureCatalogueTitle', {
Expand All @@ -140,9 +141,12 @@ export class HomePublicPlugin
defaultMessage: 'Get started with sample data, visualizations, and dashboards.',
}),
icon: 'indexOpen',
showOnHomePage: true,
showOnHomePage: false,
path: `${HOME_APP_BASE_PATH}#/tutorial_directory`,
category: 'data' as FeatureCatalogueCategory.DATA,
visible() {
return false;
},
order: 500,
});

Expand Down
Loading

0 comments on commit 27e01b6

Please sign in to comment.