Skip to content

Commit

Permalink
reverting some unnecessary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes committed Jun 2, 2020
1 parent 0636b5f commit d9d1d6a
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ export const SectionLink: React.FC<EuiListGroupItemProps> = (props) => (
<EuiListGroupItem style={{ padding: 0 }} size={'s'} {...props} />
);

export const ActionMenuDivider: React.FC<{}> = (props) => (
<EuiHorizontalRule margin={'s'} />
);
export const ActionMenuDivider: React.FC<{}> = (props) => <EuiHorizontalRule margin={'s'} />;

export const ActionMenu: React.FC<Props> = (props) => (
<EuiPopover {...props} ownFocus={true} />
);
export const ActionMenu: React.FC<Props> = (props) => <EuiPopover {...props} ownFocus={true} />;
24 changes: 5 additions & 19 deletions x-pack/plugins/observability/public/hooks/use_track_metric.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,9 @@ export { METRIC_TYPE };
export function useUiTracker<Services extends ServiceDeps>({
app: defaultApp,
}: { app?: ObservabilityApp } = {}) {
const reportUiStats = useKibana<Services>().services?.usageCollection
?.reportUiStats;
const reportUiStats = useKibana<Services>().services?.usageCollection?.reportUiStats;
const trackEvent = useMemo(() => {
return ({
app = defaultApp,
metric,
metricType = METRIC_TYPE.COUNT,
}: TrackMetricOptions) => {
return ({ app = defaultApp, metric, metricType = METRIC_TYPE.COUNT }: TrackMetricOptions) => {
if (reportUiStats) {
reportUiStats(app as string, metricType, metric);
}
Expand All @@ -55,16 +50,10 @@ export function useUiTracker<Services extends ServiceDeps>({
}

export function useTrackMetric<Services extends ServiceDeps>(
{
app,
metric,
metricType = METRIC_TYPE.COUNT,
delay = 0,
}: TrackMetricOptions,
{ app, metric, metricType = METRIC_TYPE.COUNT, delay = 0 }: TrackMetricOptions,
effectDependencies: EffectDeps = []
) {
const reportUiStats = useKibana<Services>().services?.usageCollection
?.reportUiStats;
const reportUiStats = useKibana<Services>().services?.usageCollection?.reportUiStats;

useEffect(() => {
if (!reportUiStats) {
Expand Down Expand Up @@ -99,8 +88,5 @@ export function useTrackPageview<Services extends ServiceDeps>(
{ path, ...rest }: TrackPageviewProps,
effectDependencies: EffectDeps = []
) {
useTrackMetric<Services>(
{ ...rest, metric: `pageview__${path}` },
effectDependencies
);
useTrackMetric<Services>({ ...rest, metric: `pageview__${path}` }, effectDependencies);
}
13 changes: 3 additions & 10 deletions x-pack/plugins/observability/public/typings/eui_draggable/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,11 @@
import React from 'react';
import { EuiDraggable, EuiDragDropContext } from '@elastic/eui';

type PropsOf<T> = T extends React.ComponentType<infer ComponentProps>
? ComponentProps
: never;
type FirstArgumentOf<Func> = Func extends (
arg1: infer FirstArgument,
...rest: any[]
) => any
type PropsOf<T> = T extends React.ComponentType<infer ComponentProps> ? ComponentProps : never;
type FirstArgumentOf<Func> = Func extends (arg1: infer FirstArgument, ...rest: any[]) => any
? FirstArgument
: never;
export type DragHandleProps = FirstArgumentOf<
Exclude<PropsOf<typeof EuiDraggable>['children'], React.ReactElement>
>['dragHandleProps'];
export type DropResult = FirstArgumentOf<
FirstArgumentOf<typeof EuiDragDropContext>['onDragEnd']
>;
export type DropResult = FirstArgumentOf<FirstArgumentOf<typeof EuiDragDropContext>['onDragEnd']>;
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@

import React from 'react';
import * as styledComponents from 'styled-components';
import {
ThemedStyledComponentsModule,
ThemeProvider,
ThemeProviderProps,
} from 'styled-components';
import { ThemedStyledComponentsModule, ThemeProvider, ThemeProviderProps } from 'styled-components';

import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json';
import euiLightVars from '@elastic/eui/dist/eui_theme_light.json';
Expand Down Expand Up @@ -46,11 +42,4 @@ const {
withTheme,
} = (styledComponents as unknown) as ThemedStyledComponentsModule<EuiTheme>;

export {
css,
euiStyled,
EuiThemeProvider,
createGlobalStyle,
keyframes,
withTheme,
};
export { css, euiStyled, EuiThemeProvider, createGlobalStyle, keyframes, withTheme };
5 changes: 1 addition & 4 deletions x-pack/plugins/observability/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
import { schema, TypeOf } from '@kbn/config-schema';
import { PluginInitializerContext } from 'src/core/server';
import { ObservabilityPlugin, ObservabilityPluginSetup } from './plugin';
import {
createOrUpdateIndex,
MappingsDefinition,
} from './utils/create_or_update_index';
import { createOrUpdateIndex, MappingsDefinition } from './utils/create_or_update_index';
import { ScopedAnnotationsClient } from './lib/annotations/bootstrap_annotations';

export const config = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function bootstrapAnnotations({ index, core, context }: Params) {
getScopedAnnotationsClient: (requestContext: RequestHandlerContext, request: KibanaRequest) => {
return createAnnotationsClient({
index,
apiCaller: requestContext.core.elasticsearch.dataClient.callAsCurrentUser,
apiCaller: requestContext.core.elasticsearch.legacy.client.callAsCurrentUser,
logger,
license: requestContext.licensing?.license,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ export function createAnnotationsClient(params: {
function ensureGoldLicense<T extends (...args: any[]) => any>(fn: T): T {
return ((...args) => {
if (!license?.hasAtLeast('gold')) {
throw Boom.forbidden(
'Annotations require at least a gold license or a trial license.'
);
throw Boom.forbidden('Annotations require at least a gold license or a trial license.');
}
return fn(...args);
}) as T;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ export function registerAnnotationAPIs({
}) {
function wrapRouteHandler<TType extends t.Type<any>>(
types: TType,
handler: (params: {
data: t.TypeOf<TType>;
client: ScopedAnnotationsClient;
}) => Promise<any>
handler: (params: { data: t.TypeOf<TType>; client: ScopedAnnotationsClient }) => Promise<any>
): RequestHandler {
return async (...args: Parameters<RequestHandler>) => {
const [context, request, response] = args;
Expand Down Expand Up @@ -75,9 +72,7 @@ export function registerAnnotationAPIs({
return response.custom({
statusCode: err.output?.statusCode ?? 500,
body: {
message:
err.output?.payload?.message ??
'An internal server error occured',
message: err.output?.payload?.message ?? 'An internal server error occured',
},
});
}
Expand All @@ -93,12 +88,9 @@ export function registerAnnotationAPIs({
body: unknowns,
},
},
wrapRouteHandler(
t.type({ body: createAnnotationRt }),
({ data, client }) => {
return client.create(data.body);
}
)
wrapRouteHandler(t.type({ body: createAnnotationRt }), ({ data, client }) => {
return client.create(data.body);
})
);

router.delete(
Expand All @@ -108,12 +100,9 @@ export function registerAnnotationAPIs({
params: unknowns,
},
},
wrapRouteHandler(
t.type({ params: deleteAnnotationRt }),
({ data, client }) => {
return client.delete(data.params);
}
)
wrapRouteHandler(t.type({ params: deleteAnnotationRt }), ({ data, client }) => {
return client.delete(data.params);
})
);

router.get(
Expand All @@ -123,11 +112,8 @@ export function registerAnnotationAPIs({
params: unknowns,
},
},
wrapRouteHandler(
t.type({ params: getAnnotationByIdRt }),
({ data, client }) => {
return client.getById(data.params);
}
)
wrapRouteHandler(t.type({ params: getAnnotationByIdRt }), ({ data, client }) => {
return client.getById(data.params);
})
);
}
5 changes: 1 addition & 4 deletions x-pack/plugins/observability/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ export class ObservabilityPlugin implements Plugin<ObservabilityPluginSetup> {
this.initContext = initContext;
}

public async setup(
core: CoreSetup,
plugins: {}
): Promise<ObservabilityPluginSetup> {
public async setup(core: CoreSetup, plugins: {}): Promise<ObservabilityPluginSetup> {
const config$ = this.initContext.config.create<ObservabilityConfig>();

const config = await config$.pipe(take(1)).toPromise();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ export async function createOrUpdateIndex({
});

if (!result.acknowledged) {
const resultError =
result && result.error && JSON.stringify(result.error);
const resultError = result && result.error && JSON.stringify(result.error);
throw new Error(resultError);
}
},
Expand Down
4 changes: 1 addition & 3 deletions x-pack/plugins/observability/typings/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

export type PromiseReturnType<Func> = Func extends (
...args: any[]
) => Promise<infer Value>
export type PromiseReturnType<Func> = Func extends (...args: any[]) => Promise<infer Value>
? Value
: Func;

0 comments on commit d9d1d6a

Please sign in to comment.