Skip to content

Commit

Permalink
add helper type
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed Apr 17, 2024
1 parent d62161a commit 8abc1b3
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import ReactMarkdown from 'react-markdown';

import type {
AppMountParameters,
CoreStart,
FatalErrorsStart,
HttpStart,
NotificationsStart,
Expand All @@ -32,6 +31,7 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render';

import type { StartServices } from '../..';
import { parseNext } from '../../../common/parse_next';
import { AuthenticationStatePage } from '../components';

Expand Down Expand Up @@ -128,7 +128,7 @@ export function AccessAgreementPage({ http, fatalErrors, notifications }: Props)
}

export function renderAccessAgreementPage(
services: Pick<CoreStart, 'analytics' | 'i18n' | 'theme'>,
services: StartServices,
{ element }: Pick<AppMountParameters, 'element'>,
props: Props
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ import React from 'react';
import ReactDOM from 'react-dom';
import useObservable from 'react-use/lib/useObservable';

import type {
AppMountParameters,
CoreStart,
CustomBrandingStart,
IBasePath,
} from '@kbn/core/public';
import type { AppMountParameters, CustomBrandingStart, IBasePath } from '@kbn/core/public';
import { FormattedMessage } from '@kbn/i18n-react';
import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render';

import type { StartServices } from '../..';
import { parseNext } from '../../../common/parse_next';
import { AuthenticationStatePage } from '../components';

Expand Down Expand Up @@ -47,7 +43,7 @@ export function LoggedOutPage({ basePath, customBranding }: Props) {
}

export function renderLoggedOutPage(
services: Pick<CoreStart, 'analytics' | 'i18n' | 'theme'>,
services: StartServices,
{ element }: Pick<AppMountParameters, 'element'>,
props: Props
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { BehaviorSubject } from 'rxjs';

import type {
AppMountParameters,
CoreStart,
CustomBrandingStart,
FatalErrorsStart,
HttpStart,
Expand All @@ -38,6 +37,7 @@ import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render';

import type { LoginFormProps } from './components';
import { DisabledLoginForm, LoginForm, LoginFormMessageType } from './components';
import type { StartServices } from '../..';
import {
AUTH_PROVIDER_HINT_QUERY_STRING_PARAMETER,
LOGOUT_REASON_QUERY_STRING_PARAMETER,
Expand Down Expand Up @@ -368,7 +368,7 @@ export class LoginPage extends Component<Props, State> {
}

export function renderLoginPage(
services: Pick<CoreStart, 'analytics' | 'i18n' | 'theme'>,
services: StartServices,
{ element }: Pick<AppMountParameters, 'element'>,
props: Props
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import { EuiButton } from '@elastic/eui';
import React, { useEffect, useState } from 'react';
import ReactDOM from 'react-dom';

import type { AppMountParameters, CoreStart, IBasePath } from '@kbn/core/public';
import type { AppMountParameters, IBasePath } from '@kbn/core/public';
import { FormattedMessage } from '@kbn/i18n-react';
import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render';
import type { AuthenticationServiceSetup } from '@kbn/security-plugin-types-public';

import type { StartServices } from '../..';
import { parseNext } from '../../../common/parse_next';
import { AuthenticationStatePage } from '../components';

Expand Down Expand Up @@ -53,7 +54,7 @@ export function OverwrittenSessionPage({ authc, basePath }: Props) {
}

export function renderOverwrittenSessionPage(
services: Pick<CoreStart, 'analytics' | 'i18n' | 'theme'>,
services: StartServices,
{ element }: Pick<AppMountParameters, 'element'>,
props: Props
) {
Expand Down
5 changes: 4 additions & 1 deletion x-pack/plugins/security/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import type { PluginInitializer, PluginInitializerContext } from '@kbn/core/public';
import type { CoreStart, PluginInitializer, PluginInitializerContext } from '@kbn/core/public';
import type { SecurityPluginSetup } from '@kbn/security-plugin-types-public';

import type {
Expand Down Expand Up @@ -40,3 +40,6 @@ export const plugin: PluginInitializer<
PluginSetupDependencies,
PluginStartDependencies
> = (initializerContext: PluginInitializerContext) => new SecurityPlugin(initializerContext);

// services needed for rendering React using shared modules
export type StartServices = Pick<CoreStart, 'analytics' | 'i18n' | 'theme'>;
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import useAsyncFn from 'react-use/lib/useAsyncFn';
import useObservable from 'react-use/lib/useObservable';
import type { Observable } from 'rxjs';

import type { CoreStart, ToastInput } from '@kbn/core/public';
import type { ToastInput } from '@kbn/core/public';
import { i18n } from '@kbn/i18n';
import { FormattedMessage, FormattedRelative } from '@kbn/i18n-react';
import { toMountPoint } from '@kbn/react-kibana-mount';

import type { SessionState } from './session_timeout';
import type { StartServices } from '..';
import { SESSION_GRACE_PERIOD_MS } from '../../common/constants';

export interface SessionExpirationToastProps {
Expand Down Expand Up @@ -74,7 +75,7 @@ export const SessionExpirationToast: FunctionComponent<SessionExpirationToastPro
};

export const createSessionExpirationToast = (
services: Pick<CoreStart, 'analytics' | 'i18n' | 'theme'>,
services: StartServices,
sessionState$: Observable<SessionState>,
onExtend: () => Promise<any>,
onClose: () => void
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/security/public/session/session_timeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type { Subscription } from 'rxjs';
import { BehaviorSubject, skip, tap, throttleTime } from 'rxjs';

import type {
CoreStart,
HttpFetchOptionsWithPath,
HttpSetup,
NotificationsSetup,
Expand All @@ -18,6 +17,7 @@ import type {

import { createSessionExpirationToast } from './session_expiration_toast';
import type { SessionExpired } from './session_expired';
import type { StartServices } from '..';
import {
SESSION_CHECK_MS,
SESSION_EXPIRATION_WARNING_MS,
Expand Down Expand Up @@ -58,7 +58,7 @@ export class SessionTimeout {
private stopLogoutTimer?: Function;

constructor(
private startServices: Pick<CoreStart, 'analytics' | 'i18n' | 'theme'>,
private startServices: StartServices,
private notifications: NotificationsSetup,
private sessionExpired: Pick<SessionExpired, 'logout'>,
private http: HttpSetup,
Expand Down

0 comments on commit 8abc1b3

Please sign in to comment.