Skip to content

Commit

Permalink
[Logs onboarding] Explore logs button should have different states (#…
Browse files Browse the repository at this point in the history
…167409)

Closes #166009.

When system integration is installed successfully we should be able to
redirect the user to logs explorer with the `System integration`
selected


https://github.com/elastic/kibana/assets/1313018/7a1d7457-00e8-4399-9332-3ea7af2b0145

When system integration installation failed we should be able to
redirect the user to logs explorer with `All logs` selected


https://github.com/elastic/kibana/assets/1313018/e13f69ab-adb4-460c-84cf-d9971ce56b9f

When system integration is being installed, Explore Logs button should
be disabled


https://github.com/elastic/kibana/assets/1313018/5dd04859-e75b-49ed-9f47-5ad2120eb9d8

### How to test
1. Log in as `viewer` user
2. Enter [system
logs](https://deploy-kibana-pr167409.kb.us-west2.gcp.elastic-cloud.com/app/observabilityOnboarding/systemLogs)
onboarding flow
3. Verify System integration was not installed
4. Click on `Explore Logs`
5. Verify you are being redirected to Log explorer with `All logs` being
selected
6. Logout and log in again as `admin` user
7. Enter [system
logs](https://deploy-kibana-pr167409.kb.us-west2.gcp.elastic-cloud.com/app/observabilityOnboarding/systemLogs)
onboarding flow
8. Verify system integration was installed successfully
9. Click on `Explore Logs`
10. Verify you are being redirected to Log explorer with `[system]`
being selected
  • Loading branch information
yngrdyn authored Oct 2, 2023
1 parent 6d34331 commit 45771ff
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -644,14 +644,48 @@ describe('[Logs onboarding] System logs', () => {
.contains('Logs are being shipped!')
.should('exist');
});
});

