Skip to content

Commit

Permalink
[Discover] Simplify feedback modal (#5837)
Browse files Browse the repository at this point in the history
* Simplify feedback modal

Signed-off-by: Ashwin P Chandran <[email protected]>

* renames datagrid  settng to newDiscover setting

Signed-off-by: Ashwin P Chandran <[email protected]>

* removes sub module from branch

Signed-off-by: Ashwin P Chandran <[email protected]>

---------

Signed-off-by: Ashwin P Chandran <[email protected]>
  • Loading branch information
ashwin-pc authored Feb 7, 2024
1 parent 79dc3f3 commit b078a06
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 280 deletions.
1 change: 0 additions & 1 deletion dashboards-observability
Submodule dashboards-observability deleted from 8f091b
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
} from '../../../../common';
import { UI_SETTINGS } from '../../../../../data/common';
import { LegacyDiscoverTable } from '../default_discover_table/default_discover_table';
import { getDataGridTableSetting } from '../utils/local_storage';
import { getNewDiscoverSetting } from '../utils/local_storage';
import { SortDirection, SortOrder } from '../../../saved_searches/types';
import { useToolbarOptions } from './data_grid_toolbar';

Expand Down Expand Up @@ -160,7 +160,7 @@ export const DataGridTable = ({
];
}, []);

const datagridActive = getDataGridTableSetting(services.storage);
const newDiscoverEnabled = getNewDiscoverSetting(services.storage);

const legacyDiscoverTable = useMemo(
() => (
Expand Down Expand Up @@ -232,7 +232,7 @@ export const DataGridTable = ({
]
);

const tablePanelProps = datagridActive
const tablePanelProps = newDiscoverEnabled
? {
paddingSize: 'none' as const,
style: {
Expand Down Expand Up @@ -267,9 +267,9 @@ export const DataGridTable = ({
className="eui-xScrollWithShadows"
>
<EuiPanel hasBorder={false} hasShadow={false} {...tablePanelProps}>
{datagridActive ? dataGridTable : legacyDiscoverTable}
{newDiscoverEnabled ? dataGridTable : legacyDiscoverTable}
</EuiPanel>
{datagridActive && inspectedHit && (
{newDiscoverEnabled && inspectedHit && (
<DataGridFlyout
indexPattern={indexPattern}
hit={inspectedHit}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import { i18n } from '@osd/i18n';
import React from 'react';
import { EuiText } from '@elastic/eui';
import { DiscoverViewServices } from '../../../build_services';
import { showOpenSearchPanel } from './show_open_search_panel';
import { SavedSearch } from '../../../saved_searches';
import { Adapters } from '../../../../../inspector/public';
import { TopNavMenuData } from '../../../../../navigation/public';
Expand All @@ -16,14 +16,17 @@ import {
SavedObjectSaveModal,
showSaveModal,
} from '../../../../../saved_objects/public';
import {
OpenSearchDashboardsContextProvider,
toMountPoint,
} from '../../../../../opensearch_dashboards_react/public';
import { DiscoverState, setSavedSearchId } from '../../utils/state_management';
import { DOC_HIDE_TIME_COLUMN_SETTING, SORT_DEFAULT_ORDER_SETTING } from '../../../../common';
import { getSortForSearchSource } from '../../view_components/utils/get_sort_for_search_source';
import { getRootBreadcrumbs } from '../../helpers/breadcrumbs';
import { syncQueryStateWithUrl } from '../../../../../data/public';

import { showTableFeedbacksPanel } from './show_table_feedbacks_panel';
import { getDataGridTableSetting, setDataGridTableSetting } from '../utils/local_storage';
import { getNewDiscoverSetting, setNewDiscoverSetting } from '../utils/local_storage';
import { OpenSearchPanel } from './open_search_panel';

export const getTopNavLinks = (
services: DiscoverViewServices,
Expand Down Expand Up @@ -166,11 +169,20 @@ export const getTopNavLinks = (
}),
testId: 'discoverOpenButton',
run: () => {
showOpenSearchPanel({
makeUrl: (searchId) => `#/view/${encodeURIComponent(searchId)}`,
I18nContext: core.i18n.Context,
services,
});
const flyoutSession = services.overlays.openFlyout(
toMountPoint(
<OpenSearchDashboardsContextProvider services={services}>
<OpenSearchPanel
onClose={() => {
if (flyoutSession) {
flyoutSession.close();
}
}}
makeUrl={(searchId) => `#/view/${encodeURIComponent(searchId)}`}
/>
</OpenSearchDashboardsContextProvider>
)
);
},
};

Expand Down Expand Up @@ -201,7 +213,7 @@ export const getTopNavLinks = (
...sharingData,
title: savedSearch.title,
},
isDirty: !savedSearch.id || state.isDirty,
isDirty: !savedSearch.id || state.isDirty || false,
});
},
};
Expand All @@ -228,7 +240,7 @@ export const getTopNavLinks = (
const oldDiscoverButtonLabel = i18n.translate('discover.localMenu.discoverButton.label.old', {
defaultMessage: 'Use legacy Discover',
});
const isNewDiscover = getDataGridTableSetting(storage);
const isNewDiscover = getNewDiscoverSetting(storage);
const newTable: TopNavMenuData = {
id: 'table-datagrid',
label: isNewDiscover ? oldDiscoverButtonLabel : newDiscoverButtonLabel,
Expand All @@ -238,15 +250,37 @@ export const getTopNavLinks = (
testId: 'datagridTableButton',
run: async () => {
// Read the current state from localStorage
const useDatagridTable = getDataGridTableSetting(storage);
if (useDatagridTable) {
showTableFeedbacksPanel({
I18nContext: core.i18n.Context,
services,
});
const newDiscoverEnabled = getNewDiscoverSetting(storage);
if (newDiscoverEnabled) {
const confirmed = await services.overlays.openConfirm(
toMountPoint(
<EuiText>
<p>
Help drive future improvements by{' '}
<a href="https://survey.opensearch.org" target="_blank" rel="noopener noreferrer">
providing feedback
</a>{' '}
about your experience.
</p>
</EuiText>
),
{
title: i18n.translate('discover.localMenu.newTableConfirmModalTitle', {
defaultMessage: 'Share your thoughts on the latest Discover features',
}),
cancelButtonText: 'Cancel',
confirmButtonText: 'Turn off new features',
defaultFocusedButton: 'confirm',
}
);

if (confirmed) {
setNewDiscoverSetting(false, storage);
window.location.reload();
}
} else {
// Save the new setting to localStorage
setDataGridTableSetting(true, storage);
setNewDiscoverSetting(true, storage);
window.location.reload();
}
},
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit b078a06

Please sign in to comment.