-
Notifications
You must be signed in to change notification settings - Fork 916
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add table feedback panel and fix comments
Signed-off-by: Anan Z <[email protected]>
- Loading branch information
Showing
10 changed files
with
214 additions
and
29 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
42 changes: 42 additions & 0 deletions
42
...r/public/application/components/top_nav/__snapshots__/table_feedbacks_panel.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
50 changes: 50 additions & 0 deletions
50
src/plugins/discover/public/application/components/top_nav/show_table_feedbacks_panel.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,50 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { TableFeedbacksPanel } from './table_feedbacks_panel'; | ||
import { I18nStart } from '../../../../../../core/public'; | ||
import { OpenSearchDashboardsContextProvider } from '../../../../../opensearch_dashboards_react/public'; | ||
import { DiscoverViewServices } from '../../../build_services'; | ||
import { DATA_GRID_TABLE } from '../../../../common'; | ||
|
||
let isFeedbackPanelOpen = false; | ||
|
||
export function showTableFeedbacksPanel({ | ||
I18nContext, | ||
services, | ||
}: { | ||
I18nContext: I18nStart['Context']; | ||
services: DiscoverViewServices; | ||
}) { | ||
// if (isFeedbackPanelOpen) { | ||
// return; | ||
// } | ||
|
||
// isFeedbackPanelOpen = true; | ||
const container = document.createElement('div'); | ||
const onClose = () => { | ||
ReactDOM.unmountComponentAtNode(container); | ||
document.body.removeChild(container); | ||
isFeedbackPanelOpen = false; | ||
}; | ||
|
||
const onTurnOff = async () => { | ||
await services.uiSettings.set(DATA_GRID_TABLE, false); | ||
onClose(); | ||
window.location.reload(); | ||
}; | ||
|
||
document.body.appendChild(container); | ||
const element = ( | ||
<OpenSearchDashboardsContextProvider services={services}> | ||
<I18nContext> | ||
<TableFeedbacksPanel onClose={onClose} onTurnOff={onTurnOff} /> | ||
</I18nContext> | ||
</OpenSearchDashboardsContextProvider> | ||
); | ||
ReactDOM.render(element, container); | ||
} |
34 changes: 34 additions & 0 deletions
34
src/plugins/discover/public/application/components/top_nav/table_feedbacks_panel.test.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,34 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { shallow, ShallowWrapper } from 'enzyme'; | ||
import { TableFeedbacksPanel } from './table_feedbacks_panel'; | ||
|
||
describe('TableFeedbacksPanel', () => { | ||
let onCloseMock: jest.Mock; | ||
let onTurnOffMock: jest.Mock; | ||
let wrapper: ShallowWrapper; | ||
|
||
beforeEach(() => { | ||
onCloseMock = jest.fn(); | ||
onTurnOffMock = jest.fn(); | ||
wrapper = shallow(<TableFeedbacksPanel onClose={onCloseMock} onTurnOff={onTurnOffMock} />); | ||
}); | ||
|
||
it('renders correctly', () => { | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('calls onClose when the Cancel button is clicked', () => { | ||
wrapper.find('EuiButtonEmpty').simulate('click'); | ||
expect(onCloseMock).toHaveBeenCalled(); | ||
}); | ||
|
||
it('calls onTurnOff when the Turn off new features button is clicked', () => { | ||
wrapper.find('EuiButton').simulate('click'); | ||
expect(onTurnOffMock).toHaveBeenCalled(); | ||
}); | ||
}); |
48 changes: 48 additions & 0 deletions
48
src/plugins/discover/public/application/components/top_nav/table_feedbacks_panel.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,48 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { | ||
EuiModal, | ||
EuiModalHeader, | ||
EuiModalHeaderTitle, | ||
EuiModalBody, | ||
EuiModalFooter, | ||
EuiButton, | ||
EuiText, | ||
EuiButtonEmpty, | ||
} from '@elastic/eui'; | ||
|
||
interface TableFeedbacksPanelProps { | ||
onClose: () => void; | ||
onTurnOff: () => Promise<void>; | ||
} | ||
|
||
export const TableFeedbacksPanel = ({ onClose, onTurnOff }: TableFeedbacksPanelProps) => ( | ||
<EuiModal onClose={onClose} maxWidth={600}> | ||
<EuiModalHeader> | ||
<EuiModalHeaderTitle> | ||
<h4>Share your thoughts on the latest Discover features</h4> | ||
</EuiModalHeaderTitle> | ||
</EuiModalHeader> | ||
|
||
<EuiModalBody> | ||
<EuiText> | ||
<p> | ||
Event tables: Documents are now expanded through a flyout. Density, column order, and | ||
sorting controls have been improved.{' '} | ||
<a href="https://survey.opensearch.org">Provide feedbacks</a>. | ||
</p> | ||
</EuiText> | ||
</EuiModalBody> | ||
|
||
<EuiModalFooter> | ||
<EuiButtonEmpty onClick={onClose}>Cancel</EuiButtonEmpty> | ||
<EuiButton onClick={onTurnOff} fill> | ||
Turn off new features | ||
</EuiButton> | ||
</EuiModalFooter> | ||
</EuiModal> | ||
); |
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