it('when user clicks on Explore Logs it navigates to observability log explorer', () => {
cy.wait('@systemIntegrationInstall');
cy.wait('@checkOnboardingProgress');
cy.getByTestSubj('obltOnboardingExploreLogs').should('exist').click();
describe('Explore Logs', () => {
describe('when integration installation fails', () => {
beforeEach(() => {
cy.deleteIntegration('system');
cy.intercept('GET', '/api/fleet/epm/packages/system', {
statusCode: 500,
body: {
message: 'Internal error',
},
}).as('systemIntegrationInstall');
cy.loginAsLogMonitoringUser();
cy.visitKibana('/app/observabilityOnboarding/systemLogs');
});

it('when users clicks on Explore logs they navigate to log explorer - All logs', () => {
cy.wait('@systemIntegrationInstall');
cy.getByTestSubj('obltOnboardingExploreLogs').should('exist').click();

cy.url().should('include', '/app/observability-log-explorer');
cy.get('button').contains('[System] syslog').should('exist');
cy.url().should('include', '/app/observability-log-explorer');
cy.get('button').contains('All logs').should('exist');
});
});

describe('when integration installation succeed', () => {
beforeEach(() => {
cy.deleteIntegration('system');
cy.intercept('GET', '/api/fleet/epm/packages/system').as(
'systemIntegrationInstall'
);
cy.loginAsLogMonitoringUser();
cy.visitKibana('/app/observabilityOnboarding/systemLogs');
});

it('when users clicks on Explore logs they navigate to log explorer and System integration is selected', () => {
cy.wait('@systemIntegrationInstall');
cy.getByTestSubj('obltOnboardingExploreLogs').should('exist').click();

cy.url().should('include', '/app/observability-log-explorer');
cy.get('button').contains('[System] syslog').should('exist');
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,40 @@ import {
EuiSpacer,
EuiText,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { default as React, useCallback, useEffect, useState } from 'react';
import {
AllDatasetsLocatorParams,
ALL_DATASETS_LOCATOR_ID,
SingleDatasetLocatorParams,
SINGLE_DATASET_LOCATOR_ID,
} from '@kbn/deeplinks-observability/locators';
import { ObservabilityOnboardingPluginSetupDeps } from '../../../plugin';
import { i18n } from '@kbn/i18n';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { default as React, useCallback, useEffect, useState } from 'react';
import { useWizard } from '.';
import { FETCH_STATUS, useFetcher } from '../../../hooks/use_fetcher';
import { useKibanaNavigation } from '../../../hooks/use_kibana_navigation';
import { ObservabilityOnboardingPluginSetupDeps } from '../../../plugin';
import {
ElasticAgentPlatform,
getElasticAgentSetupCommand,
} from '../../shared/get_elastic_agent_setup_command';
import {
EuiStepStatus,
InstallElasticAgentSteps,
ProgressStepId,
EuiStepStatus,
} from '../../shared/install_elastic_agent_steps';
import {
StepPanel,
StepPanelContent,
StepPanelFooter,
} from '../../shared/step_panel';
import { ApiKeyBanner } from '../custom_logs/api_key_banner';
import { WindowsInstallStep } from '../../shared/windows_install_step';
import { SystemIntegrationBanner } from './system_integration_banner';
import { TroubleshootingLink } from '../../shared/troubleshooting_link';
import { WindowsInstallStep } from '../../shared/windows_install_step';
import { ApiKeyBanner } from '../custom_logs/api_key_banner';
import {
SystemIntegrationBanner,
SystemIntegrationBannerState,
} from './system_integration_banner';

export function InstallElasticAgent() {
const {
Expand All @@ -52,19 +57,37 @@ export function InstallElasticAgent() {
share.url.locators.get<SingleDatasetLocatorParams>(
SINGLE_DATASET_LOCATOR_ID
);
const allDataSetsLocator = share.url.locators.get<AllDatasetsLocatorParams>(
ALL_DATASETS_LOCATOR_ID
);

const { navigateToKibanaUrl } = useKibanaNavigation();
const { getState, setState } = useWizard();
const wizardState = getState();
const [elasticAgentPlatform, setElasticAgentPlatform] =
useState<ElasticAgentPlatform>('linux-tar');
const [systemIntegrationStatus, setSystemIntegrationStatus] =
useState<SystemIntegrationBannerState>('pending');

const onIntegrationStatusChange = useCallback(
(status: SystemIntegrationBannerState) => {
setSystemIntegrationStatus(status);
},
[]
);

const datasetName = 'system-logs';

function onBack() {
navigateToKibanaUrl('/app/observabilityOnboarding');
}

async function onContinue() {
if (systemIntegrationStatus === 'rejected') {
await allDataSetsLocator!.navigate({});
return;
}

await singleDatasetLocator!.navigate({
integration: 'system',
dataset: 'system.syslog',
Expand Down Expand Up @@ -216,6 +239,7 @@ export function InstallElasticAgent() {
iconType="magnifyWithPlus"
onClick={onContinue}
data-test-subj="obltOnboardingExploreLogs"
disabled={systemIntegrationStatus === 'pending'}
>
{i18n.translate(
'xpack.observability_onboarding.steps.exploreLogs',
Expand All @@ -241,7 +265,7 @@ export function InstallElasticAgent() {
</p>
</EuiText>
<EuiSpacer size="m" />
<SystemIntegrationBanner />
<SystemIntegrationBanner onStatusChange={onIntegrationStatusChange} />
<EuiSpacer size="m" />
{apiKeyEncoded && onboardingId ? (
<ApiKeyBanner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,31 @@ import {
import { useKibanaNavigation } from '../../../hooks/use_kibana_navigation';
import { PopoverTooltip } from '../../shared/popover_tooltip';

export function SystemIntegrationBanner() {
export type SystemIntegrationBannerState = 'pending' | 'resolved' | 'rejected';

export function SystemIntegrationBanner({
onStatusChange,
}: {
onStatusChange: (status: SystemIntegrationBannerState) => void;
}) {
const { navigateToAppUrl } = useKibanaNavigation();
const [integrationVersion, setIntegrationVersion] = useState<string>();
const [error, setError] = useState<SystemIntegrationError>();

const onIntegrationCreationSuccess = useCallback(
({ version }: { version?: string }) => {
setIntegrationVersion(version);
onStatusChange('resolved');
},
[]
[onStatusChange]
);

const onIntegrationCreationFailure = useCallback(
(e: SystemIntegrationError) => {
setError(e);
onStatusChange('rejected');
},
[]
[onStatusChange]
);

const { performRequest, requestState } = useInstallSystemIntegration({
Expand Down

0 comments on commit 45771ff

Please sign in to comment.