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

[Bug] UI changes for overview page, fix re-direction for workspaces #2152

Merged
merged 7 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions common/constants/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export const DATACONNECTIONS_ENDPOINT = '/_plugins/_query/_datasources';
export const JOBS_ENDPOINT_BASE = '/_plugins/_async_query';
export const JOB_RESULT_ENDPOINT = '/result';

export const tutorialSampleDataPluginId = 'import_sample_data';

export const observabilityID = 'observability-logs';
export const observabilityTitle = 'Observability';
export const observabilityPluginOrder = 1500;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@
}) => {
const [collectionMethod, setCollectionMethod] = useState('');
const [specificMethod, setSpecificMethod] = useState('');
const [_gettingStarted, setGettingStarted] = useState<any>(null);

Check warning on line 63 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const [selectedTabId, setSelectedTabId] = useState('workflow_0');
const [_selectedWorkflow, setSelectedWorkflow] = useState('');
const [workflows, setWorkflows] = useState<any[]>([]);

Check warning on line 66 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const [selectedCard, setSelectedCard] = useState('');
const [collectorOptions, setCollectorOptions] = useState<CollectorOption[]>([]);

const technologyJsonMap: Record<string, any> = {

Check warning on line 70 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
otel: otelJson,
csv: csvFileJson,
golang: golangClientJson,
Expand Down Expand Up @@ -95,7 +95,7 @@
setGettingStarted(null);
setWorkflows([]);
}
}, [specificMethod]);

Check warning on line 98 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has a missing dependency: 'technologyJsonMap'. Either include it or remove the dependency array

