Skip to content

Commit

Permalink
Merge commit '94e850dcb52bfbcd8850a5aef6d96eef303a179f' into lens/ref…
Browse files Browse the repository at this point in the history
…actor_dragdrop
  • Loading branch information
mbondyra committed Jul 7, 2023
2 parents 3334807 + 94e850d commit b0f3b2f
Show file tree
Hide file tree
Showing 26 changed files with 492 additions and 70 deletions.
1 change: 1 addition & 0 deletions packages/kbn-doc-links/src/get_doc_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
connectorsDropbox: `${ENTERPRISE_SEARCH_DOCS}connectors-dropbox.html`,
connectorsContentExtraction: `${ENTERPRISE_SEARCH_DOCS}connectors-content-extraction.html`,
connectorsGoogleCloudStorage: `${ENTERPRISE_SEARCH_DOCS}connectors-google-cloud.html`,
connectorsGoogleDrive: `${ENTERPRISE_SEARCH_DOCS}connectors-google-drive.html`,
connectorsJira: `${ENTERPRISE_SEARCH_DOCS}connectors-jira.html`,
connectorsMicrosoftSQL: `${ENTERPRISE_SEARCH_DOCS}connectors-ms-sql.html`,
connectorsMongoDB: `${ENTERPRISE_SEARCH_DOCS}connectors-mongodb.html`,
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-doc-links/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export interface DocLinks {
readonly connectorsContentExtraction: string;
readonly connectorsDropbox: string;
readonly connectorsGoogleCloudStorage: string;
readonly connectorsGoogleDrive: string;
readonly connectorsJira: string;
readonly connectorsMicrosoftSQL: string;
readonly connectorsMongoDB: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pageLoadAssetSize:
kibanaUsageCollection: 16463
kibanaUtils: 79713
kubernetesSecurity: 77234
lens: 37000
lens: 38000
licenseManagement: 41817
licensing: 29004
lists: 22900
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export function FiltersNotificationPopover({
}: FiltersNotificationProps) {
const { embeddable } = context;
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
const [disableEditbutton, setDisableEditButton] = useState(false);

return (
<EuiPopover
Expand All @@ -57,26 +58,31 @@ export function FiltersNotificationPopover({
anchorPosition="upCenter"
>
<EuiPopoverTitle>{displayName}</EuiPopoverTitle>
<FiltersNotificationPopoverContents context={context} />
<FiltersNotificationPopoverContents
context={context}
setDisableEditButton={setDisableEditButton}
/>
<EuiPopoverFooter>
<EuiFlexGroup
gutterSize="s"
alignItems="center"
justifyContent="flexEnd"
responsive={false}
wrap={true}
>
<EuiFlexItem grow={false}>
<EuiButton
data-test-subj={'filtersNotificationModal__editButton'}
size="s"
fill
onClick={() => editPanelAction.execute({ embeddable })}
>
{dashboardFilterNotificationActionStrings.getEditButtonTitle()}
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
{!disableEditbutton && (
<EuiFlexGroup
gutterSize="s"
alignItems="center"
justifyContent="flexEnd"
responsive={false}
wrap={true}
>
<EuiFlexItem grow={false}>
<EuiButton
data-test-subj={'filtersNotificationModal__editButton'}
size="s"
fill
onClick={() => editPanelAction.execute({ embeddable })}
>
{dashboardFilterNotificationActionStrings.getEditButtonTitle()}
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
)}
</EuiPopoverFooter>
</EuiPopover>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ import { DashboardContainer } from '../dashboard_container/embeddable/dashboard_

export interface FiltersNotificationProps {
context: FiltersNotificationActionContext;
setDisableEditButton: (flag: boolean) => void;
}

export function FiltersNotificationPopoverContents({ context }: FiltersNotificationProps) {
export function FiltersNotificationPopoverContents({
context,
setDisableEditButton,
}: FiltersNotificationProps) {
const { embeddable } = context;
const [isLoading, setIsLoading] = useState(true);
const [filters, setFilters] = useState<Filter[]>([]);
Expand All @@ -53,6 +57,7 @@ export function FiltersNotificationPopoverContents({ context }: FiltersNotificat
const language = getAggregateQueryMode(embeddableQuery);
setQueryLanguage(language);
setQueryString(embeddableQuery[language as keyof AggregateQuery]);
setDisableEditButton(true);
}
}
setIsLoading(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ export function useChartConfigPanel({
dataView={dataView}
adaptersTables={lensTablesAdapter}
updateAll={updateSuggestion}
setIsFlyoutVisible={setIsFlyoutVisible}
closeFlyout={() => {
setIsFlyoutVisible(false);
}}
wrapInFlyout
datasourceId="textBased"
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,43 @@ describe('getLensAttributes', () => {
`);
});

it('should return correct attributes for text based languages with adhoc dataview', () => {
const adHocDataview = {
...dataView,
isPersisted: () => false,
} as DataView;
const lensAttrs = getLensAttributes({
title: 'test',
filters,
query,
dataView: adHocDataview,
timeInterval,
breakdownField: undefined,
suggestion: currentSuggestionMock,
});
expect(lensAttrs.attributes).toEqual({
state: expect.objectContaining({
adHocDataViews: {
'index-pattern-with-timefield-id': {},
},
}),
references: [
{
id: 'index-pattern-with-timefield-id',
name: 'indexpattern-datasource-current-indexpattern',
type: 'index-pattern',
},
{
id: 'index-pattern-with-timefield-id',
name: 'indexpattern-datasource-layer-unifiedHistogram',
type: 'index-pattern',
},
],
title: 'test',
visualizationType: 'lnsHeatmap',
});
});

it('should return suggestion title if no title is given', () => {
expect(
getLensAttributes({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ export const getLensAttributes = ({
filters,
query,
visualization,
...(dataView &&
dataView.id &&
!dataView.isPersisted() && {
adHocDataViews: {
[dataView.id]: dataView.toSpec(false),
},
}),
},
visualizationType: suggestion ? suggestion.visualizationId : 'lnsXY',
} as TypedLensByValueInput['attributes'];
Expand Down
10 changes: 10 additions & 0 deletions x-pack/plugins/enterprise_search/common/connectors/connectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ export const CONNECTOR_DEFINITIONS: ConnectorServerSideDefinition[] = [
}),
serviceType: 'google_cloud_storage',
},
{
iconPath: 'google_drive.svg',
isBeta: true,
isNative: false,
keywords: ['google', 'drive', 'connector'],
name: i18n.translate('xpack.enterpriseSearch.content.nativeConnectors.googleDrive.name', {
defaultMessage: 'Google Drive',
}),
serviceType: 'google_drive',
},
{
iconPath: 'mongodb.svg',
isBeta: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export const CONNECTORS_DICT: Record<string, ConnectorClientSideDefinition> = {
externalDocsUrl: 'https://cloud.google.com/storage/docs',
icon: CONNECTOR_ICONS.google_cloud_storage,
},
google_drive: {
docsUrl: docLinks.connectorsGoogleDrive,
externalAuthDocsUrl: 'https://cloud.google.com/iam/docs/service-account-overview',
externalDocsUrl: 'https://developers.google.com/drive',
icon: CONNECTOR_ICONS.google_drive,
},
jira: {
docsUrl: docLinks.connectorsJira,
externalAuthDocsUrl: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class DocLinks {
public connectorsContentExtraction: string;
public connectorsDropbox: string;
public connectorsGoogleCloudStorage: string;
public connectorsGoogleDrive: string;
public connectorsJira: string;
public connectorsMicrosoftSQL: string;
public connectorsMongoDB: string;
Expand Down Expand Up @@ -223,6 +224,7 @@ class DocLinks {
this.connectorsClients = '';
this.connectorsDropbox = '';
this.connectorsGoogleCloudStorage = '';
this.connectorsGoogleDrive = '';
this.connectorsJira = '';
this.connectorsMicrosoftSQL = '';
this.connectorsMongoDB = '';
Expand Down Expand Up @@ -380,6 +382,7 @@ class DocLinks {
this.connectorsDropbox = docLinks.links.enterpriseSearch.connectorsDropbox;
this.connectorsGoogleCloudStorage =
docLinks.links.enterpriseSearch.connectorsGoogleCloudStorage;
this.connectorsGoogleDrive = docLinks.links.enterpriseSearch.connectorsGoogleDrive;
this.connectorsJira = docLinks.links.enterpriseSearch.connectorsJira;
this.connectorsMicrosoftSQL = docLinks.links.enterpriseSearch.connectorsMicrosoftSQL;
this.connectorsMongoDB = docLinks.links.enterpriseSearch.connectorsMongoDB;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import custom from '../../../assets/source_icons/custom.svg';
import dropbox from '../../../assets/source_icons/dropbox.svg';
import github from '../../../assets/source_icons/github.svg';
import google_cloud_storage from '../../../assets/source_icons/google_cloud_storage.svg';
import google_drive from '../../../assets/source_icons/google_drive.svg';
import jira_cloud from '../../../assets/source_icons/jira_cloud.svg';
import mongodb from '../../../assets/source_icons/mongodb.svg';
import microsoft_sql from '../../../assets/source_icons/mssql.svg';
Expand All @@ -31,6 +32,7 @@ export const CONNECTOR_ICONS = {
dropbox,
github,
google_cloud_storage,
google_drive,
jira_cloud,
microsoft_sql,
mongodb,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export function getEditLensConfiguration(
attributes,
dataView,
updateAll,
setIsFlyoutVisible,
closeFlyout,
wrapInFlyout,
datasourceId,
adaptersTables,
}: EditLensConfigurationProps) => {
Expand Down Expand Up @@ -88,15 +89,38 @@ export function getEditLensConfiguration(
const lensStore: LensRootStore = makeConfigureStore(storeDeps, {
lens: getPreloadedState(storeDeps) as LensAppState,
} as unknown as PreloadedState<LensState>);
const closeFlyout = () => {
setIsFlyoutVisible?.(false);

const getWrapper = (children: JSX.Element) => {
if (wrapInFlyout) {
return (
<EuiFlyout
type="push"
ownFocus
onClose={() => {
closeFlyout?.();
}}
aria-labelledby={i18n.translate('xpack.lens.config.editLabel', {
defaultMessage: 'Edit configuration',
})}
size="s"
hideCloseButton
css={css`
background: none;
`}
>
{children}
</EuiFlyout>
);
} else {
return children;
}
};

const configPanelProps = {
attributes,
dataView,
updateAll,
setIsFlyoutVisible,
closeFlyout,
datasourceId,
adaptersTables,
coreStart,
Expand All @@ -105,25 +129,10 @@ export function getEditLensConfiguration(
datasourceMap,
};

return (
<EuiFlyout
type="push"
ownFocus
onClose={closeFlyout}
aria-labelledby={i18n.translate('xpack.lens.config.editLabel', {
defaultMessage: 'Edit configuration',
})}
size="s"
className="lnsEditConfigurationFlyout"
css={css`
background: none;
`}
hideCloseButton
>
<Provider store={lensStore}>
<LensEditConfigurationFlyout {...configPanelProps} />
</Provider>
</EuiFlyout>
return getWrapper(
<Provider store={lensStore}>
<LensEditConfigurationFlyout {...configPanelProps} />
</Provider>
);
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,22 +120,22 @@ describe('LensEditConfigurationFlyout', () => {
startDependencies,
visualizationMap,
datasourceMap,
setIsFlyoutVisible: jest.fn(),
closeFlyout: jest.fn(),
datasourceId: 'testDatasource',
} as unknown as EditConfigPanelProps;
}

it('should call the setIsFlyout callback if collapse button is clicked', async () => {
const setIsFlyoutVisibleSpy = jest.fn();
it('should call the closeFlyout callback if collapse button is clicked', async () => {
const closeFlyoutSpy = jest.fn();
const props = getDefaultProps();
const newProps = {
...props,
setIsFlyoutVisible: setIsFlyoutVisibleSpy,
closeFlyout: closeFlyoutSpy,
};
const { instance } = await prepareAndMountComponent(newProps);
expect(instance.find(EuiFlyoutBody).exists()).toBe(true);
instance.find('[data-test-subj="collapseFlyoutButton"]').at(1).simulate('click');
expect(setIsFlyoutVisibleSpy).toHaveBeenCalled();
expect(closeFlyoutSpy).toHaveBeenCalled();
});

it('should compute the frame public api correctly', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export interface EditConfigPanelProps {
startDependencies: LensPluginStartDependencies;
visualizationMap: VisualizationMap;
datasourceMap: DatasourceMap;
setIsFlyoutVisible?: (flag: boolean) => void;
closeFlyout?: () => void;
wrapInFlyout?: boolean;
datasourceId: 'formBased' | 'textBased';
adaptersTables?: Record<string, Datatable>;
}
Expand All @@ -57,7 +58,7 @@ export function LensEditConfigurationFlyout({
datasourceMap,
datasourceId,
updateAll,
setIsFlyoutVisible,
closeFlyout,
adaptersTables,
}: EditConfigPanelProps) {
const currentDataViewId = dataView.id ?? '';
Expand Down Expand Up @@ -112,10 +113,6 @@ export function LensEditConfigurationFlyout({
};
}, [activeData, dataViews, datasourceLayers, dateRange]);

const closeFlyout = () => {
setIsFlyoutVisible?.(false);
};

const layerPanelsProps = {
framePublicAPI,
datasourceMap,
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/lens/public/async_services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ export * from './app_plugin/save_modal_container';
export * from './chart_info_api';

export * from './trigger_actions/open_in_discover_helpers';
export * from './trigger_actions/open_lens_config/helpers';
Loading

0 comments on commit b0f3b2f

Please sign in to comment.