Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Home Page #6065

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Workspace] Add a workspace client in workspace plugin ([#6094](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6094))
- [Multiple Datasource] Add component to show single selected data source in read only mode ([#6125](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6125))
- [Workspace] Add workspace id in basePath ([#6060](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6060))
- Implement new home page ([#6065](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6065))
- Add sidecar service ([#5920](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5920))

### 🐛 Bug Fixes
Expand Down Expand Up @@ -1069,4 +1070,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

### 🔩 Tests

- Update caniuse to fix failed integration tests ([#2322](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2322))
- Update caniuse to fix failed integration tests ([#2322](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2322))
1 change: 1 addition & 0 deletions src/plugins/home/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@

export const PLUGIN_ID = 'home';
export const HOME_APP_BASE_PATH = `/app/${PLUGIN_ID}`;
export const USE_NEW_HOME_PAGE = 'home:useNewHomePage';
6 changes: 2 additions & 4 deletions src/plugins/home/opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
"version": "opensearchDashboards",
"server": true,
"ui": true,
"requiredPlugins": ["data", "urlForwarding"],
"requiredPlugins": ["data", "urlForwarding", "savedObjects"],
"optionalPlugins": ["usageCollection", "telemetry", "dataSource"],
"requiredBundles": [
"opensearchDashboardsReact", "dataSourceManagement"
]
"requiredBundles": ["opensearchDashboardsReact", "dataSourceManagement"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
@import "synopsis";
@import "welcome";
@import "tutorial/tutorial";
@import "homepage/homepage";
49 changes: 37 additions & 12 deletions src/plugins/home/public/application/components/home_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
import React from 'react';
import { I18nProvider } from '@osd/i18n/react';
import PropTypes from 'prop-types';
import { Home } from './home';
import { Home } from './legacy/home';
import { Homepage } from './homepage';
import { FeatureDirectory } from './feature_directory';
import { TutorialDirectory } from './tutorial_directory';
import { Tutorial } from './tutorial/tutorial';
Expand All @@ -40,6 +41,7 @@ import { getTutorial } from '../load_tutorials';
import { replaceTemplateStrings } from './tutorial/replace_template_strings';
import { getServices } from '../opensearch_dashboards_services';
import { useMount } from 'react-use';
import { USE_NEW_HOME_PAGE } from '../../../common/constants';

const RedirectToDefaultApp = () => {
useMount(() => {
Expand All @@ -56,6 +58,7 @@ export function HomeApp({ directories, solutions }) {
addBasePath,
environmentService,
telemetry,
uiSettings,
} = getServices();
const environment = environmentService.getEnvironment();
const isCloudEnabled = environment.cloud;
Expand Down Expand Up @@ -83,6 +86,20 @@ export function HomeApp({ directories, solutions }) {
);
};

const legacyHome = (
<Home
addBasePath={addBasePath}
directories={directories}
solutions={solutions}
find={savedObjectsClient.find}
localStorage={localStorage}
urlBasePath={getBasePath()}
telemetry={telemetry}
/>
);

const homepage = <Homepage />;

return (
<I18nProvider>
<Router>
Expand All @@ -92,17 +109,25 @@ export function HomeApp({ directories, solutions }) {
<Route exact path="/feature_directory">
<FeatureDirectory addBasePath={addBasePath} directories={directories} />
</Route>
<Route exact path="/">
<Home
addBasePath={addBasePath}
directories={directories}
solutions={solutions}
find={savedObjectsClient.find}
localStorage={localStorage}
urlBasePath={getBasePath()}
telemetry={telemetry}
/>
</Route>
{uiSettings.get(USE_NEW_HOME_PAGE) ? (
<>
<Route exact path="/legacy-home">
{legacyHome}
</Route>
<Route exact path="/">
{homepage}
</Route>
</>
) : (
<>
<Route exact path="/next-home">
{homepage}
</Route>
<Route exact path="/">
{legacyHome}
</Route>
</>
)}
<Route path="*" exact={true} component={RedirectToDefaultApp} />
</Switch>
</Router>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.home-homepage-pageBody {
// This is needed to make sure the page body is not wider than the page.
// This is otherwise not possible with the props on EuiPageTemplate.
padding: 0 $euiSizeL;
}

.home-homepage-body--fill {
min-height: $euiSize * 50;
}
105 changes: 105 additions & 0 deletions src/plugins/home/public/application/components/homepage/footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { FormattedMessage } from '@osd/i18n/react';
import { EuiFlexGroup, EuiFlexItem, EuiButtonEmpty } from '@elastic/eui';
import { i18n } from '@osd/i18n';
import { CoreStart } from 'opensearch-dashboards/public';
import { HOME_APP_BASE_PATH } from '../../../../common/constants';
import {
RedirectAppLinks,
useOpenSearchDashboards,
useUiSetting$,
} from '../../../../../opensearch_dashboards_react/public';

export const Footer: React.FC = () => {
const [defaultRoute, setDefaultRoute] = useUiSetting$<string>('defaultRoute');
const {
services: {
application,
notifications: { toasts },
},
} = useOpenSearchDashboards<CoreStart>();

const getUrlForApp = application.getUrlForApp;
const { show, save } = application.capabilities.advancedSettings ?? {};

const isAdvancedSettingsEnabled = show && save;

const defaultRouteButton =
defaultRoute === HOME_APP_BASE_PATH ? (
<RedirectAppLinks application={application}>
<EuiButtonEmpty
flush="both"
href={getUrlForApp('management', { path: 'opensearch-dashboards/settings#defaultRoute' })}
iconType="home"
size="xs"
>
<FormattedMessage
id="home.footer.changeHomeRouteLink"
defaultMessage="Display a different page on log in"
/>
</EuiButtonEmpty>
</RedirectAppLinks>
) : (
<EuiButtonEmpty
flush="both"
iconType="home"
onClick={() => {
setDefaultRoute(HOME_APP_BASE_PATH);
toasts.addSuccess({
title: i18n.translate('home.footer.changeDefaultRouteSuccessToast', {
defaultMessage: 'Landing page updated',
}),
});
}}
size="xs"
>
<FormattedMessage
id="home.footer.makeDefaultRouteLink"
defaultMessage="Make this my landing page"
/>
</EuiButtonEmpty>
);

return (
<EuiFlexGroup direction="row" wrap>
{isAdvancedSettingsEnabled && <EuiFlexItem grow={false}>{defaultRouteButton}</EuiFlexItem>}

<EuiFlexItem grow={false}>
<RedirectAppLinks application={application}>
<EuiButtonEmpty
flush="both"
href={getUrlForApp('home', { path: '#/feature_directory' })}
iconType="apps"
size="xs"
>
<FormattedMessage
id="home.footer.appDirectoryButtonLabel"
defaultMessage="View app directory"
/>
</EuiButtonEmpty>
</RedirectAppLinks>
</EuiFlexItem>

<EuiFlexItem grow={false}>
<RedirectAppLinks application={application}>
<EuiButtonEmpty
flush="both"
href={getUrlForApp('opensearch_dashboards_overview')}
iconType="visualizeApp"
size="xs"
>
<FormattedMessage
id="home.footer.visualizeAndAnalyze"
defaultMessage="Visualize & Analyze"
/>
</EuiButtonEmpty>
</RedirectAppLinks>
</EuiFlexItem>
</EuiFlexGroup>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React, { FC } from 'react';
import { EuiPanel } from '@elastic/eui';
import { RenderFn } from '../../../services/section_type/section_type';
import { LazyRender } from './lazy_render';

interface Props {
render: RenderFn;
}

export const HeroSection: FC<Props> = ({ render }) => {
return (
<EuiPanel data-test-subj="homepageHeroSection">
<LazyRender render={render} />
</EuiPanel>
);
};
Loading
Loading