const handleCollectionMethodChange = (value: string) => {
setCollectionMethod(value);
Expand All @@ -103,7 +103,7 @@
setSelectedWorkflow('');
setGettingStarted(null);
setWorkflows([]);
onCardSelectionChange(value === 'Use a sample dataset');
onCardSelectionChange(value === 'Configure use-case based content');

if (value === 'Configure collectors') {
setCollectorOptions([
Expand All @@ -118,7 +118,7 @@
}
};

const handleSpecificMethodChange = (selectedOption: any) => {

Check warning on line 121 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
if (!selectedOption) {
return;
}
Expand All @@ -135,7 +135,7 @@
setWorkflows([]);
};

const onTabClick = (tab: any) => {

Check warning on line 138 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const workflowIndex = parseInt(tab.id.split('_')[1], 10);
setSelectedTabId(tab.id);
setSelectedWorkflow(workflows[workflowIndex].name);
Expand Down Expand Up @@ -165,8 +165,8 @@
);
};

const renderSteps = (workflow: any) => {

Check warning on line 168 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const steps = workflow.steps.map((step: any) => ({

Check warning on line 169 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
title: step.name,
children: (
<div>
Expand All @@ -181,7 +181,7 @@
<EuiTitle size="xs">
<h4>Input Parameters:</h4>
</EuiTitle>
{step['input-params'].map((param: any, idx: number) => (

Check warning on line 184 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
<EuiText key={idx}>
<strong>{param.name}:</strong> {param.description} ({param.type})
</EuiText>
Expand Down Expand Up @@ -225,7 +225,7 @@
return <EuiSteps steps={steps} />;
};

const renderSchema = (schemas: any[]) =>

Check warning on line 228 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
schemas.map((schema, idx) => (
<div key={idx}>
<EuiTitle size="s">
Expand Down Expand Up @@ -349,20 +349,20 @@
<EuiFlexItem>
<EuiCheckableCard
id="use_sample_dataset"
label="Use a sample dataset"
label="Configure use-case based content"
checkableType="radio"
checked={selectedCard === 'Use a sample dataset'}
checked={selectedCard === 'Configure use-case based content'}
TackAdam marked this conversation as resolved.
Show resolved Hide resolved
onChange={() => {
handleCollectionMethodChange('Use a sample dataset');
setSelectedCard('Use a sample dataset');
handleCollectionMethodChange('Configure use-case based content');
setSelectedCard('Configure use-case based content');
}}
>
Explore with a log dataset
</EuiCheckableCard>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="m" />
{collectionMethod === 'Use a sample dataset' ? (
{collectionMethod === 'Configure use-case based content' ? (
<IntegrationCards />
) : (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
} from '@elastic/eui';
import { coreRefs } from '../../../../public/framework/core_refs';
import { fetchDashboardIds, fetchIndexPatternIds, redirectToDashboards } from './utils';
import { getWorkspaceIdFromUrl } from '../../../../../../src/core/public/utils';

interface Pattern {
id: string;
Expand Down Expand Up @@ -75,8 +76,15 @@ export const QueryAndAnalyze: React.FC<QueryAndAnalyzeProps> = ({
? `mds-${selectedDataSourceId}-objectId-${patternId}`
: patternId;

const currentUrl = window.location.href;
const workspaceId = getWorkspaceIdFromUrl(currentUrl, coreRefs?.http!.basePath.getBasePath());

const workspacePatternId = workspaceId
? `workspaceId-${workspaceId}-${finalPatternId}`
: finalPatternId;

coreRefs?.application!.navigateToApp('data-explorer', {
path: `discover#?_a=(discover:(columns:!(_source),isDirty:!f,sort:!()),metadata:(indexPattern:'${finalPatternId}',view:discover))&_q=(filters:!(),query:(language:kuery,query:''))&_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-15m,to:now))`,
path: `discover#?_a=(discover:(columns:!(_source),isDirty:!f,sort:!()),metadata:(indexPattern:'${workspacePatternId}',view:discover))&_q=(filters:!(),query:(language:kuery,query:''))&_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-15m,to:now))`,
});
};

Expand All @@ -85,8 +93,16 @@ export const QueryAndAnalyze: React.FC<QueryAndAnalyzeProps> = ({
? `mds-${selectedDataSourceId}-objectId-${dashboardId}`
: dashboardId;

const currentUrl = window.location.href;
const workspaceId = getWorkspaceIdFromUrl(currentUrl, coreRefs?.http!.basePath.getBasePath());

const workspaceDashboardId = workspaceId
? `workspaceId-${workspaceId}-${finalDashboardId}`
: finalDashboardId;
const dashboardUrl = `#/view/${workspaceDashboardId}`;

coreRefs?.application!.navigateToApp('dashboards', {
path: `#/view/${finalDashboardId}`,
path: dashboardUrl,
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function IntegrationOverview(props: any) {
data-test-subj="try-it-button"
data-click-metric-element="integrations.create_from_try_it"
>
Try It
Try with sample data
</EuiSmallButton>
</EuiFlexItem>
<EuiFlexItem grow={false}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,47 +95,52 @@ exports[`Add dashboard callout renders add dashboard callout 1`] = `
className="euiSpacer euiSpacer--l"
/>
</EuiSpacer>
<EuiButton>
<EuiButtonDisplay
baseClassName="euiButton"
disabled={false}
element="button"
isDisabled={false}
type="button"
<EuiSmallButton>
<EuiButton
size="s"
>
<button
className="euiButton euiButton--primary"
<EuiButtonDisplay
baseClassName="euiButton"
disabled={false}
style={
Object {
"minWidth": undefined,
}
}
element="button"
isDisabled={false}
size="s"
type="button"
>
<EuiButtonContent
className="euiButton__content"
iconGap="m"
iconSide="left"
textProps={
<button
className="euiButton euiButton--primary euiButton--small"
disabled={false}
style={
Object {
"className": "euiButton__text",
"minWidth": undefined,
}
}
type="button"
>
<span
className="euiButtonContent euiButton__content"
<EuiButtonContent
className="euiButton__content"
iconGap="m"
iconSide="left"
textProps={
Object {
"className": "euiButton__text",
}
}
>
<span
className="euiButton__text"
className="euiButtonContent euiButton__content"
>
Select
<span
className="euiButton__text"
>
Select
</span>
</span>
</span>
</EuiButtonContent>
</button>
</EuiButtonDisplay>
</EuiButton>
</EuiButtonContent>
</button>
</EuiButtonDisplay>
</EuiButton>
</EuiSmallButton>
</div>
</EuiTextColor>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,47 +96,52 @@ exports[`Dashboard controls should render 1`] = `
className="euiSpacer euiSpacer--l"
/>
</EuiSpacer>
<EuiButton>
<EuiButtonDisplay
baseClassName="euiButton"
disabled={false}
element="button"
isDisabled={false}
type="button"
<EuiSmallButton>
<EuiButton
size="s"
>
<button
className="euiButton euiButton--primary"
<EuiButtonDisplay
baseClassName="euiButton"
disabled={false}
style={
Object {
"minWidth": undefined,
}
}
element="button"
isDisabled={false}
size="s"
type="button"
>
<EuiButtonContent
className="euiButton__content"
iconGap="m"
iconSide="left"
textProps={
<button
className="euiButton euiButton--primary euiButton--small"
disabled={false}
style={
Object {
"className": "euiButton__text",
"minWidth": undefined,
}
}
type="button"
>
<span
className="euiButtonContent euiButton__content"
<EuiButtonContent
className="euiButton__content"
iconGap="m"
iconSide="left"
textProps={
Object {
"className": "euiButton__text",
}
}
>
<span
className="euiButton__text"
className="euiButtonContent euiButton__content"
>
Select
<span
className="euiButton__text"
>
Select
</span>
</span>
</span>
</EuiButtonContent>
</button>
</EuiButtonDisplay>
</EuiButton>
</EuiButtonContent>
</button>
</EuiButtonDisplay>
</EuiButton>
</EuiSmallButton>
</div>
</EuiTextColor>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { EuiButton, EuiCallOut, EuiLink, EuiSpacer, EuiText } from '@elastic/eui';
import { EuiSmallButton, EuiCallOut, EuiLink, EuiSpacer, EuiText } from '@elastic/eui';
import React from 'react';
import { useObservable } from 'react-use';
import { coreRefs } from '../../../framework/core_refs';
Expand All @@ -30,7 +30,7 @@ export function AddDashboardCallout() {
</p>
</EuiText>
<EuiSpacer />
<EuiButton onClick={showFlyout}>Select</EuiButton>
<EuiSmallButton onClick={showFlyout}>Select</EuiSmallButton>
</EuiCallOut>
</>
);
Expand Down
27 changes: 21 additions & 6 deletions public/components/overview/components/card_configs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
alertingPluginID,
anomalyDetectionPluginID,
discoverPluginID,
tutorialSampleDataPluginId,
} from '../../../../common/constants/shared';

export interface GettingStartedConfig {
Expand All @@ -34,9 +35,22 @@ const GETTING_STARTED_CONFIG: GettingStartedConfig = {
url: observabilityGettingStartedID,
};

const SAMPLEDATA_CONFIG: GettingStartedConfig = {
id: 'sample_data',
order: 2,
description: i18n.translate('home.sampleData.card.description', {
defaultMessage: 'You can install sample data to experiment with OpenSearch Dashboards.',
}),
title: i18n.translate('home.sampleData.card.title', {
defaultMessage: 'Try OpenSearch',
}),
url: tutorialSampleDataPluginId,
footer: 'Sample Datasets',
};

const DISCOVER_CONFIG: GettingStartedConfig = {
id: 'discover',
order: 2,
order: 3,
title: i18n.translate('observability.overview.card.discover.title', {
defaultMessage: 'Discover insights',
}),
Expand All @@ -47,7 +61,7 @@ const DISCOVER_CONFIG: GettingStartedConfig = {

const METRICS_CONFIG: GettingStartedConfig = {
id: 'metrics',
order: 3,
order: 4,
title: i18n.translate('observability.overview.card.metrics.title', {
defaultMessage: 'Monitor system performance',
}),
Expand All @@ -58,7 +72,7 @@ const METRICS_CONFIG: GettingStartedConfig = {

const TRACES_CONFIG: GettingStartedConfig = {
id: 'traces',
order: 4,
order: 5,
title: i18n.translate('observability.overview.card.traces.title', {
defaultMessage: 'Identify performance issues',
}),
Expand All @@ -69,7 +83,7 @@ const TRACES_CONFIG: GettingStartedConfig = {

const SERVICES_CONFIG: GettingStartedConfig = {
id: 'services',
order: 5,
order: 6,
title: i18n.translate('observability.overview.card.services.title', {
defaultMessage: 'Monitor service health',
}),
Expand All @@ -80,7 +94,7 @@ const SERVICES_CONFIG: GettingStartedConfig = {

const ALERTS_CONFIG: GettingStartedConfig = {
id: 'alerts',
order: 6,
order: 7,
title: i18n.translate('observability.overview.card.alerts.title', {
defaultMessage: 'Get notified',
}),
Expand All @@ -91,7 +105,7 @@ const ALERTS_CONFIG: GettingStartedConfig = {

const ANOMALY_CONFIG: GettingStartedConfig = {
id: 'anomaly',
order: 7,
order: 8,
title: i18n.translate('observability.overview.card.anomaly.title', {
defaultMessage: 'Detect anomalies in your data',
}),
Expand All @@ -102,6 +116,7 @@ const ANOMALY_CONFIG: GettingStartedConfig = {

export const cardConfigs = [
GETTING_STARTED_CONFIG,
SAMPLEDATA_CONFIG,
DISCOVER_CONFIG,
METRICS_CONFIG,
TRACES_CONFIG,
Expand Down
20 changes: 12 additions & 8 deletions public/components/overview/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { EuiText } from '@elastic/eui';
import { EuiI18n } from '@elastic/eui';
import React, { ReactNode, useEffect, useState } from 'react';
import { HashRouter, Route, Switch } from 'react-router-dom';
import { alertsPluginID, anomalyPluginID } from '../../../common/constants/overview';
Expand Down Expand Up @@ -67,13 +67,17 @@ export const Home = () => {
order: card.order,
description: card.description,
title: card.title,
onClick: () => coreRefs.application?.navigateToApp(card.url, { path: '#/' }),
getFooter: () => {
return (
<EuiText size="s" textAlign="center">
{card.footer}
</EuiText>
);
cardProps: {
selectable: {
children: (
<EuiI18n
TackAdam marked this conversation as resolved.
Show resolved Hide resolved
token="home.sampleData.card.footer"
default={card.footer || 'Documentation'}
/>
),
onClick: () => coreRefs.application?.navigateToApp(card.url, { path: '#/' }),
isSelected: false,
},
},
}),
getTargetArea: () => HOME_CONTENT_AREAS.GET_STARTED,
Expand Down
Loading