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

Share Modal #179037

Merged
merged 41 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
75209df
initial commit
rshen91 Feb 22, 2024
bd1a7a7
wip
rshen91 Feb 22, 2024
9cf504f
working link preview
rshen91 Feb 22, 2024
ce80ba8
link
rshen91 Feb 22, 2024
9902e8a
tsconfig
rshen91 Feb 22, 2024
f26df8a
tsconfig
rshen91 Feb 22, 2024
5e96f80
copy link on click
rshen91 Feb 22, 2024
cfc5b51
wip
rshen91 Feb 29, 2024
4a5f9b6
working on embed modal hooks
rshen91 Mar 4, 2024
50752ff
fix embed behavior in url
rshen91 Mar 4, 2024
0d20b3b
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Mar 4, 2024
617c54c
design chx
rshen91 Mar 4, 2024
de0ffd1
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Mar 4, 2024
b309fe3
fix order of tabs to match figma
rshen91 Mar 5, 2024
9198c22
short urls when click copy link
rshen91 Mar 6, 2024
1711f0f
add package to i18n
rshen91 Mar 6, 2024
1f7c5e7
add padding right to code block
rshen91 Mar 6, 2024
c41e945
fix
rshen91 Mar 6, 2024
5b84a4f
wip adapt eyos work to pr
rshen91 Mar 8, 2024
f6c5a84
wip refactor to use tabbedModal
rshen91 Mar 11, 2024
4be2b6d
wip
rshen91 Mar 11, 2024
6abb25c
wip for collab
rshen91 Mar 12, 2024
114520c
rework implementation for v2 share
eokoneyo Mar 19, 2024
07fdb87
fix issue with switching state within tabbed modal
eokoneyo Mar 20, 2024
95ae238
integrate link and embed modal into modal to receive correct value on…
eokoneyo Mar 20, 2024
6481f73
visual styling for share modal
eokoneyo Mar 20, 2024
caab0d3
incorporate work for export tab
eokoneyo Mar 20, 2024
1587c6b
remove kbn-share-modal package
eokoneyo Mar 26, 2024
9f42f17
remove unused share modal impl and related
eokoneyo Mar 26, 2024
09c9517
rework storybook setup to match new component expectation
eokoneyo Mar 26, 2024
00fef70
rework tab modal component
eokoneyo Mar 27, 2024
c0cf1e6
lens unsaved state changes
rshen91 Apr 2, 2024
7b788ea
Merge remote-tracking branch 'upstream/main' into rshen-embed-modal-l…
rshen91 Apr 2, 2024
484fcef
make style optional
rshen91 Apr 2, 2024
228487e
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Apr 2, 2024
f8ca1c0
fix id for formatted message in embed
rshen91 Apr 2, 2024
da70776
Merge remote-tracking branch 'upstream/main' into rshen-embed-modal-l…
rshen91 Apr 4, 2024
d5b0155
check types fix
rshen91 Apr 4, 2024
975f43d
Merge branch 'main' into rshen-embed-modal-link-logic-rework
rshen91 Apr 4, 2024
d87de2c
remove nulls from tabs
rshen91 Apr 4, 2024
f6dfe9d
Merge remote-tracking branch 'refs/remotes/eokoneyo/rshen-embed-modal…
rshen91 Apr 4, 2024
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ packages/shared-ux/router/mocks @elastic/appex-sharedux
packages/shared-ux/router/types @elastic/appex-sharedux
packages/shared-ux/storybook/config @elastic/appex-sharedux
packages/shared-ux/storybook/mock @elastic/appex-sharedux
packages/shared-ux/modal/tabbed @elastic/appex-sharedux
packages/kbn-shared-ux-utility @elastic/appex-sharedux
x-pack/plugins/observability_solution/slo @elastic/obs-ux-management-team
x-pack/packages/kbn-slo-schema @elastic/obs-ux-management-team
Expand Down
38 changes: 8 additions & 30 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@
"autocomplete": "packages/kbn-securitysolution-autocomplete/src",
"bfetch": "src/plugins/bfetch",
"bfetchError": "packages/kbn-bfetch-error",
"cases": [
"packages/kbn-cases-components"
],
"cases": ["packages/kbn-cases-components"],
"cellActions": "packages/kbn-cell-actions",
"charts": "src/plugins/charts",
"console": "src/plugins/console",
"contentManagement": "packages/content-management",
"core": [
"src/core",
"packages/core"
],
"core": ["src/core", "packages/core"],
"customIntegrations": "src/plugins/custom_integrations",
"customIntegrationsPackage": "packages/kbn-custom-integrations",
"dashboard": "src/plugins/dashboard",
Expand All @@ -31,10 +26,7 @@
"dataViews": "src/plugins/data_views",
"defaultNavigation": "packages/default-nav",
"devTools": "src/plugins/dev_tools",
"discover": [
"src/plugins/discover",
"packages/kbn-discover-utils"
],
"discover": ["src/plugins/discover", "packages/kbn-discover-utils"],
"savedSearch": "src/plugins/saved_search",
"embeddableApi": "src/plugins/embeddable",
"presentationPanel": "src/plugins/presentation_panel",
Expand Down Expand Up @@ -111,10 +103,7 @@
"searchConnectors": "packages/kbn-search-connectors",
"searchConnectorsPlugin": "x-pack/plugins/search_connectors",
"server": "src/legacy/server",
"share": [
"src/plugins/share",
"packages/kbn-reporting-share"
],
"share": ["src/plugins/share", "packages/kbn-reporting-share"],
"sharedUXPackages": "packages/shared-ux",
"searchApiPanels": "packages/kbn-search-api-panels/",
"searchErrors": "packages/kbn-search-errors",
Expand All @@ -126,17 +115,9 @@
"languageDocumentationPopover": "packages/kbn-language-documentation-popover/src",
"textBasedLanguages": "src/plugins/text_based_languages",
"statusPage": "src/legacy/core_plugins/status_page",
"telemetry": [
"src/plugins/telemetry",
"src/plugins/telemetry_management_section"
],
"timelion": [
"src/plugins/vis_types/timelion"
],
"uiActions": [
"src/plugins/ui_actions",
"packages/kbn-ui-actions-browser"
],
"telemetry": ["src/plugins/telemetry", "src/plugins/telemetry_management_section"],
"timelion": ["src/plugins/vis_types/timelion"],
"uiActions": ["src/plugins/ui_actions", "packages/kbn-ui-actions-browser"],
"uiActionsEnhanced": "src/plugins/ui_actions_enhanced",
"uiActionsExamples": "examples/ui_action_examples",
"usageCollection": "src/plugins/usage_collection",
Expand All @@ -157,10 +138,7 @@
"visualizations": "src/plugins/visualizations",
"visualizationUiComponents": "packages/kbn-visualization-ui-components",
"visualizationUtils": "packages/kbn-visualization-utils",
"unifiedDocViewer": [
"src/plugins/unified_doc_viewer",
"packages/kbn-unified-doc-viewer"
],
"unifiedDocViewer": ["src/plugins/unified_doc_viewer", "packages/kbn-unified-doc-viewer"],
"unifiedSearch": "src/plugins/unified_search",
"unifiedFieldList": "packages/kbn-unified-field-list",
"unifiedHistogram": "src/plugins/unified_histogram",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,7 @@
"@kbn/shared-ux-router-types": "link:packages/shared-ux/router/types",
"@kbn/shared-ux-storybook-config": "link:packages/shared-ux/storybook/config",
"@kbn/shared-ux-storybook-mock": "link:packages/shared-ux/storybook/mock",
"@kbn/shared-ux-tabbed-modal": "link:packages/shared-ux/modal/tabbed",
"@kbn/shared-ux-utility": "link:packages/kbn-shared-ux-utility",
"@kbn/slo-plugin": "link:x-pack/plugins/observability_solution/slo",
"@kbn/slo-schema": "link:x-pack/packages/kbn-slo-schema",
Expand Down
19 changes: 19 additions & 0 deletions packages/shared-ux/modal/tabbed/README.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
id: sharedUX/Page/TabbedModal
slug: /shared-ux/modal/tabbed
title: Kibana Tabbed Modal
description: A component for rendering tabs within a modal.
tags: ['shared-ux', 'component']
date: 2024-04-28
---

