-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[data view mgmt] add saved object relationships to data view manageme…
…nt (#132385) * add saved object relationships to data view management
- Loading branch information
Showing
20 changed files
with
402 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...ins/data_view_management/public/components/edit_index_pattern/relationships_table/i18n.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
|
||
export const typeFieldName = i18n.translate( | ||
'indexPatternManagement.objectsTable.relationships.columnTypeName', | ||
{ | ||
defaultMessage: 'Type', | ||
} | ||
); | ||
|
||
export const typeFieldDescription = i18n.translate( | ||
'indexPatternManagement.objectsTable.relationships.columnTypeDescription', | ||
{ defaultMessage: 'Type of the saved object' } | ||
); | ||
|
||
export const titleFieldName = i18n.translate( | ||
'indexPatternManagement.objectsTable.relationships.columnTitleName', | ||
{ | ||
defaultMessage: 'Title', | ||
} | ||
); | ||
|
||
export const titleFieldDescription = i18n.translate( | ||
'indexPatternManagement.objectsTable.relationships.columnTitleDescription', | ||
{ defaultMessage: 'Title of the saved object' } | ||
); | ||
|
||
export const filterTitle = i18n.translate( | ||
'indexPatternManagement.objectsTable.relationships.search.filters.type.name', | ||
{ defaultMessage: 'Type' } | ||
); |
9 changes: 9 additions & 0 deletions
9
...ns/data_view_management/public/components/edit_index_pattern/relationships_table/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export { RelationshipsTable } from './relationships_table'; |
154 changes: 154 additions & 0 deletions
154
...nagement/public/components/edit_index_pattern/relationships_table/relationships_table.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { | ||
EuiInMemoryTable, | ||
HorizontalAlignment, | ||
EuiText, | ||
EuiLink, | ||
EuiTableDataType, | ||
} from '@elastic/eui'; | ||
import { CoreStart } from '@kbn/core/public'; | ||
import { get } from 'lodash'; | ||
import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app'; | ||
|
||
import { | ||
SavedObjectRelation, | ||
SavedObjectManagementTypeInfo, | ||
SavedObjectsManagementPluginStart, | ||
} from '@kbn/saved-objects-management-plugin/public'; | ||
|
||
import { EuiToolTip, EuiIcon, SearchFilterConfig } from '@elastic/eui'; | ||
import { IPM_APP_ID } from '../../../plugin'; | ||
import { | ||
typeFieldName, | ||
typeFieldDescription, | ||
titleFieldName, | ||
titleFieldDescription, | ||
filterTitle, | ||
} from './i18n'; | ||
|
||
const canGoInApp = ( | ||
savedObject: SavedObjectRelation, | ||
capabilities: CoreStart['application']['capabilities'] | ||
) => { | ||
const { inAppUrl } = savedObject.meta; | ||
if (!inAppUrl) return false; | ||
if (!inAppUrl.uiCapabilitiesPath) return true; | ||
return Boolean(get(capabilities, inAppUrl.uiCapabilitiesPath)); | ||
}; | ||
|
||
export const RelationshipsTable = ({ | ||
basePath, | ||
capabilities, | ||
id, | ||
navigateToUrl, | ||
getDefaultTitle, | ||
getSavedObjectLabel, | ||
relationships, | ||
allowedTypes, | ||
}: { | ||
basePath: CoreStart['http']['basePath']; | ||
capabilities: CoreStart['application']['capabilities']; | ||
navigateToUrl: CoreStart['application']['navigateToUrl']; | ||
id: string; | ||
getDefaultTitle: SavedObjectsManagementPluginStart['getDefaultTitle']; | ||
getSavedObjectLabel: SavedObjectsManagementPluginStart['getSavedObjectLabel']; | ||
relationships: SavedObjectRelation[]; | ||
allowedTypes: SavedObjectManagementTypeInfo[]; | ||
}) => { | ||
const columns = [ | ||
{ | ||
field: 'type', | ||
name: typeFieldName, | ||
width: '50px', | ||
align: 'center' as HorizontalAlignment, | ||
description: typeFieldDescription, | ||
sortable: false, | ||
render: (type: string, object: SavedObjectRelation) => { | ||
const typeLabel = getSavedObjectLabel(type, allowedTypes); | ||
return ( | ||
<EuiToolTip position="top" content={typeLabel}> | ||
<EuiIcon | ||
aria-label={typeLabel} | ||
type={object.meta.icon || 'apps'} | ||
size="s" | ||
data-test-subj="relationshipsObjectType" | ||
/> | ||
</EuiToolTip> | ||
); | ||
}, | ||
}, | ||
{ | ||
field: 'title', | ||
name: titleFieldName, | ||
description: titleFieldDescription, | ||
dataType: 'string' as EuiTableDataType, | ||
sortable: false, | ||
render: (title: string, object: SavedObjectRelation) => { | ||
const path = object.meta.inAppUrl?.path || ''; | ||
const showUrl = canGoInApp(object, capabilities); | ||
const titleDisplayed = title || getDefaultTitle(object); | ||
|
||
return showUrl ? ( | ||
<EuiLink href={basePath.prepend(path)} data-test-subj="relationshipsTitle"> | ||
{titleDisplayed} | ||
</EuiLink> | ||
) : ( | ||
<EuiText size="s" data-test-subj="relationshipsTitle"> | ||
{titleDisplayed} | ||
</EuiText> | ||
); | ||
}, | ||
}, | ||
]; | ||
|
||
const filterTypesMap = new Map( | ||
relationships.map((relationship) => [ | ||
relationship.type, | ||
{ | ||
value: relationship.type, | ||
name: relationship.type, | ||
view: relationship.type, | ||
}, | ||
]) | ||
); | ||
|
||
const search = { | ||
// query, | ||
// onChange: handleOnChange, | ||
box: { | ||
incremental: true, | ||
schema: true, | ||
}, | ||
filters: [ | ||
{ | ||
type: 'field_value_selection', | ||
field: 'type', | ||
name: filterTitle, | ||
multiSelect: 'or', | ||
options: [...filterTypesMap.values()], | ||
}, | ||
] as SearchFilterConfig[], | ||
}; | ||
|
||
return ( | ||
<RedirectAppLinks currentAppId={IPM_APP_ID} navigateToUrl={navigateToUrl}> | ||
<EuiInMemoryTable<SavedObjectRelation> | ||
items={relationships} | ||
columns={columns} | ||
pagination={true} | ||
search={search} | ||
rowProps={() => ({ | ||
'data-test-subj': `relationshipsTableRow`, | ||
})} | ||
/> | ||
</RedirectAppLinks> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.