parent
78b6d60a3c
commit
5f8e60849d
|
@ -21,6 +21,7 @@ export {
|
|||
SendRequestConfig,
|
||||
SendRequestResponse,
|
||||
UseRequestConfig,
|
||||
UseRequestResponse,
|
||||
sendRequest,
|
||||
useRequest,
|
||||
} from './request';
|
||||
|
|
|
@ -27,7 +27,7 @@ export interface SendRequestConfig {
|
|||
|
||||
export interface SendRequestResponse {
|
||||
data: any;
|
||||
error: Error;
|
||||
error: Error | null;
|
||||
}
|
||||
|
||||
export interface UseRequestConfig extends SendRequestConfig {
|
||||
|
@ -36,10 +36,18 @@ export interface UseRequestConfig extends SendRequestConfig {
|
|||
deserializer?: (data: any) => any;
|
||||
}
|
||||
|
||||
export interface UseRequestResponse {
|
||||
isInitialRequest: boolean;
|
||||
isLoading: boolean;
|
||||
error: null | unknown;
|
||||
data: any;
|
||||
sendRequest: (...args: any[]) => Promise<SendRequestResponse>;
|
||||
}
|
||||
|
||||
export const sendRequest = async (
|
||||
httpClient: ng.IHttpService,
|
||||
{ path, method, body }: SendRequestConfig
|
||||
): Promise<Partial<SendRequestResponse>> => {
|
||||
): Promise<SendRequestResponse> => {
|
||||
try {
|
||||
const response = await (httpClient as any)[method](path, body);
|
||||
|
||||
|
@ -47,9 +55,10 @@ export const sendRequest = async (
|
|||
throw new Error(response.statusText);
|
||||
}
|
||||
|
||||
return { data: response.data };
|
||||
return { data: response.data, error: null };
|
||||
} catch (e) {
|
||||
return {
|
||||
data: null,
|
||||
error: e.response ? e.response : e,
|
||||
};
|
||||
}
|
||||
|
@ -65,7 +74,7 @@ export const useRequest = (
|
|||
initialData,
|
||||
deserializer = (data: any): any => data,
|
||||
}: UseRequestConfig
|
||||
) => {
|
||||
): UseRequestResponse => {
|
||||
// Main states for tracking request status and data
|
||||
const [error, setError] = useState<null | any>(null);
|
||||
const [isLoading, setIsLoading] = useState<boolean>(true);
|
||||
|
@ -112,7 +121,7 @@ export const useRequest = (
|
|||
// If an outdated request has resolved, DON'T update state, but DO allow the processData handler
|
||||
// to execute side effects like update telemetry.
|
||||
if (isOutdatedRequest) {
|
||||
return;
|
||||
return { data: null, error: null };
|
||||
}
|
||||
|
||||
setError(responseError);
|
||||
|
@ -123,6 +132,8 @@ export const useRequest = (
|
|||
// If we're on an interval, we need to schedule the next request. This also allows us to reset
|
||||
// the interval if the user has manually requested the data, to avoid doubled-up requests.
|
||||
scheduleRequest();
|
||||
|
||||
return { data: serializedResponseData, error: responseError };
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -24,3 +24,4 @@ export * from './combobox_field';
|
|||
export * from './multi_select_field';
|
||||
export * from './select_field';
|
||||
export * from './toggle_field';
|
||||
export * from './text_area_field';
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { EuiFormRow, EuiTextArea } from '@elastic/eui';
|
||||
|
||||
import { FieldHook } from '../../hook_form_lib';
|
||||
import { getFieldValidityAndErrorMessage } from '../helpers';
|
||||
|
||||
interface Props {
|
||||
field: FieldHook;
|
||||
euiFieldProps?: Record<string, any>;
|
||||
idAria?: string;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export const TextAreaField = ({ field, euiFieldProps = {}, ...rest }: Props) => {
|
||||
const { isInvalid, errorMessage } = getFieldValidityAndErrorMessage(field);
|
||||
|
||||
return (
|
||||
<EuiFormRow
|
||||
label={field.label}
|
||||
helpText={field.helpText}
|
||||
error={errorMessage}
|
||||
isInvalid={isInvalid}
|
||||
fullWidth
|
||||
data-test-subj={rest['data-test-subj']}
|
||||
describedByIds={rest.idAria ? [rest.idAria] : undefined}
|
||||
>
|
||||
<EuiTextArea
|
||||
isInvalid={isInvalid}
|
||||
value={field.value as string}
|
||||
onChange={field.onChange}
|
||||
fullWidth
|
||||
data-test-subj="input"
|
||||
{...euiFieldProps}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
);
|
||||
};
|
|
@ -12,7 +12,7 @@
|
|||
],
|
||||
"test_utils/*": [
|
||||
"src/test_utils/public/*"
|
||||
],
|
||||
]
|
||||
},
|
||||
// Support .tsx files and transform JSX into calls to React.createElement
|
||||
"jsx": "react",
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export { SectionError } from './section_error';
|
||||
export { SectionError, Error } from './section_error';
|
||||
export { SectionLoading } from './section_loading';
|
||||
export { NoMatch } from './no_match';
|
||||
export { PageErrorForbidden } from './page_error';
|
||||
|
|
|
@ -7,15 +7,17 @@
|
|||
import { EuiCallOut, EuiSpacer } from '@elastic/eui';
|
||||
import React, { Fragment } from 'react';
|
||||
|
||||
export interface Error {
|
||||
data: {
|
||||
error: string;
|
||||
cause?: string[];
|
||||
message?: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface Props {
|
||||
title: React.ReactNode;
|
||||
error: {
|
||||
data: {
|
||||
error: string;
|
||||
cause?: string[];
|
||||
message?: string;
|
||||
};
|
||||
};
|
||||
error: Error;
|
||||
}
|
||||
|
||||
export const SectionError: React.FunctionComponent<Props> = ({ title, error, ...rest }) => {
|
||||
|
|
|
@ -31,10 +31,11 @@ import {
|
|||
UIM_TEMPLATE_DETAIL_PANEL_ALIASES_TAB,
|
||||
} from '../../../../../common/constants';
|
||||
import { Template } from '../../../../../common/types';
|
||||
import { TemplateDeleteModal, SectionLoading, SectionError } from '../../../../components';
|
||||
import { TemplateDeleteModal, SectionLoading, SectionError, Error } from '../../../../components';
|
||||
import { loadIndexTemplate } from '../../../../services/api';
|
||||
import { decodePath } from '../../../../services/routing';
|
||||
import { trackUiMetric, METRIC_TYPE } from '../../../../services/track_ui_metric';
|
||||
import { SendRequestResponse } from '../../../../shared_imports';
|
||||
import { TabSummary, TabMappings, TabSettings, TabAliases } from './tabs';
|
||||
|
||||
interface Props {
|
||||
|
@ -42,7 +43,7 @@ interface Props {
|
|||
onClose: () => void;
|
||||
editTemplate: (templateName: Template['name']) => void;
|
||||
cloneTemplate: (templateName: Template['name']) => void;
|
||||
reload: () => Promise<void>;
|
||||
reload: () => Promise<SendRequestResponse>;
|
||||
}
|
||||
|
||||
const SUMMARY_TAB_ID = 'summary';
|
||||
|
@ -128,7 +129,7 @@ export const TemplateDetails: React.FunctionComponent<Props> = ({
|
|||
defaultMessage="Error loading template"
|
||||
/>
|
||||
}
|
||||
error={error}
|
||||
error={error as Error}
|
||||
data-test-subj="sectionError"
|
||||
/>
|
||||
);
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
EuiFlexItem,
|
||||
EuiFlexGroup,
|
||||
} from '@elastic/eui';
|
||||
import { SectionError, SectionLoading } from '../../../components';
|
||||
import { SectionError, SectionLoading, Error } from '../../../components';
|
||||
import { TemplateTable } from './template_table';
|
||||
import { loadIndexTemplates } from '../../../services/api';
|
||||
import { Template } from '../../../../common/types';
|
||||
|
@ -87,7 +87,7 @@ export const TemplateList: React.FunctionComponent<RouteComponentProps<MatchPara
|
|||
defaultMessage="Error loading templates"
|
||||
/>
|
||||
}
|
||||
error={error}
|
||||
error={error as Error}
|
||||
/>
|
||||
);
|
||||
} else if (Array.isArray(templates) && templates.length === 0) {
|
||||
|
|
|
@ -13,10 +13,11 @@ import { BASE_PATH, UIM_TEMPLATE_SHOW_DETAILS_CLICK } from '../../../../../commo
|
|||
import { TemplateDeleteModal } from '../../../../components';
|
||||
import { trackUiMetric, METRIC_TYPE } from '../../../../services/track_ui_metric';
|
||||
import { getTemplateDetailsLink } from '../../../../services/routing';
|
||||
import { SendRequestResponse } from '../../../../shared_imports';
|
||||
|
||||
interface Props {
|
||||
templates: TemplateListItem[];
|
||||
reload: () => Promise<void>;
|
||||
reload: () => Promise<SendRequestResponse>;
|
||||
editTemplate: (name: Template['name']) => void;
|
||||
cloneTemplate: (name: Template['name']) => void;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import React, { useEffect, useState } from 'react';
|
|||
import { RouteComponentProps } from 'react-router-dom';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { EuiPageBody, EuiPageContent, EuiSpacer, EuiTitle } from '@elastic/eui';
|
||||
import { TemplateForm, SectionLoading, SectionError } from '../../components';
|
||||
import { TemplateForm, SectionLoading, SectionError, Error } from '../../components';
|
||||
import { setBreadcrumbs } from '../../services/set_breadcrumbs';
|
||||
import { decodePath, getTemplateDetailsLink } from '../../services/routing';
|
||||
import { Template } from '../../../common/types';
|
||||
|
@ -77,7 +77,7 @@ export const TemplateClone: React.FunctionComponent<RouteComponentProps<MatchPar
|
|||
defaultMessage="Error loading template to clone"
|
||||
/>
|
||||
}
|
||||
error={templateToCloneError}
|
||||
error={templateToCloneError as Error}
|
||||
data-test-subj="sectionError"
|
||||
/>
|
||||
);
|
||||
|
|
|
@ -10,7 +10,7 @@ import { EuiPageBody, EuiPageContent, EuiTitle, EuiSpacer, EuiCallOut } from '@e
|
|||
import { setBreadcrumbs } from '../../services/set_breadcrumbs';
|
||||
import { loadIndexTemplate, updateTemplate } from '../../services/api';
|
||||
import { decodePath, getTemplateDetailsLink } from '../../services/routing';
|
||||
import { SectionLoading, SectionError, TemplateForm } from '../../components';
|
||||
import { SectionLoading, SectionError, TemplateForm, Error } from '../../components';
|
||||
import { Template } from '../../../common/types';
|
||||
|
||||
interface MatchParams {
|
||||
|
@ -73,7 +73,7 @@ export const TemplateEdit: React.FunctionComponent<RouteComponentProps<MatchPara
|
|||
defaultMessage="Error loading template"
|
||||
/>
|
||||
}
|
||||
error={error}
|
||||
error={error as Error}
|
||||
data-test-subj="sectionError"
|
||||
/>
|
||||
);
|
||||
|
|
|
@ -13,7 +13,7 @@ import {
|
|||
} from '../shared_imports';
|
||||
import { getHttpClient } from './api';
|
||||
|
||||
export const sendRequest = (config: SendRequestConfig): Promise<Partial<SendRequestResponse>> => {
|
||||
export const sendRequest = (config: SendRequestConfig): Promise<SendRequestResponse> => {
|
||||
return _sendRequest(getHttpClient(), config);
|
||||
};
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ export { RepositoryDeleteProvider } from './repository_delete_provider';
|
|||
export { RepositoryForm } from './repository_form';
|
||||
export { RepositoryVerificationBadge } from './repository_verification_badge';
|
||||
export { RepositoryTypeLogo } from './repository_type_logo';
|
||||
export { SectionError } from './section_error';
|
||||
export { SectionError, Error } from './section_error';
|
||||
export { SectionLoading } from './section_loading';
|
||||
export { SnapshotDeleteProvider } from './snapshot_delete_provider';
|
||||
export { RestoreSnapshotForm } from './restore_snapshot_form';
|
||||
|
|
|
@ -30,7 +30,7 @@ import { documentationLinksService } from '../../services/documentation';
|
|||
import { useLoadRepositoryTypes } from '../../services/http';
|
||||
import { textService } from '../../services/text';
|
||||
import { RepositoryValidation } from '../../services/validation';
|
||||
import { SectionError, SectionLoading, RepositoryTypeLogo } from '../';
|
||||
import { SectionError, SectionLoading, RepositoryTypeLogo, Error } from '../';
|
||||
|
||||
interface Props {
|
||||
repository: Repository | EmptyRepository;
|
||||
|
@ -177,7 +177,7 @@ export const RepositoryFormStepOne: React.FunctionComponent<Props> = ({
|
|||
defaultMessage="Error loading repository types"
|
||||
/>
|
||||
}
|
||||
error={repositoryTypesError}
|
||||
error={repositoryTypesError as Error}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -7,15 +7,17 @@
|
|||
import { EuiCallOut, EuiSpacer } from '@elastic/eui';
|
||||
import React, { Fragment } from 'react';
|
||||
|
||||
export interface Error {
|
||||
data: {
|
||||
error: string;
|
||||
cause?: string[];
|
||||
message?: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface Props {
|
||||
title: React.ReactNode;
|
||||
error: {
|
||||
data: {
|
||||
error: string;
|
||||
cause?: string[];
|
||||
message?: string;
|
||||
};
|
||||
};
|
||||
error: Error;
|
||||
actions?: JSX.Element;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ export const AuthorizationProvider = ({ privilegesEndpoint, children }: Props) =
|
|||
isLoading,
|
||||
privileges: isLoading ? { hasAllPrivileges: true, missingPrivileges: {} } : privilegesData,
|
||||
apiError: error ? error : null,
|
||||
};
|
||||
} as Authorization;
|
||||
|
||||
return <AuthorizationContext.Provider value={value}>{children}</AuthorizationContext.Provider>;
|
||||
};
|
||||
|
|
|
@ -37,6 +37,7 @@ import {
|
|||
SectionLoading,
|
||||
PolicyExecuteProvider,
|
||||
PolicyDeleteProvider,
|
||||
Error,
|
||||
} from '../../../../components';
|
||||
import { TabSummary, TabHistory } from './tabs';
|
||||
|
||||
|
@ -144,7 +145,7 @@ export const PolicyDetails: React.FunctionComponent<Props> = ({
|
|||
};
|
||||
|
||||
const renderError = () => {
|
||||
const notFound = error.status === 404;
|
||||
const notFound = (error as any).status === 404;
|
||||
const errorObject = notFound
|
||||
? {
|
||||
data: {
|
||||
|
@ -168,7 +169,7 @@ export const PolicyDetails: React.FunctionComponent<Props> = ({
|
|||
defaultMessage="Error loading policy"
|
||||
/>
|
||||
}
|
||||
error={errorObject}
|
||||
error={errorObject as Error}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -10,7 +10,7 @@ import { RouteComponentProps } from 'react-router-dom';
|
|||
import { EuiEmptyPrompt, EuiButton, EuiCallOut, EuiSpacer } from '@elastic/eui';
|
||||
import { SlmPolicy } from '../../../../../common/types';
|
||||
import { APP_SLM_CLUSTER_PRIVILEGES } from '../../../../../common/constants';
|
||||
import { SectionError, SectionLoading } from '../../../components';
|
||||
import { SectionError, SectionLoading, Error } from '../../../components';
|
||||
import { BASE_PATH, UIM_POLICY_LIST_LOAD } from '../../../constants';
|
||||
import { useAppDependencies } from '../../../index';
|
||||
import { useLoadPolicies, useLoadRetentionSettings } from '../../../services/http';
|
||||
|
@ -102,7 +102,7 @@ export const PolicyList: React.FunctionComponent<RouteComponentProps<MatchParams
|
|||
defaultMessage="Error loading policies"
|
||||
/>
|
||||
}
|
||||
error={error}
|
||||
error={error as Error}
|
||||
/>
|
||||
);
|
||||
} else if (policies && policies.length === 0) {
|
||||
|
|
|
@ -28,10 +28,11 @@ import {
|
|||
} from '../../../../components';
|
||||
import { uiMetricService } from '../../../../services/ui_metric';
|
||||
import { linkToAddPolicy, linkToEditPolicy } from '../../../../services/navigation';
|
||||
import { SendRequestResponse } from '../../../../../shared_imports';
|
||||
|
||||
interface Props {
|
||||
policies: SlmPolicy[];
|
||||
reload: () => Promise<void>;
|
||||
reload: () => Promise<SendRequestResponse>;
|
||||
openPolicyDetailsUrl: (name: SlmPolicy['name']) => string;
|
||||
onPolicyDeleted: (policiesDeleted: Array<SlmPolicy['name']>) => void;
|
||||
onPolicyExecuted: () => void;
|
||||
|
|
|
@ -39,6 +39,7 @@ import {
|
|||
SectionError,
|
||||
SectionLoading,
|
||||
RepositoryVerificationBadge,
|
||||
Error,
|
||||
} from '../../../../components';
|
||||
import { TypeDetails } from './type_details';
|
||||
|
||||
|
@ -98,7 +99,7 @@ export const RepositoryDetails: React.FunctionComponent<Props> = ({
|
|||
};
|
||||
|
||||
const renderError = () => {
|
||||
const notFound = error.status === 404;
|
||||
const notFound = (error as any).status === 404;
|
||||
const errorObject = notFound
|
||||
? {
|
||||
data: {
|
||||
|
@ -122,7 +123,7 @@ export const RepositoryDetails: React.FunctionComponent<Props> = ({
|
|||
defaultMessage="Error loading repository"
|
||||
/>
|
||||
}
|
||||
error={errorObject}
|
||||
error={errorObject as Error}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -9,7 +9,7 @@ import { RouteComponentProps } from 'react-router-dom';
|
|||
|
||||
import { EuiButton, EuiEmptyPrompt } from '@elastic/eui';
|
||||
import { Repository } from '../../../../../common/types';
|
||||
import { SectionError, SectionLoading } from '../../../components';
|
||||
import { SectionError, SectionLoading, Error } from '../../../components';
|
||||
import { BASE_PATH, UIM_REPOSITORY_LIST_LOAD } from '../../../constants';
|
||||
import { useAppDependencies } from '../../../index';
|
||||
import { useLoadRepositories } from '../../../services/http';
|
||||
|
@ -88,7 +88,7 @@ export const RepositoryList: React.FunctionComponent<RouteComponentProps<MatchPa
|
|||
defaultMessage="Error loading repositories"
|
||||
/>
|
||||
}
|
||||
error={error}
|
||||
error={error as Error}
|
||||
/>
|
||||
);
|
||||
} else if (repositories && repositories.length === 0) {
|
||||
|
|
|
@ -24,11 +24,12 @@ import { useAppDependencies } from '../../../../index';
|
|||
import { textService } from '../../../../services/text';
|
||||
import { uiMetricService } from '../../../../services/ui_metric';
|
||||
import { linkToEditRepository, linkToAddRepository } from '../../../../services/navigation';
|
||||
import { SendRequestResponse } from '../../../../../shared_imports';
|
||||
|
||||
interface Props {
|
||||
repositories: Repository[];
|
||||
managedRepository?: string;
|
||||
reload: () => Promise<void>;
|
||||
reload: () => Promise<SendRequestResponse>;
|
||||
openRepositoryDetailsUrl: (name: Repository['name']) => string;
|
||||
onRepositoryDeleted: (repositoriesDeleted: Array<Repository['name']>) => void;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import {
|
|||
EuiLink,
|
||||
} from '@elastic/eui';
|
||||
import { APP_RESTORE_INDEX_PRIVILEGES } from '../../../../../common/constants';
|
||||
import { SectionError, SectionLoading } from '../../../components';
|
||||
import { SectionError, SectionLoading, Error } from '../../../components';
|
||||
import { UIM_RESTORE_LIST_LOAD } from '../../../constants';
|
||||
import { useAppDependencies } from '../../../index';
|
||||
import { useLoadRestores } from '../../../services/http';
|
||||
|
@ -85,7 +85,7 @@ export const RestoreList: React.FunctionComponent = () => {
|
|||
defaultMessage="Error loading restores"
|
||||
/>
|
||||
}
|
||||
error={error}
|
||||
error={error as Error}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,12 @@ import {
|
|||
import React, { Fragment, useState, useEffect } from 'react';
|
||||
|
||||
import { SnapshotDetails as ISnapshotDetails } from '../../../../../../common/types';
|
||||
import { SectionError, SectionLoading, SnapshotDeleteProvider } from '../../../../components';
|
||||
import {
|
||||
SectionError,
|
||||
SectionLoading,
|
||||
SnapshotDeleteProvider,
|
||||
Error,
|
||||
} from '../../../../components';
|
||||
import { useAppDependencies } from '../../../../index';
|
||||
import {
|
||||
UIM_SNAPSHOT_DETAIL_PANEL_SUMMARY_TAB,
|
||||
|
@ -125,7 +130,7 @@ export const SnapshotDetails: React.FunctionComponent<Props> = ({
|
|||
content = <TabFailures snapshotState={snapshotState} indexFailures={indexFailures} />;
|
||||
}
|
||||
} else if (error) {
|
||||
const notFound = error.status === 404;
|
||||
const notFound = (error as any).status === 404;
|
||||
const errorObject = notFound
|
||||
? {
|
||||
data: {
|
||||
|
@ -148,7 +153,7 @@ export const SnapshotDetails: React.FunctionComponent<Props> = ({
|
|||
defaultMessage="Error loading repository"
|
||||
/>
|
||||
}
|
||||
error={errorObject}
|
||||
error={errorObject as Error}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
|
|
|
@ -10,7 +10,7 @@ import { parse } from 'querystring';
|
|||
import { EuiButton, EuiCallOut, EuiLink, EuiEmptyPrompt, EuiSpacer, EuiIcon } from '@elastic/eui';
|
||||
|
||||
import { APP_SLM_CLUSTER_PRIVILEGES } from '../../../../../common/constants';
|
||||
import { SectionError, SectionLoading } from '../../../components';
|
||||
import { SectionError, SectionLoading, Error } from '../../../components';
|
||||
import { BASE_PATH, UIM_SNAPSHOT_LIST_LOAD } from '../../../constants';
|
||||
import { WithPrivileges } from '../../../lib/authorization';
|
||||
import { useAppDependencies } from '../../../index';
|
||||
|
@ -125,7 +125,7 @@ export const SnapshotList: React.FunctionComponent<RouteComponentProps<MatchPara
|
|||
defaultMessage="Error loading snapshots"
|
||||
/>
|
||||
}
|
||||
error={error}
|
||||
error={error as Error}
|
||||
/>
|
||||
);
|
||||
} else if (Object.keys(errors).length && repositories.length === 0) {
|
||||
|
|
|
@ -21,11 +21,12 @@ import { useAppDependencies } from '../../../../index';
|
|||
import { linkToRepository, linkToRestoreSnapshot } from '../../../../services/navigation';
|
||||
import { uiMetricService } from '../../../../services/ui_metric';
|
||||
import { DataPlaceholder, FormattedDateTime, SnapshotDeleteProvider } from '../../../../components';
|
||||
import { SendRequestResponse } from '../../../../../shared_imports';
|
||||
|
||||
interface Props {
|
||||
snapshots: SnapshotDetails[];
|
||||
repositories: string[];
|
||||
reload: () => Promise<void>;
|
||||
reload: () => Promise<SendRequestResponse>;
|
||||
openSnapshotDetailsUrl: (repositoryName: string, snapshotId: string) => string;
|
||||
repositoryFilter?: string;
|
||||
policyFilter?: string;
|
||||
|
|
|
@ -10,7 +10,7 @@ import { EuiPageBody, EuiPageContent, EuiSpacer, EuiTitle } from '@elastic/eui';
|
|||
import { SlmPolicyPayload } from '../../../../common/types';
|
||||
import { TIME_UNITS } from '../../../../common/constants';
|
||||
|
||||
import { PolicyForm, SectionError, SectionLoading } from '../../components';
|
||||
import { PolicyForm, SectionError, SectionLoading, Error } from '../../components';
|
||||
import { useAppDependencies } from '../../index';
|
||||
import { BASE_PATH, DEFAULT_POLICY_SCHEDULE } from '../../constants';
|
||||
import { breadcrumbService, docTitleService } from '../../services/navigation';
|
||||
|
@ -119,7 +119,7 @@ export const PolicyAdd: React.FunctionComponent<RouteComponentProps> = ({
|
|||
defaultMessage="Error loading available indices"
|
||||
/>
|
||||
}
|
||||
error={errorLoadingIndices}
|
||||
error={errorLoadingIndices as Error}
|
||||
/>
|
||||
) : (
|
||||
<PolicyForm
|
||||
|
|
|
@ -10,7 +10,7 @@ import { EuiPageBody, EuiPageContent, EuiSpacer, EuiTitle } from '@elastic/eui';
|
|||
import { SlmPolicyPayload } from '../../../../common/types';
|
||||
import { TIME_UNITS } from '../../../../common/constants';
|
||||
|
||||
import { SectionError, SectionLoading, PolicyForm } from '../../components';
|
||||
import { SectionError, SectionLoading, PolicyForm, Error } from '../../components';
|
||||
import { BASE_PATH } from '../../constants';
|
||||
import { useAppDependencies } from '../../index';
|
||||
import { breadcrumbService, docTitleService } from '../../services/navigation';
|
||||
|
@ -114,7 +114,7 @@ export const PolicyEdit: React.FunctionComponent<RouteComponentProps<MatchParams
|
|||
|
||||
const renderError = () => {
|
||||
if (errorLoadingPolicy) {
|
||||
const notFound = errorLoadingPolicy.status === 404;
|
||||
const notFound = (errorLoadingPolicy as any).status === 404;
|
||||
const errorObject = notFound
|
||||
? {
|
||||
data: {
|
||||
|
@ -135,7 +135,7 @@ export const PolicyEdit: React.FunctionComponent<RouteComponentProps<MatchParams
|
|||
defaultMessage="Error loading policy details"
|
||||
/>
|
||||
}
|
||||
error={errorObject}
|
||||
error={errorObject as Error}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ export const PolicyEdit: React.FunctionComponent<RouteComponentProps<MatchParams
|
|||
defaultMessage="Error loading available indices"
|
||||
/>
|
||||
}
|
||||
error={errorLoadingIndices}
|
||||
error={errorLoadingIndices as Error}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import { RouteComponentProps } from 'react-router-dom';
|
|||
import { EuiCallOut, EuiPageBody, EuiPageContent, EuiSpacer, EuiTitle } from '@elastic/eui';
|
||||
import { Repository, EmptyRepository } from '../../../../common/types';
|
||||
|
||||
import { RepositoryForm, SectionError, SectionLoading } from '../../components';
|
||||
import { RepositoryForm, SectionError, SectionLoading, Error } from '../../components';
|
||||
import { BASE_PATH, Section } from '../../constants';
|
||||
import { useAppDependencies } from '../../index';
|
||||
import { breadcrumbService, docTitleService } from '../../services/navigation';
|
||||
|
@ -87,7 +87,7 @@ export const RepositoryEdit: React.FunctionComponent<RouteComponentProps<MatchPa
|
|||
};
|
||||
|
||||
const renderError = () => {
|
||||
const notFound = repositoryError.status === 404;
|
||||
const notFound = (repositoryError as any).status === 404;
|
||||
const errorObject = notFound
|
||||
? {
|
||||
data: {
|
||||
|
@ -111,7 +111,7 @@ export const RepositoryEdit: React.FunctionComponent<RouteComponentProps<MatchPa
|
|||
defaultMessage="Error loading repository details"
|
||||
/>
|
||||
}
|
||||
error={errorObject}
|
||||
error={errorObject as Error}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -9,7 +9,7 @@ import { EuiPageBody, EuiPageContent, EuiSpacer, EuiTitle } from '@elastic/eui';
|
|||
|
||||
import { SnapshotDetails, RestoreSettings } from '../../../../common/types';
|
||||
import { BASE_PATH } from '../../constants';
|
||||
import { SectionError, SectionLoading, RestoreSnapshotForm } from '../../components';
|
||||
import { SectionError, SectionLoading, RestoreSnapshotForm, Error } from '../../components';
|
||||
import { useAppDependencies } from '../../index';
|
||||
import { breadcrumbService, docTitleService } from '../../services/navigation';
|
||||
import { useLoadSnapshot, executeRestore } from '../../services/http';
|
||||
|
@ -86,7 +86,7 @@ export const RestoreSnapshot: React.FunctionComponent<RouteComponentProps<MatchP
|
|||
};
|
||||
|
||||
const renderError = () => {
|
||||
const notFound = snapshotError.status === 404;
|
||||
const notFound = (snapshotError as any).status === 404;
|
||||
const errorObject = notFound
|
||||
? {
|
||||
data: {
|
||||
|
@ -111,7 +111,7 @@ export const RestoreSnapshot: React.FunctionComponent<RouteComponentProps<MatchP
|
|||
defaultMessage="Error loading snapshot details"
|
||||
/>
|
||||
}
|
||||
error={errorObject}
|
||||
error={errorObject as Error}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -13,7 +13,7 @@ import {
|
|||
} from '../../../shared_imports';
|
||||
import { httpService } from './index';
|
||||
|
||||
export const sendRequest = (config: SendRequestConfig): Promise<Partial<SendRequestResponse>> => {
|
||||
export const sendRequest = (config: SendRequestConfig): Promise<SendRequestResponse> => {
|
||||
return _sendRequest(httpService.httpClient, config);
|
||||
};
|
||||
|
||||
|
|
|
@ -10,4 +10,4 @@ export { DeleteWatchesModal } from './delete_watches_modal';
|
|||
export { ErrableFormRow } from './form_errors';
|
||||
export { WatchStatus } from './watch_status';
|
||||
export { SectionLoading } from './section_loading';
|
||||
export { SectionError } from './section_error';
|
||||
export { SectionError, Error } from './section_error';
|
||||
|
|
|
@ -7,15 +7,17 @@
|
|||
import { EuiCallOut, EuiSpacer } from '@elastic/eui';
|
||||
import React, { Fragment } from 'react';
|
||||
|
||||
export interface Error {
|
||||
data: {
|
||||
error: string;
|
||||
cause?: string[];
|
||||
message?: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface Props {
|
||||
title: React.ReactNode;
|
||||
error: {
|
||||
data: {
|
||||
error: string;
|
||||
cause?: string[];
|
||||
message?: string;
|
||||
};
|
||||
};
|
||||
error: Error;
|
||||
}
|
||||
|
||||
export const SectionError: React.FunctionComponent<Props> = ({ title, error, ...rest }) => {
|
||||
|
|
|
@ -13,7 +13,7 @@ import {
|
|||
} from '../shared_imports';
|
||||
import { getHttpClient } from './api';
|
||||
|
||||
export const sendRequest = (config: SendRequestConfig): Promise<Partial<SendRequestResponse>> => {
|
||||
export const sendRequest = (config: SendRequestConfig): Promise<SendRequestResponse> => {
|
||||
return _sendRequest(getHttpClient(), config);
|
||||
};
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import { getWatchVisualizationData } from '../../../../lib/api';
|
|||
import { WatchContext } from '../../watch_context';
|
||||
import { aggTypes } from '../../../../models/watch/agg_types';
|
||||
import { comparators } from '../../../../models/watch/comparators';
|
||||
import { SectionError } from '../../../../components';
|
||||
import { SectionError, Error } from '../../../../components';
|
||||
|
||||
const customTheme = () => {
|
||||
return {
|
||||
|
@ -181,7 +181,7 @@ export const WatchVisualization = () => {
|
|||
defaultMessage="Cannot load watch visualization"
|
||||
/>
|
||||
}
|
||||
error={error}
|
||||
error={error as Error}
|
||||
/>
|
||||
<EuiSpacer size="l" />
|
||||
</Fragment>
|
||||
|
|
|
@ -39,6 +39,7 @@ import {
|
|||
WatchStatus,
|
||||
SectionError,
|
||||
SectionLoading,
|
||||
Error,
|
||||
} from '../../../components';
|
||||
import { loadWatches } from '../../../lib/api';
|
||||
import { watcherGettingStartedUrl } from '../../../lib/documentation_links';
|
||||
|
@ -223,7 +224,7 @@ export const WatchList = () => {
|
|||
defaultMessage="Error loading watches"
|
||||
/>
|
||||
}
|
||||
error={error}
|
||||
error={error as Error}
|
||||
/>
|
||||
);
|
||||
} else if (availableWatches) {
|
||||
|
|
|
@ -24,7 +24,7 @@ import {
|
|||
} from '@elastic/eui';
|
||||
|
||||
import { PAGINATION } from '../../../../common/constants';
|
||||
import { WatchStatus, SectionError } from '../../../components';
|
||||
import { WatchStatus, SectionError, Error } from '../../../components';
|
||||
import { loadWatchHistory, loadWatchHistoryDetail } from '../../../lib/api';
|
||||
import { WatchDetailsContext } from '../watch_details_context';
|
||||
|
||||
|
@ -107,7 +107,7 @@ export const WatchHistory = () => {
|
|||
defaultMessage="Error loading execution history"
|
||||
/>
|
||||
}
|
||||
error={historyError}
|
||||
error={historyError as Error}
|
||||
/>
|
||||
</Fragment>
|
||||
);
|
||||
|
@ -186,7 +186,7 @@ export const WatchHistory = () => {
|
|||
defaultMessage="Error loading execution details"
|
||||
/>
|
||||
}
|
||||
error={watchHistoryDetailsError}
|
||||
error={watchHistoryDetailsError as Error}
|
||||
data-test-subj="errorMessage"
|
||||
/>
|
||||
</EuiFlyoutBody>
|
||||
|
|
|
@ -14,6 +14,10 @@ import {
|
|||
} from '../../../common/constants';
|
||||
|
||||
export function checkLicense(pluginName, minimumLicenseRequired, xpackLicenseInfo) {
|
||||
if (!minimumLicenseRequired) {
|
||||
throw new Error(`Error checking license for plugin "${pluginName}". The minimum license required has not been provided.`);
|
||||
}
|
||||
|
||||
if(!RANKED_LICENSE_TYPES.includes(minimumLicenseRequired)) {
|
||||
throw new Error(`Invalid license type supplied to checkLicense: ${minimumLicenseRequired}`);
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ export const createRouter = (server, pluginId, apiBasePath = '', config) => {
|
|||
return (['get', 'post', 'put', 'delete', 'patch'].reduce((router, methodName) => {
|
||||
router[methodName] = (subPath, handler) => {
|
||||
const method = methodName.toUpperCase();
|
||||
const path = `${apiBasePath}${subPath}`;
|
||||
const path = apiBasePath + subPath;
|
||||
server.route({
|
||||
path,
|
||||
method,
|
||||
|
|
Loading…
Reference in a new issue