## API

| Export | Description |
|---|---| |
| `TabbedModal` | component that renders tab content within a modal in kibana.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
| `TabbedModal` | component that renders tab content within a modal in kibana.
| `TabbedModal` | component that renders tab content within a modal in Kibana.

| `IModalTabDeclaration` | type definition for defining the content of a modal tab, also provides support to make the tab content controlled and have it's state if needed be managed by the modal.

## EUI Promotion Status

This component is not currently considered for promotion to EUI.
9 changes: 9 additions & 0 deletions packages/shared-ux/modal/tabbed/index.tsx
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 { TabbedModal, type IModalTabDeclaration } from './src/tabbed_modal';
13 changes: 13 additions & 0 deletions packages/shared-ux/modal/tabbed/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* 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.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../../../..',
roots: ['<rootDir>/packages/shared-ux/modal/tabbed'],
};
5 changes: 5 additions & 0 deletions packages/shared-ux/modal/tabbed/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "shared-common",
"id": "@kbn/shared-ux-tabbed-modal",
"owner": "@elastic/appex-sharedux"
}
6 changes: 6 additions & 0 deletions packages/shared-ux/modal/tabbed/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@kbn/shared-ux-tabbed-modal",
"private": true,
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0"
}
110 changes: 110 additions & 0 deletions packages/shared-ux/modal/tabbed/src/context/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
* 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, { type ComponentProps, type ComponentType } from 'react';
import { renderHook, act } from '@testing-library/react-hooks';
import { useModalContext, ModalContextProvider } from '.';

