Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] Fix edit datasource not working following changes in #67234 (#68583) #68721

Merged
merged 1 commit into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { CreateDatasourceFrom } from '../types';
export interface CustomConfigureDatasourceProps {
packageName: string;
from: CreateDatasourceFrom;
datasource: NewDatasource | (NewDatasource & { id: string });
datasource: NewDatasource;
datasourceId?: string;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ import { CreateDatasourceFrom } from './types';
export const StepConfigureDatasource: React.FunctionComponent<{
from?: CreateDatasourceFrom;
packageInfo: PackageInfo;
datasource: NewDatasource | (NewDatasource & { id: string });
datasource: NewDatasource;
datasourceId?: string;
updateDatasource: (fields: Partial<NewDatasource>) => void;
validationResults: DatasourceValidationResults;
submitAttempted: boolean;
}> = ({
from = 'config',
packageInfo,
datasource,
datasourceId,
updateDatasource,
validationResults,
submitAttempted,
Expand Down Expand Up @@ -70,9 +72,10 @@ export const StepConfigureDatasource: React.FunctionComponent<{
) : (
<EuiPanel>
<CustomConfigureDatasource
from={from}
packageName={packageInfo.name}
datasource={datasource}
from={from}
datasourceId={datasourceId}
/>
</EuiPanel>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ export const EditDatasourcePage: React.FunctionComponent = () => {
const [loadingError, setLoadingError] = useState<Error>();
const [agentConfig, setAgentConfig] = useState<AgentConfig>();
const [packageInfo, setPackageInfo] = useState<PackageInfo>();
const [datasource, setDatasource] = useState<NewDatasource & { id: string }>({
id: '',
const [datasource, setDatasource] = useState<NewDatasource>({
name: '',
description: '',
config_id: '',
Expand All @@ -94,6 +93,7 @@ export const EditDatasourcePage: React.FunctionComponent = () => {
}
if (datasourceData?.item) {
const {
id,
revision,
inputs,
created_by,
Expand Down Expand Up @@ -302,6 +302,7 @@ export const EditDatasourcePage: React.FunctionComponent = () => {
from={'edit'}
packageInfo={packageInfo}
datasource={datasource}
datasourceId={datasourceId}
updateDatasource={updateDatasource}
validationResults={validationResults!}
submitAttempted={formState === 'INVALID'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,21 @@ import { LinkToApp } from '../../../../../common/components/endpoint/link_to_app
import {
CustomConfigureDatasourceContent,
CustomConfigureDatasourceProps,
NewDatasource,
} from '../../../../../../../ingest_manager/public';
import { getManagementUrl } from '../../../..';

type DatasourceWithId = NewDatasource & { id: string };

/**
* Exports Endpoint-specific datasource configuration instructions
* for use in the Ingest app create / edit datasource config
*/
export const ConfigureEndpointDatasource = memo<CustomConfigureDatasourceContent>(
({
from,
datasource,
}: {
from: string;
datasource: CustomConfigureDatasourceProps['datasource'];
}) => {
({ from, datasourceId }: CustomConfigureDatasourceProps) => {
const { services } = useKibana();
let policyUrl = '';
if (from === 'edit') {
if (from === 'edit' && datasourceId) {
policyUrl = getManagementUrl({
name: 'policyDetails',
policyId: (datasource as DatasourceWithId).id,
policyId: datasourceId,
});
}

Expand Down