mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
* [File data visualizer] Disabling create data view based on capabilities * removing data view management card based on permissions * fixing reset button and index data viz link Co-authored-by: James Gowdy <jgowdy@elastic.co>
This commit is contained in:
parent
7601fdc57e
commit
5648faacb3
9 changed files with 108 additions and 50 deletions
|
@ -58,7 +58,13 @@ export const ResultsLinks: FC<Props> = ({
|
|||
additionalLinks,
|
||||
}) => {
|
||||
const {
|
||||
services: { fileUpload },
|
||||
services: {
|
||||
fileUpload,
|
||||
application: { getUrlForApp, capabilities },
|
||||
share: {
|
||||
urlGenerators: { getUrlGenerator },
|
||||
},
|
||||
},
|
||||
} = useDataVisualizerKibana();
|
||||
|
||||
const [duration, setDuration] = useState({
|
||||
|
@ -72,15 +78,6 @@ export const ResultsLinks: FC<Props> = ({
|
|||
const [indexPatternManagementLink, setIndexPatternManagementLink] = useState('');
|
||||
const [generatedLinks, setGeneratedLinks] = useState<Record<string, string>>({});
|
||||
|
||||
const {
|
||||
services: {
|
||||
application: { getUrlForApp, capabilities },
|
||||
share: {
|
||||
urlGenerators: { getUrlGenerator },
|
||||
},
|
||||
},
|
||||
} = useDataVisualizerKibana();
|
||||
|
||||
useEffect(() => {
|
||||
let unmounted = false;
|
||||
|
||||
|
@ -137,11 +134,14 @@ export const ResultsLinks: FC<Props> = ({
|
|||
setIndexManagementLink(
|
||||
getUrlForApp('management', { path: '/data/index_management/indices' })
|
||||
);
|
||||
setIndexPatternManagementLink(
|
||||
getUrlForApp('management', {
|
||||
path: `/kibana/indexPatterns${createIndexPattern ? `/patterns/${indexPatternId}` : ''}`,
|
||||
})
|
||||
);
|
||||
|
||||
if (capabilities.indexPatterns.save === true) {
|
||||
setIndexPatternManagementLink(
|
||||
getUrlForApp('management', {
|
||||
path: `/kibana/indexPatterns${createIndexPattern ? `/patterns/${indexPatternId}` : ''}`,
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return () => {
|
||||
|
|
|
@ -295,12 +295,7 @@ export class FileDataVisualizerView extends Component {
|
|||
<div>
|
||||
{mode === MODE.READ && (
|
||||
<>
|
||||
{!loading && !loaded && (
|
||||
<AboutPanel
|
||||
onFilePickerChange={this.onFilePickerChange}
|
||||
disabled={!fileCouldNotBeReadPermissionError}
|
||||
/>
|
||||
)}
|
||||
{!loading && !loaded && <AboutPanel onFilePickerChange={this.onFilePickerChange} />}
|
||||
|
||||
{loading && <LoadingPanel />}
|
||||
|
||||
|
@ -373,6 +368,7 @@ export class FileDataVisualizerView extends Component {
|
|||
savedObjectsClient={this.savedObjectsClient}
|
||||
fileUpload={this.props.fileUpload}
|
||||
resultsLinks={this.props.resultsLinks}
|
||||
capabilities={this.props.capabilities}
|
||||
/>
|
||||
|
||||
{bottomBarVisible && (
|
||||
|
|
|
@ -21,6 +21,7 @@ import {
|
|||
import { CombinedField, CombinedFieldsForm } from '../../../common/components/combined_fields';
|
||||
import { JsonEditor, EDITOR_MODE } from '../json_editor';
|
||||
import { FindFileStructureResponse } from '../../../../../../file_upload/common';
|
||||
import { CreateDataViewToolTip } from './create_data_view_tooltip';
|
||||
const EDITOR_HEIGHT = '300px';
|
||||
|
||||
interface Props {
|
||||
|
@ -42,6 +43,7 @@ interface Props {
|
|||
combinedFields: CombinedField[];
|
||||
onCombinedFieldsChange(combinedFields: CombinedField[]): void;
|
||||
results: FindFileStructureResponse;
|
||||
canCreateDataView: boolean;
|
||||
}
|
||||
|
||||
export const AdvancedSettings: FC<Props> = ({
|
||||
|
@ -63,6 +65,7 @@ export const AdvancedSettings: FC<Props> = ({
|
|||
combinedFields,
|
||||
onCombinedFieldsChange,
|
||||
results,
|
||||
canCreateDataView,
|
||||
}) => {
|
||||
return (
|
||||
<React.Fragment>
|
||||
|
@ -98,18 +101,20 @@ export const AdvancedSettings: FC<Props> = ({
|
|||
|
||||
<EuiSpacer size="m" />
|
||||
|
||||
<EuiCheckbox
|
||||
id="createIndexPattern"
|
||||
label={
|
||||
<FormattedMessage
|
||||
id="xpack.dataVisualizer.file.advancedImportSettings.createDataViewLabel"
|
||||
defaultMessage="Create data view"
|
||||
/>
|
||||
}
|
||||
checked={createIndexPattern === true}
|
||||
disabled={initialized === true}
|
||||
onChange={onCreateIndexPatternChange}
|
||||
/>
|
||||
<CreateDataViewToolTip showTooltip={canCreateDataView === false}>
|
||||
<EuiCheckbox
|
||||
id="createIndexPattern"
|
||||
label={
|
||||
<FormattedMessage
|
||||
id="xpack.dataVisualizer.file.advancedImportSettings.createDataViewLabel"
|
||||
defaultMessage="Create data view"
|
||||
/>
|
||||
}
|
||||
checked={createIndexPattern === true}
|
||||
disabled={initialized === true || canCreateDataView === false}
|
||||
onChange={onCreateIndexPatternChange}
|
||||
/>
|
||||
</CreateDataViewToolTip>
|
||||
|
||||
<EuiSpacer size="s" />
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* 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, { FC } from 'react';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { EuiToolTip } from '@elastic/eui';
|
||||
|
||||
interface Props {
|
||||
children?: React.ReactElement;
|
||||
showTooltip: boolean;
|
||||
}
|
||||
|
||||
export const CreateDataViewToolTip: FC<Props> = ({ children, showTooltip }) => {
|
||||
return (
|
||||
<EuiToolTip
|
||||
position="top"
|
||||
content={
|
||||
showTooltip ? (
|
||||
<FormattedMessage
|
||||
id="xpack.dataVisualizer.file.cannotCreateDataView.tooltip"
|
||||
defaultMessage="You need permission to create data views."
|
||||
/>
|
||||
) : null
|
||||
}
|
||||
>
|
||||
{children}
|
||||
</EuiToolTip>
|
||||
);
|
||||
};
|
|
@ -14,6 +14,7 @@ import { SimpleSettings } from './simple';
|
|||
import { AdvancedSettings } from './advanced';
|
||||
import { CombinedField } from '../../../common/components/combined_fields';
|
||||
import { FindFileStructureResponse } from '../../../../../../file_upload/common';
|
||||
import { useDataVisualizerKibana } from '../../../kibana_context';
|
||||
|
||||
interface Props {
|
||||
index: string;
|
||||
|
@ -56,6 +57,15 @@ export const ImportSettings: FC<Props> = ({
|
|||
onCombinedFieldsChange,
|
||||
results,
|
||||
}) => {
|
||||
const {
|
||||
services: {
|
||||
application: { capabilities },
|
||||
},
|
||||
} = useDataVisualizerKibana();
|
||||
|
||||
const canCreateDataView =
|
||||
capabilities.savedObjectsManagement.edit === true || capabilities.indexPatterns.save === true;
|
||||
|
||||
const tabs = [
|
||||
{
|
||||
id: 'simple-settings',
|
||||
|
@ -74,6 +84,7 @@ export const ImportSettings: FC<Props> = ({
|
|||
onCreateIndexPatternChange={onCreateIndexPatternChange}
|
||||
indexNameError={indexNameError}
|
||||
combinedFields={combinedFields}
|
||||
canCreateDataView={canCreateDataView}
|
||||
/>
|
||||
</React.Fragment>
|
||||
),
|
||||
|
@ -106,6 +117,7 @@ export const ImportSettings: FC<Props> = ({
|
|||
combinedFields={combinedFields}
|
||||
onCombinedFieldsChange={onCombinedFieldsChange}
|
||||
results={results}
|
||||
canCreateDataView={canCreateDataView}
|
||||
/>
|
||||
</React.Fragment>
|
||||
),
|
||||
|
|
|
@ -14,6 +14,7 @@ import {
|
|||
CombinedField,
|
||||
CombinedFieldsReadOnlyForm,
|
||||
} from '../../../common/components/combined_fields';
|
||||
import { CreateDataViewToolTip } from './create_data_view_tooltip';
|
||||
|
||||
interface Props {
|
||||
index: string;
|
||||
|
@ -23,6 +24,7 @@ interface Props {
|
|||
onCreateIndexPatternChange(): void;
|
||||
indexNameError: string;
|
||||
combinedFields: CombinedField[];
|
||||
canCreateDataView: boolean;
|
||||
}
|
||||
|
||||
export const SimpleSettings: FC<Props> = ({
|
||||
|
@ -33,6 +35,7 @@ export const SimpleSettings: FC<Props> = ({
|
|||
onCreateIndexPatternChange,
|
||||
indexNameError,
|
||||
combinedFields,
|
||||
canCreateDataView,
|
||||
}) => {
|
||||
return (
|
||||
<React.Fragment>
|
||||
|
@ -69,19 +72,21 @@ export const SimpleSettings: FC<Props> = ({
|
|||
|
||||
<EuiSpacer size="m" />
|
||||
|
||||
<EuiCheckbox
|
||||
id="createIndexPattern"
|
||||
label={
|
||||
<FormattedMessage
|
||||
id="xpack.dataVisualizer.file.simpleImportSettings.createDataViewLabel"
|
||||
defaultMessage="Create data view"
|
||||
/>
|
||||
}
|
||||
checked={createIndexPattern === true}
|
||||
disabled={initialized === true}
|
||||
onChange={onCreateIndexPatternChange}
|
||||
data-test-subj="dataVisualizerFileCreateIndexPatternCheckbox"
|
||||
/>
|
||||
<CreateDataViewToolTip showTooltip={canCreateDataView === false}>
|
||||
<EuiCheckbox
|
||||
id="createIndexPattern"
|
||||
label={
|
||||
<FormattedMessage
|
||||
id="xpack.dataVisualizer.file.simpleImportSettings.createDataViewLabel"
|
||||
defaultMessage="Create data view"
|
||||
/>
|
||||
}
|
||||
checked={createIndexPattern === true}
|
||||
disabled={initialized === true || canCreateDataView === false}
|
||||
onChange={onCreateIndexPatternChange}
|
||||
data-test-subj="dataVisualizerFileCreateIndexPatternCheckbox"
|
||||
/>
|
||||
</CreateDataViewToolTip>
|
||||
|
||||
<EuiSpacer size="m" />
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ export class ImportView extends Component {
|
|||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = getDefaultState(DEFAULT_STATE, this.props.results);
|
||||
this.state = getDefaultState(DEFAULT_STATE, this.props.results, this.props.capabilities);
|
||||
this.savedObjectsClient = props.savedObjectsClient;
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ export class ImportView extends Component {
|
|||
}
|
||||
|
||||
clickReset = () => {
|
||||
const state = getDefaultState(this.state, this.props.results);
|
||||
const state = getDefaultState(this.state, this.props.results, this.props.capabilities);
|
||||
this.setState(state, () => {
|
||||
this.loadIndexPatternNames();
|
||||
});
|
||||
|
@ -640,7 +640,7 @@ async function createKibanaIndexPattern(indexPatternName, indexPatterns, timeFie
|
|||
}
|
||||
}
|
||||
|
||||
function getDefaultState(state, results) {
|
||||
function getDefaultState(state, results, capabilities) {
|
||||
const indexSettingsString =
|
||||
state.indexSettingsString === ''
|
||||
? JSON.stringify(DEFAULT_INDEX_SETTINGS, null, 2)
|
||||
|
@ -666,6 +666,11 @@ function getDefaultState(state, results) {
|
|||
|
||||
const timeFieldName = results.timestamp_field;
|
||||
|
||||
const createIndexPattern =
|
||||
capabilities.savedObjectsManagement.edit === false && capabilities.indexPatterns.save === false
|
||||
? false
|
||||
: state.createIndexPattern;
|
||||
|
||||
return {
|
||||
...DEFAULT_STATE,
|
||||
indexSettingsString,
|
||||
|
@ -673,6 +678,7 @@ function getDefaultState(state, results) {
|
|||
pipelineString,
|
||||
timeFieldName,
|
||||
combinedFields,
|
||||
createIndexPattern,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ export const FileDataVisualizer: FC<Props> = ({ additionalLinks }) => {
|
|||
http={coreStart.http}
|
||||
fileUpload={fileUpload}
|
||||
resultsLinks={additionalLinks}
|
||||
capabilities={coreStart.application.capabilities}
|
||||
/>
|
||||
</KibanaContextProvider>
|
||||
);
|
||||
|
|
|
@ -89,7 +89,7 @@ export const FileDataVisualizerPage: FC = () => {
|
|||
},
|
||||
});
|
||||
},
|
||||
canDisplay: async () => true,
|
||||
canDisplay: async ({ indexPatternId }) => indexPatternId !== '',
|
||||
},
|
||||
],
|
||||
[]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue