Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
mgiota committed Feb 20, 2024
1 parent 066301d commit cdf7de2
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 27 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,8 @@
"@kbn/shared-ux-storybook-config": "link:packages/shared-ux/storybook/config",
"@kbn/shared-ux-storybook-mock": "link:packages/shared-ux/storybook/mock",
"@kbn/shared-ux-utility": "link:packages/kbn-shared-ux-utility",
"@kbn/slos-plugin": "link:x-pack/plugins/observability_solution/slos",
"@kbn/slo-schema": "link:x-pack/packages/kbn-slo-schema",
"@kbn/slos-plugin": "link:x-pack/plugins/observability_solution/slos",
"@kbn/snapshot-restore-plugin": "link:x-pack/plugins/snapshot_restore",
"@kbn/sort-predicates": "link:packages/kbn-sort-predicates",
"@kbn/spaces-plugin": "link:x-pack/plugins/spaces",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React from 'react';
import ReactDOM from 'react-dom';
import { AppMountParameters, CoreStart } from '../../../src/core/public';
import { AppMountParameters, CoreStart } from '@kbn/core/public';
import { AppPluginStartDependencies } from './types';
import { SlosApp } from './components/app';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React, { useState } from 'react';
import { i18n } from '@kbn/i18n';
import { FormattedMessage, I18nProvider } from '@kbn/i18n-react';
Expand All @@ -15,7 +22,7 @@ interface SlosAppDeps {
navigation: NavigationPublicPluginStart;
}

export const SlosApp = ({ basename, notifications, http, navigation }: SlosAppDeps) => {
export function SlosApp({ basename, notifications, http, navigation }: SlosAppDeps) {
// Use React hooks to manage state.
const [timestamp, setTimestamp] = useState<string | undefined>();

Expand All @@ -25,9 +32,7 @@ export const SlosApp = ({ basename, notifications, http, navigation }: SlosAppDe
setTimestamp(res.time);
// Use the core notifications service to display a success message.
notifications.toasts.addSuccess(
i18n.translate('slos.dataUpdated', {
defaultMessage: 'Data updated',
})
i18n.translate('xpack.slos.onClickHandler.', { defaultMessage: '' })
);
});
};
Expand Down Expand Up @@ -79,7 +84,12 @@ export const SlosApp = ({ basename, notifications, http, navigation }: SlosAppDe
values={{ time: timestamp ? timestamp : 'Unknown' }}
/>
</p>
<EuiButton type="primary" size="s" onClick={onClickHandler}>
<EuiButton
data-test-subj="observabilitySolutionSlosAppGetDataButton"
type="primary"
size="s"
onClick={onClickHandler}
>
<FormattedMessage id="slos.buttonText" defaultMessage="Get data" />
</EuiButton>
</EuiText>
Expand All @@ -89,4 +99,4 @@ export const SlosApp = ({ basename, notifications, http, navigation }: SlosAppDe
</I18nProvider>
</Router>
);
};
}
Empty file.
7 changes: 6 additions & 1 deletion x-pack/plugins/observability_solution/slos/public/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import './index.scss';
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { SlosPlugin } from './plugin';

Expand Down
28 changes: 17 additions & 11 deletions x-pack/plugins/observability_solution/slos/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,23 @@
*/

import { i18n } from '@kbn/i18n';
import { AppMountParameters, CoreSetup, CoreStart, Plugin } from '../../../src/core/public';
import { SlosPluginSetup, SlosPluginStart, AppPluginStartDependencies } from './types';
import {
AppMountParameters,
AppNavLinkStatus,
CoreSetup,
CoreStart,
DEFAULT_APP_CATEGORIES,
Plugin,
PluginInitializerContext,
} from '@kbn/core/public';
import { SlosPluginSetupDeps, SlosPluginStartDeps } from './types'; // TODO move later to type
import { PLUGIN_NAME } from '../common';

export type SlosPluginSetup = ReturnType<SlosPlugin['setup']>;
export type SlosPluginStart = void;

export class SlosPlugin implements Plugin<SlosPluginSetup, SlosPluginStart> {
public setup(core: CoreSetup): SlosPluginSetup {
public setup(core: CoreSetup, plugins: SlosPluginSetupDeps) /* : SlosPluginSetup*/ {
// Register an application into the side navigation menu
core.application.register({
id: 'slos',
Expand All @@ -22,24 +33,19 @@ export class SlosPlugin implements Plugin<SlosPluginSetup, SlosPluginStart> {
// Get start services as specified in kibana.json
const [coreStart, depsStart] = await core.getStartServices();
// Render the application
return renderApp(coreStart, depsStart as AppPluginStartDependencies, params);
return renderApp(coreStart, depsStart as SlosPluginStartDeps, params);
},
});

// Return methods that should be available to other plugins
return {
getGreeting() {
return i18n.translate('slos.greetingText', {
defaultMessage: 'Hello from {name}!',
values: {
name: PLUGIN_NAME,
},
});
return i18n.translate('xpack.slos..', { defaultMessage: '' });
},
};
}

public start(core: CoreStart): SlosPluginStart {
public start(core: CoreStart, plugins: SlosPluginStartDeps) /* : SlosPluginStart*/ {
return {};
}

Expand Down
34 changes: 27 additions & 7 deletions x-pack/plugins/observability_solution/slos/public/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
import { NavigationPublicPluginStart } from '../../../src/plugins/navigation/public';
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export interface SlosPluginSetup {
getGreeting: () => string;
import {
ObservabilityPublicSetup,
ObservabilityPublicStart,
} from '@kbn/observability-plugin/public';
import type {
ObservabilitySharedPluginSetup,
ObservabilitySharedPluginStart,
} from '@kbn/observability-shared-plugin/public';
import type {
TriggersAndActionsUIPublicPluginSetup,
TriggersAndActionsUIPublicPluginStart,
} from '@kbn/triggers-actions-ui-plugin/public';

export interface SlosPluginSetupDeps {
observability: ObservabilityPublicSetup;
observabilityShared: ObservabilitySharedPluginSetup;
triggersActionsUi: TriggersAndActionsUIPublicPluginSetup;
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface SlosPluginStart {}

export interface AppPluginStartDependencies {
navigation: NavigationPublicPluginStart;
export interface SlosPluginStartDeps {
observability: ObservabilityPublicStart;
observabilityShared: ObservabilitySharedPluginStart;
triggersActionsUi: TriggersAndActionsUIPublicPluginStart;
}
7 changes: 7 additions & 0 deletions x-pack/plugins/observability_solution/slos/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,12 @@
],
"exclude": [
"target/**/*"
],
"kbn_references": [
"@kbn/i18n",
"@kbn/i18n-react",
"@kbn/shared-ux-router",
"@kbn/core",
"@kbn/navigation-plugin",
]
}

0 comments on commit cdf7de2

Please sign in to comment.