-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Navigation embeddable] Add content management #160896
Merged
nickpeihl
merged 25 commits into
elastic:navigation-embeddable
from
nickpeihl:navEmbeddable-cm
Aug 10, 2023
Merged
Changes from 18 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
0c7c839
Initialize content management
nickpeihl b426814
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine 38340ab
Merge branch 'navigation-embeddable' of https://github.com/elastic/ki…
nickpeihl 78b0bf2
Rename linkListJSON to linksJSON
nickpeihl 9e8e10f
Merge branch 'navEmbeddable-cm' of https://github.com/nickpeihl/kiban…
nickpeihl 81b3bb8
Start wiring content management to UI
nickpeihl 8b5ec43
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine 719c046
Wire saved objects and attribute service
nickpeihl 82da138
Merge branch 'navEmbeddable-cm' of https://github.com/nickpeihl/kiban…
nickpeihl 88df8f2
Merge remote-tracking branch 'upstream/navigation-embeddable' into na…
nickpeihl cef9efb
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine 9879a34
[CI] Auto-commit changed files from 'node scripts/check_mappings_upda…
kibanamachine 6046fde
Wires content management to UI. Mostly complete.
nickpeihl c024f9c
Change links mapping from object to array of links
nickpeihl e4d8327
Link panels must have a minimum of one link
nickpeihl f0bd9a9
Do not return anything from canceled flyout
nickpeihl 78dd9ce
Create by-value or by-ref embeddable
nickpeihl c4d0dbc
Fix test failures
nickpeihl e352936
Replace embeddable + panel changes
Heenawter 2b463fc
Clean up
Heenawter ff28220
Unify NAVIGATION_EMBEDDABLE_TYPE and CONTENT_ID constants
nickpeihl 8fb0ed5
Merge pull request #2 from Heenawter/suggested-replace-changes_2023-0…
nickpeihl 2729cfc
Review feedback
nickpeihl 6b254f7
Merge remote-tracking branch 'origin/navEmbeddable-cm' into navEmbedd…
nickpeihl ce38804
Catch promise rejection when canceling edit panel
nickpeihl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,21 @@ | ||
/* | ||
* 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 LATEST_VERSION = 1; | ||
|
||
export const CONTENT_ID = 'navigation_embeddable'; | ||
|
||
export const NAVIGATION_EMBEDDABLE_TYPE = 'navigation'; | ||
|
||
export const APP_ICON = 'link'; | ||
|
||
export const APP_NAME = i18n.translate('navigationEmbeddable.visTypeAlias.title', { | ||
defaultMessage: 'Links', | ||
}); |
21 changes: 21 additions & 0 deletions
21
src/plugins/navigation_embeddable/common/content_management/cm_services.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,21 @@ | ||
/* | ||
* 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 type { | ||
ContentManagementServicesDefinition as ServicesDefinition, | ||
Version, | ||
} from '@kbn/object-versioning'; | ||
|
||
// We export the versioned service definition from this file and not the barrel to avoid adding | ||
// the schemas in the "public" js bundle | ||
|
||
import { serviceDefinition as v1 } from './v1/cm_services'; | ||
|
||
export const cmServicesDefinition: { [version: Version]: ServicesDefinition } = { | ||
1: v1, | ||
}; |
23 changes: 23 additions & 0 deletions
23
src/plugins/navigation_embeddable/common/content_management/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,23 @@ | ||
/* | ||
* 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 { LATEST_VERSION, CONTENT_ID } from '../constants'; | ||
|
||
export type { NavigationEmbeddableContentType } from '../types'; | ||
|
||
export type { | ||
NavigationEmbeddableCrudTypes, | ||
NavigationEmbeddableAttributes, | ||
NavigationEmbeddableItem, | ||
NavigationLinkType, | ||
NavigationEmbeddableLink, | ||
} from './latest'; | ||
|
||
export { DASHBOARD_LINK_TYPE, EXTERNAL_LINK_TYPE } from './latest'; | ||
|
||
export * as NavigationEmbeddableV1 from './v1'; |
9 changes: 9 additions & 0 deletions
9
src/plugins/navigation_embeddable/common/content_management/latest.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 * from './v1'; |
108 changes: 108 additions & 0 deletions
108
src/plugins/navigation_embeddable/common/content_management/v1/cm_services.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,108 @@ | ||
/* | ||
* 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 { schema } from '@kbn/config-schema'; | ||
import type { ContentManagementServicesDefinition as ServicesDefinition } from '@kbn/object-versioning'; | ||
import { | ||
savedObjectSchema, | ||
objectTypeToGetResultSchema, | ||
createOptionsSchemas, | ||
updateOptionsSchema, | ||
createResultSchema, | ||
} from '@kbn/content-management-utils'; | ||
import { DASHBOARD_LINK_TYPE, EXTERNAL_LINK_TYPE } from '.'; | ||
|
||
const navigationEmbeddableLinkSchema = schema.object({ | ||
id: schema.string(), | ||
type: schema.oneOf([schema.literal(DASHBOARD_LINK_TYPE), schema.literal(EXTERNAL_LINK_TYPE)]), | ||
destination: schema.string(), | ||
label: schema.maybe(schema.string()), | ||
order: schema.number(), | ||
}); | ||
|
||
const navigationEmbeddableAttributesSchema = schema.object( | ||
{ | ||
title: schema.string(), | ||
description: schema.maybe(schema.string()), | ||
links: schema.maybe(schema.arrayOf(navigationEmbeddableLinkSchema)), | ||
}, | ||
{ unknowns: 'forbid' } | ||
); | ||
|
||
const navigationEmbeddableSavedObjectSchema = savedObjectSchema( | ||
navigationEmbeddableAttributesSchema | ||
); | ||
|
||
const searchOptionsSchema = schema.maybe( | ||
schema.object( | ||
{ | ||
onlyTitle: schema.maybe(schema.boolean()), | ||
}, | ||
{ unknowns: 'forbid' } | ||
) | ||
); | ||
|
||
const navigationEmbeddableCreateOptionsSchema = schema.object({ | ||
references: schema.maybe(createOptionsSchemas.references), | ||
overwrite: createOptionsSchemas.overwrite, | ||
}); | ||
|
||
const navigationEmbeddableUpdateOptionsSchema = schema.object({ | ||
references: updateOptionsSchema.references, | ||
}); | ||
|
||
// Content management service definition. | ||
// We need it for BWC support between different versions of the content | ||
export const serviceDefinition: ServicesDefinition = { | ||
get: { | ||
out: { | ||
result: { | ||
schema: objectTypeToGetResultSchema(navigationEmbeddableSavedObjectSchema), | ||
}, | ||
}, | ||
}, | ||
create: { | ||
in: { | ||
options: { | ||
schema: navigationEmbeddableCreateOptionsSchema, | ||
}, | ||
data: { | ||
schema: navigationEmbeddableAttributesSchema, | ||
}, | ||
}, | ||
out: { | ||
result: { | ||
schema: createResultSchema(navigationEmbeddableSavedObjectSchema), | ||
}, | ||
}, | ||
}, | ||
update: { | ||
in: { | ||
options: { | ||
schema: navigationEmbeddableUpdateOptionsSchema, // same schema as "create" | ||
}, | ||
data: { | ||
schema: navigationEmbeddableAttributesSchema, | ||
}, | ||
}, | ||
}, | ||
search: { | ||
in: { | ||
options: { | ||
schema: searchOptionsSchema, | ||
}, | ||
}, | ||
}, | ||
mSearch: { | ||
out: { | ||
result: { | ||
schema: navigationEmbeddableSavedObjectSchema, | ||
}, | ||
}, | ||
}, | ||
}; |
17 changes: 17 additions & 0 deletions
17
src/plugins/navigation_embeddable/common/content_management/v1/constants.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,17 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* Dashboard to dashboard links | ||
*/ | ||
export const DASHBOARD_LINK_TYPE = 'dashboardLink'; | ||
|
||
/** | ||
* External URL links | ||
*/ | ||
export const EXTERNAL_LINK_TYPE = 'externalLink'; |
17 changes: 17 additions & 0 deletions
17
src/plugins/navigation_embeddable/common/content_management/v1/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,17 @@ | ||
/* | ||
* 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 { NavigationEmbeddableCrudTypes } from './types'; | ||
export type { | ||
NavigationEmbeddableCrudTypes, | ||
NavigationEmbeddableAttributes, | ||
NavigationEmbeddableLink, | ||
NavigationLinkType, | ||
} from './types'; | ||
export type NavigationEmbeddableItem = NavigationEmbeddableCrudTypes['Item']; | ||
export { DASHBOARD_LINK_TYPE, EXTERNAL_LINK_TYPE } from './constants'; |
46 changes: 46 additions & 0 deletions
46
src/plugins/navigation_embeddable/common/content_management/v1/types.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,46 @@ | ||
/* | ||
* 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 type { | ||
ContentManagementCrudTypes, | ||
SavedObjectCreateOptions, | ||
SavedObjectUpdateOptions, | ||
} from '@kbn/content-management-utils'; | ||
import { NavigationEmbeddableContentType } from '../../types'; | ||
import { DASHBOARD_LINK_TYPE, EXTERNAL_LINK_TYPE } from './constants'; | ||
|
||
export type NavigationEmbeddableCrudTypes = ContentManagementCrudTypes< | ||
NavigationEmbeddableContentType, | ||
NavigationEmbeddableAttributes, | ||
Pick<SavedObjectCreateOptions, 'references'>, | ||
Pick<SavedObjectUpdateOptions, 'references'>, | ||
{ | ||
/** Flag to indicate to only search the text on the "title" field */ | ||
onlyTitle?: boolean; | ||
} | ||
>; | ||
|
||
/** | ||
* Navigation embeddable explicit input | ||
*/ | ||
export type NavigationLinkType = typeof DASHBOARD_LINK_TYPE | typeof EXTERNAL_LINK_TYPE; | ||
|
||
export interface NavigationEmbeddableLink { | ||
id: string; | ||
type: NavigationLinkType; | ||
destination: string; | ||
label?: string; | ||
order: number; | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
export type NavigationEmbeddableAttributes = { | ||
title: string; | ||
description?: string; | ||
links?: NavigationEmbeddableLink[]; | ||
}; |
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 { CONTENT_ID, LATEST_VERSION } from './constants'; |
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,19 @@ | ||
/* | ||
* 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 type { SavedObjectsResolveResponse } from '@kbn/core-saved-objects-api-server'; | ||
|
||
export type NavigationEmbeddableContentType = 'navigation_embeddable'; | ||
|
||
// TODO does this type need to be versioned? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👀 |
||
export interface SharingSavedObjectProps { | ||
outcome: SavedObjectsResolveResponse['outcome']; | ||
aliasTargetId?: SavedObjectsResolveResponse['alias_target_id']; | ||
aliasPurpose?: SavedObjectsResolveResponse['alias_purpose']; | ||
sourceId?: string; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can make this better by making changes to the
Container.replaceEmbeddable
method to be functionally similar to the replacePanel function indashboard/public/dashboard_container/embeddable/api/panel_management.ts
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR to address this: nickpeihl#2 @nickpeihl @ThomThomson
Figured it was easiest to make a PR against this PR, so that we can test the saved object stuff in its entirety - let me know if something else works better, though 👍