type ModalContextProviderProps = ComponentProps<typeof ModalContextProvider>;

function createModalContextWrapper<T extends ComponentType>(props: ModalContextProviderProps) {
return function CreatedWrapper({ children }) {
return <ModalContextProvider {...props}>{children}</ModalContextProvider>;
};
}

describe('tabbed modal provider', () => {
it('creates a default internal state of specific shape', () => {
const props: ModalContextProviderProps = {
tabs: [
{
id: 'test',
name: 'Test',
},
],
defaultSelectedTabId: 'test',
};

const { result } = renderHook(useModalContext, {
wrapper: createModalContextWrapper(props),
});

expect(result.current).toHaveProperty(
'tabs',
([] as ModalContextProviderProps['tabs']).concat(props.tabs).map((tab) => {
if (tab.initialState) {
delete tab.initialState;
}

return tab;
})
);

expect(result.current).toHaveProperty(
'state',
expect.objectContaining({
meta: expect.objectContaining({ selectedTabId: props.defaultSelectedTabId }),
test: {},
})
);

expect(result.current).toHaveProperty('dispatch', expect.any(Function));
});

it('invocating the context dispatch function causes state changes for the selected tab state', () => {
const SUT_DISPATCH_ACTION = {
type: 'TEST_ACTION',
payload: 'state_update',
};

const props: ModalContextProviderProps = {
tabs: [
{
id: 'test',
name: 'Test',
reducer: (state = {}, action) => {
switch (action.type) {
case SUT_DISPATCH_ACTION.type:
return {
...state,
sut: action.payload,
};
default:
return state;
}
},
},
],
defaultSelectedTabId: 'test',
};

const { result } = renderHook(useModalContext, {
wrapper: createModalContextWrapper(props),
});

expect(result.current).toHaveProperty(
'state',
expect.objectContaining({
test: {},
})
);

act(() => {
result.current.dispatch(SUT_DISPATCH_ACTION);
});

expect(result.current).toHaveProperty(
'state',
expect.objectContaining({
test: {
sut: SUT_DISPATCH_ACTION.payload,
},
})
);
});
});
Loading