Skip to content

Commit

Permalink
Merge branch 'main' into fix-non-ecs-sort
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored May 20, 2022
2 parents a8db1db + 46cd729 commit de12ca8
Show file tree
Hide file tree
Showing 90 changed files with 1,662 additions and 594 deletions.
6 changes: 6 additions & 0 deletions packages/kbn-doc-links/src/get_doc_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
apiKeys: `${WORKPLACE_SEARCH_DOCS}workplace-search-api-authentication.html`,
box: `${WORKPLACE_SEARCH_DOCS}workplace-search-box-connector.html`,
confluenceCloud: `${WORKPLACE_SEARCH_DOCS}workplace-search-confluence-cloud-connector.html`,
confluenceCloudConnectorPackage: `${WORKPLACE_SEARCH_DOCS}confluence-cloud.html`,
confluenceServer: `${WORKPLACE_SEARCH_DOCS}workplace-search-confluence-server-connector.html`,
customConnectorPackage: `${WORKPLACE_SEARCH_DOCS}custom-connector-package.html`,
customSources: `${WORKPLACE_SEARCH_DOCS}workplace-search-custom-api-sources.html`,
customSourcePermissions: `${WORKPLACE_SEARCH_DOCS}workplace-search-custom-api-sources.html#custom-api-source-document-level-access-control`,
documentPermissions: `${WORKPLACE_SEARCH_DOCS}workplace-search-sources-document-permissions.html`,
Expand All @@ -139,7 +141,9 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
indexingSchedule: `${WORKPLACE_SEARCH_DOCS}workplace-search-customizing-indexing-rules.html#_indexing_schedule`,
jiraCloud: `${WORKPLACE_SEARCH_DOCS}workplace-search-jira-cloud-connector.html`,
jiraServer: `${WORKPLACE_SEARCH_DOCS}workplace-search-jira-server-connector.html`,
networkDrive: `${WORKPLACE_SEARCH_DOCS}network-drives.html`,
oneDrive: `${WORKPLACE_SEARCH_DOCS}workplace-search-onedrive-connector.html`,
outlook: `${WORKPLACE_SEARCH_DOCS}microsoft-outlook.html`,
permissions: `${WORKPLACE_SEARCH_DOCS}workplace-search-permissions.html#organizational-sources-private-sources`,
salesforce: `${WORKPLACE_SEARCH_DOCS}workplace-search-salesforce-connector.html`,
security: `${WORKPLACE_SEARCH_DOCS}workplace-search-security.html`,
Expand All @@ -148,7 +152,9 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
sharePointServer: `${WORKPLACE_SEARCH_DOCS}sharepoint-server.html`,
slack: `${WORKPLACE_SEARCH_DOCS}workplace-search-slack-connector.html`,
synch: `${WORKPLACE_SEARCH_DOCS}workplace-search-customizing-indexing-rules.html`,
teams: `${WORKPLACE_SEARCH_DOCS}microsoft-teams.html`,
zendesk: `${WORKPLACE_SEARCH_DOCS}workplace-search-zendesk-connector.html`,
zoom: `${WORKPLACE_SEARCH_DOCS}zoom.html`,
},
metricbeat: {
base: `${ELASTIC_WEBSITE_URL}guide/en/beats/metricbeat/${DOC_LINK_VERSION}`,
Expand Down
6 changes: 6 additions & 0 deletions packages/kbn-doc-links/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ export interface DocLinks {
readonly apiKeys: string;
readonly box: string;
readonly confluenceCloud: string;
readonly confluenceCloudConnectorPackage: string;
readonly confluenceServer: string;
readonly customConnectorPackage: string;
readonly customSources: string;
readonly customSourcePermissions: string;
readonly documentPermissions: string;
Expand All @@ -125,7 +127,9 @@ export interface DocLinks {
readonly indexingSchedule: string;
readonly jiraCloud: string;
readonly jiraServer: string;
readonly networkDrive: string;
readonly oneDrive: string;
readonly outlook: string;
readonly permissions: string;
readonly salesforce: string;
readonly security: string;
Expand All @@ -134,7 +138,9 @@ export interface DocLinks {
readonly sharePointServer: string;
readonly slack: string;
readonly synch: string;
readonly teams: string;
readonly zendesk: string;
readonly zoom: string;
};
readonly heartbeat: {
readonly base: string;
Expand Down
13 changes: 0 additions & 13 deletions src/plugins/share/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -215,19 +215,6 @@ const url = await shortUrls.create({
});
```

You can make the short URL slug human-readable by specifying the
`humanReadableSlug` flag:

```ts
const url = await shortUrls.create({
locator,
params: {
dashboardId: '123',
},
humanReadableSlug: true,
});
```

Or you can manually specify the slug for the short URL using the `slug` option:

```ts
Expand Down
6 changes: 0 additions & 6 deletions src/plugins/share/common/url_service/short_urls/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@ export interface ShortUrlCreateParams<P extends SerializableRecord> {
* URL. This part will be visible to the user, it can have user-friendly text.
*/
slug?: string;

/**
* Whether to generate a slug automatically. If `true`, the slug will be
* a human-readable text consisting of three worlds: "<adjective>-<adjective>-<noun>".
*/
humanReadableSlug?: boolean;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ describe('create()', () => {
body: expect.any(String),
});
expect(JSON.parse(fetchSpy.mock.calls[0][1].body)).toStrictEqual({
humanReadableSlug: false,
locatorId: LEGACY_SHORT_URL_LOCATOR_ID,
params: {
url: 'https://example.com/foo/bar',
Expand Down Expand Up @@ -173,7 +172,6 @@ describe('createFromLongUrl()', () => {
body: expect.any(String),
});
expect(JSON.parse(fetchSpy.mock.calls[0][1].body)).toStrictEqual({
humanReadableSlug: true,
locatorId: LEGACY_SHORT_URL_LOCATOR_ID,
params: {
url: '/a/b/c',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,13 @@ export class BrowserShortUrlClient implements IShortUrlClient {
locator,
params,
slug = undefined,
humanReadableSlug = false,
}: ShortUrlCreateParams<P>): Promise<ShortUrl<P>> {
const { http } = this.dependencies;
const data = await http.fetch<ShortUrlData<P>>('/api/short_url', {
method: 'POST',
body: JSON.stringify({
locatorId: locator.id,
slug,
humanReadableSlug,
params,
}),
});
Expand Down Expand Up @@ -113,7 +111,6 @@ export class BrowserShortUrlClient implements IShortUrlClient {

const result = await this.createWithLocator({
locator,
humanReadableSlug: true,
params: {
url: relativeUrl,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ export const registerCreateRoute = (router: IRouter, url: ServerUrlService) => {
minLength: 3,
maxLength: 255,
}),
/**
* @deprecated
*
* This field is deprecated as the API does not support automatic
* human-readable slug generation.
*
* @todo This field will be removed in a future version. It is left
* here for backwards compatibility.
*/
humanReadableSlug: schema.boolean({
defaultValue: false,
}),
Expand All @@ -36,7 +45,7 @@ export const registerCreateRoute = (router: IRouter, url: ServerUrlService) => {
router.handleLegacyErrors(async (ctx, req, res) => {
const savedObjects = (await ctx.core).savedObjects.client;
const shortUrls = url.shortUrls.get({ savedObjects });
const { locatorId, params, slug, humanReadableSlug } = req.body;
const { locatorId, params, slug } = req.body;
const locator = url.locators.get(locatorId);

if (!locator) {
Expand All @@ -51,7 +60,6 @@ export const registerCreateRoute = (router: IRouter, url: ServerUrlService) => {
locator,
params,
slug,
humanReadableSlug,
});

return res.ok({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,6 @@ describe('ServerShortUrlClient', () => {
})
).rejects.toThrowError(new UrlServiceError(`Slug "lala" already exists.`, 'SLUG_EXISTS'));
});

test('can automatically generate human-readable slug', async () => {
const { client, locator } = setup();
const shortUrl = await client.create({
locator,
humanReadableSlug: true,
params: {
url: '/app/test#foo/bar/baz',
},
});

expect(shortUrl.data.slug.split('-').length).toBe(3);
});
});

describe('.get()', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import type { SerializableRecord } from '@kbn/utility-types';
import { SavedObjectReference } from '@kbn/core/server';
import { generateSlug } from 'random-word-slugs';
import { ShortUrlRecord } from '.';
import type {
IShortUrlClient,
Expand Down Expand Up @@ -60,14 +59,13 @@ export class ServerShortUrlClient implements IShortUrlClient {
locator,
params,
slug = '',
humanReadableSlug = false,
}: ShortUrlCreateParams<P>): Promise<ShortUrl<P>> {
if (slug) {
validateSlug(slug);
}

if (!slug) {
slug = humanReadableSlug ? generateSlug() : randomStr(4);
slug = randomStr(5);
}

const { storage, currentVersion } = this.dependencies;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function ({ getService }: FtrProviderContext) {

expect(resp.body).to.be.an('array');

expect(resp.body.length).to.be(43);
expect(resp.body.length).to.be(42);

// Test for sample data card
expect(resp.body.findIndex((c: { id: string }) => c.id === 'sample_data_all')).to.be.above(
Expand Down
16 changes: 0 additions & 16 deletions test/api_integration/apis/short_url/create_short_url/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,6 @@ export default function ({ getService }: FtrProviderContext) {
expect(response.body.url).to.be('');
});

it('can generate a human-readable slug, composed of three words', async () => {
const response = await supertest.post('/api/short_url').send({
locatorId: 'LEGACY_SHORT_URL_LOCATOR',
params: {},
humanReadableSlug: true,
});

expect(response.status).to.be(200);
expect(typeof response.body.slug).to.be('string');
const words = response.body.slug.split('-');
expect(words.length).to.be(3);
for (const word of words) {
expect(word.length > 0).to.be(true);
}
});

it('can create a short URL with custom slug', async () => {
const rnd = Math.round(Math.random() * 1e6) + 1;
const slug = 'test-slug-' + Date.now() + '-' + rnd;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ class DocLinks {
public workplaceSearchApiKeys: string;
public workplaceSearchBox: string;
public workplaceSearchConfluenceCloud: string;
public workplaceSearchConfluenceCloudConnectorPackage: string;
public workplaceSearchConfluenceServer: string;
public workplaceSearchCustomConnectorPackage: string;
public workplaceSearchCustomSources: string;
public workplaceSearchCustomSourcePermissions: string;
public workplaceSearchDocumentPermissions: string;
Expand All @@ -78,7 +80,9 @@ class DocLinks {
public workplaceSearchIndexingSchedule: string;
public workplaceSearchJiraCloud: string;
public workplaceSearchJiraServer: string;
public workplaceSearchNetworkDrive: string;
public workplaceSearchOneDrive: string;
public workplaceSearchOutlook: string;
public workplaceSearchPermissions: string;
public workplaceSearchSalesforce: string;
public workplaceSearchSecurity: string;
Expand All @@ -87,7 +91,9 @@ class DocLinks {
public workplaceSearchSharePointServer: string;
public workplaceSearchSlack: string;
public workplaceSearchSynch: string;
public workplaceSearchTeams: string;
public workplaceSearchZendesk: string;
public workplaceSearchZoom: string;

constructor() {
this.appSearchApis = '';
Expand Down Expand Up @@ -146,7 +152,9 @@ class DocLinks {
this.workplaceSearchApiKeys = '';
this.workplaceSearchBox = '';
this.workplaceSearchConfluenceCloud = '';
this.workplaceSearchConfluenceCloudConnectorPackage = '';
this.workplaceSearchConfluenceServer = '';
this.workplaceSearchCustomConnectorPackage = '';
this.workplaceSearchCustomSources = '';
this.workplaceSearchCustomSourcePermissions = '';
this.workplaceSearchDocumentPermissions = '';
Expand All @@ -160,7 +168,9 @@ class DocLinks {
this.workplaceSearchIndexingSchedule = '';
this.workplaceSearchJiraCloud = '';
this.workplaceSearchJiraServer = '';
this.workplaceSearchNetworkDrive = '';
this.workplaceSearchOneDrive = '';
this.workplaceSearchOutlook = '';
this.workplaceSearchPermissions = '';
this.workplaceSearchSalesforce = '';
this.workplaceSearchSecurity = '';
Expand All @@ -169,7 +179,9 @@ class DocLinks {
this.workplaceSearchSharePointServer = '';
this.workplaceSearchSlack = '';
this.workplaceSearchSynch = '';
this.workplaceSearchTeams = '';
this.workplaceSearchZendesk = '';
this.workplaceSearchZoom = '';
}

public setDocLinks(docLinks: DocLinksStart): void {
Expand Down Expand Up @@ -230,7 +242,11 @@ class DocLinks {
this.workplaceSearchApiKeys = docLinks.links.workplaceSearch.apiKeys;
this.workplaceSearchBox = docLinks.links.workplaceSearch.box;
this.workplaceSearchConfluenceCloud = docLinks.links.workplaceSearch.confluenceCloud;
this.workplaceSearchConfluenceCloudConnectorPackage =
docLinks.links.workplaceSearch.confluenceCloudConnectorPackage;
this.workplaceSearchConfluenceServer = docLinks.links.workplaceSearch.confluenceServer;
this.workplaceSearchCustomConnectorPackage =
docLinks.links.workplaceSearch.customConnectorPackage;
this.workplaceSearchCustomSources = docLinks.links.workplaceSearch.customSources;
this.workplaceSearchCustomSourcePermissions =
docLinks.links.workplaceSearch.customSourcePermissions;
Expand All @@ -246,7 +262,9 @@ class DocLinks {
this.workplaceSearchIndexingSchedule = docLinks.links.workplaceSearch.indexingSchedule;
this.workplaceSearchJiraCloud = docLinks.links.workplaceSearch.jiraCloud;
this.workplaceSearchJiraServer = docLinks.links.workplaceSearch.jiraServer;
this.workplaceSearchNetworkDrive = docLinks.links.workplaceSearch.networkDrive;
this.workplaceSearchOneDrive = docLinks.links.workplaceSearch.oneDrive;
this.workplaceSearchOutlook = docLinks.links.workplaceSearch.outlook;
this.workplaceSearchPermissions = docLinks.links.workplaceSearch.permissions;
this.workplaceSearchSalesforce = docLinks.links.workplaceSearch.salesforce;
this.workplaceSearchSecurity = docLinks.links.workplaceSearch.security;
Expand All @@ -255,7 +273,9 @@ class DocLinks {
this.workplaceSearchSharePointServer = docLinks.links.workplaceSearch.sharePointServer;
this.workplaceSearchSlack = docLinks.links.workplaceSearch.slack;
this.workplaceSearchSynch = docLinks.links.workplaceSearch.synch;
this.workplaceSearchTeams = docLinks.links.workplaceSearch.teams;
this.workplaceSearchZendesk = docLinks.links.workplaceSearch.zendesk;
this.workplaceSearchZoom = docLinks.links.workplaceSearch.zoom;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const staticGenericExternalSourceData: SourceDataItem = {
isPublicKey: false,
hasOauthRedirect: false,
needsBaseUrl: false,
documentationUrl: docLinks.workplaceSearchCustomSources, // TODO Update this when we have a doclink
documentationUrl: docLinks.workplaceSearchCustomConnectorPackage,
applicationPortalUrl: '',
},
objTypes: [],
Expand Down Expand Up @@ -107,7 +107,7 @@ export const staticSourceData: SourceDataItem[] = [
isPublicKey: false,
hasOauthRedirect: true,
needsBaseUrl: true,
documentationUrl: docLinks.workplaceSearchConfluenceCloud, // TODO Update this when we have a doclink
documentationUrl: docLinks.workplaceSearchConfluenceCloudConnectorPackage,
applicationPortalUrl: 'https://developer.atlassian.com/console/myapps/',
},
objTypes: [
Expand Down Expand Up @@ -387,7 +387,7 @@ export const staticSourceData: SourceDataItem[] = [
isPublicKey: false,
hasOauthRedirect: false,
needsBaseUrl: false,
documentationUrl: docLinks.workplaceSearchCustomSources, // TODO Update this when we have a doclink
documentationUrl: docLinks.workplaceSearchNetworkDrive,
applicationPortalUrl: '',
githubRepository: 'elastic/enterprise-search-network-drive-connector',
},
Expand Down Expand Up @@ -433,7 +433,7 @@ export const staticSourceData: SourceDataItem[] = [
isPublicKey: false,
hasOauthRedirect: false,
needsBaseUrl: false,
documentationUrl: docLinks.workplaceSearchCustomSources, // TODO Update this when we have a doclink
documentationUrl: docLinks.workplaceSearchOutlook,
applicationPortalUrl: '',
githubRepository: 'elastic/enterprise-search-outlook-connector',
},
Expand Down Expand Up @@ -649,7 +649,7 @@ export const staticSourceData: SourceDataItem[] = [
isPublicKey: false,
hasOauthRedirect: false,
needsBaseUrl: false,
documentationUrl: docLinks.workplaceSearchCustomSources, // TODO Update this when we have a doclink
documentationUrl: docLinks.workplaceSearchTeams,
applicationPortalUrl: '',
githubRepository: 'elastic/enterprise-search-teams-connector',
},
Expand Down Expand Up @@ -691,7 +691,7 @@ export const staticSourceData: SourceDataItem[] = [
isPublicKey: false,
hasOauthRedirect: false,
needsBaseUrl: false,
documentationUrl: docLinks.workplaceSearchCustomSources, // TODO Update this when we have a doclink
documentationUrl: docLinks.workplaceSearchZoom,
applicationPortalUrl: '',
githubRepository: 'elastic/enterprise-search-zoom-connector',
},
Expand Down

This file was deleted.

Loading

0 comments on commit de12ca8

Please sign in to comment.