Allow the default space to be accessed via /s/default#77109
Allow the default space to be accessed via /s/default#77109legrego merged 3 commits intoelastic:masterfrom
/s/default#77109Conversation
cd783c1 to
d4a89e5
Compare
d4a89e5 to
64786c2
Compare
| return { | ||
| spaceId: DEFAULT_SPACE_ID, | ||
| pathHasExplicitSpaceIdentifier: false, | ||
| }; |
There was a problem hiding this comment.
I don't love that this function now has two responsibilities, but this function is called in some hot paths, and I didn't want to have to do regex matching twice when I'm already doing the work here to extract the space identifier.
| return `${basePath}${requestedPath}`; | ||
| } | ||
|
|
||
| function stripServerBasePath(requestBasePath: string, serverBasePath: string) { |
There was a problem hiding this comment.
No functional changes: extracted for readability
| const { spaceId, pathHasExplicitSpaceIdentifier } = getSpaceIdFromPath(path, serverBasePath); | ||
|
|
||
| if (spaceId !== DEFAULT_SPACE_ID) { | ||
| if (pathHasExplicitSpaceIdentifier) { |
There was a problem hiding this comment.
This is the actual change which enables the default space to be accessed via /s/default
|
Pinging @elastic/kibana-security (Team:Security) |
jportner
left a comment
There was a problem hiding this comment.
LGTM!
It might be worthwhile to simplify this reporting code as well (CC @tsullivan):
kibana/x-pack/plugins/reporting/server/core.ts
Lines 223 to 226 in d10d70b
| @@ -10,41 +10,60 @@ describe('getSpaceIdFromPath', () => { | |||
| describe('without a serverBasePath defined', () => { | |||
There was a problem hiding this comment.
Just from naively reading the tests, it's not clear that the default space can be used as an explicit space identifier.
Optional nit: what do you think about adding some additional test cases to make that more clear?
diff --git a/x-pack/plugins/spaces/common/lib/spaces_url_parser.test.ts b/x-pack/plugins/spaces/common/lib/spaces_url_parser.test.ts
index d563a0c86cd..c4379574f85 100644
--- a/x-pack/plugins/spaces/common/lib/spaces_url_parser.test.ts
+++ b/x-pack/plugins/spaces/common/lib/spaces_url_parser.test.ts
@@ -16,6 +16,14 @@ describe('getSpaceIdFromPath', () => {
});
});
+ test('it identifies the space url context with the default space', () => {
+ const basePath = `/s/${DEFAULT_SPACE_ID}`;
+ expect(getSpaceIdFromPath(basePath)).toEqual({
+ spaceId: DEFAULT_SPACE_ID,
+ pathHasExplicitSpaceIdentifier: true,
+ });
+ });
+
test('ignores space identifiers in the middle of the path', () => {
const basePath = `/this/is/a/crazy/path/s/my-awesome-space-lives-here`;
expect(getSpaceIdFromPath(basePath)).toEqual({
@@ -42,6 +50,14 @@ describe('getSpaceIdFromPath', () => {
});
});
+ test('it identifies the space url context with the default space', () => {
+ const basePath = `/s/${DEFAULT_SPACE_ID}`;
+ expect(getSpaceIdFromPath(basePath)).toEqual({
+ spaceId: DEFAULT_SPACE_ID,
+ pathHasExplicitSpaceIdentifier: true,
+ });
+ });
+
test('it identifies the space url context following the server base path', () => {
const basePath = `/server-base-path-here/s/my-awesome-space-lives-here`;
expect(getSpaceIdFromPath(basePath, '/server-base-path-here')).toEqual({
@@ -50,6 +66,14 @@ describe('getSpaceIdFromPath', () => {
});
});
+ test('it identifies the space url context with the default space following the server base path', () => {
+ const basePath = `/server-base-path-here/s/${DEFAULT_SPACE_ID}`;
+ expect(getSpaceIdFromPath(basePath, '/server-base-path-here')).toEqual({
+ spaceId: DEFAULT_SPACE_ID,
+ pathHasExplicitSpaceIdentifier: true,
+ });
+ });
+
test('ignores space identifiers in the middle of the path', () => {
const basePath = `/this/is/a/crazy/path/s/my-awesome-space-lives-here`;
expect(getSpaceIdFromPath(basePath, '/this/is/a')).toEqual({There was a problem hiding this comment.
Thanks for the suggestion! Done in 2084f12 (#77109)
💚 Build SucceededMetrics [docs]page load bundle size
History
To update your PR or re-run it, just comment with: |
#80815) * Allow the default space to be accessed via /s/default * apply suggestions from code review
* master: (51 commits) [Discover] Unskip flaky test (elastic#80670) Fix security solution template label (elastic#80754) [Ingest]: ignore 404, check if there are transforms in results. (elastic#80721) Moving loader to logo in header, add a slight 250ms pause (elastic#78879) [Security Solution][Cases] Fix bug with case connectors (elastic#80642) Update known-plugins.asciidoc (elastic#75388) [Lens] Add median operation (elastic#79453) Fix navigateToApp logic when navigating to the current app. (elastic#80809) [Visualizations] Fix bad color mapping with multiple split series (elastic#80801) [ILM] Add esErrorHandler for the new es js client (elastic#80302) Fix codeowners (elastic#80826) skip flaky suite (elastic#79463) [Timelion] Remove kui usage (elastic#80287) [Ingest Manager] add skipIfNoDockerRegistry to package_install_complete test (elastic#80779) [Alerting UI] Disable "Save" button for Alerts with broken Connectors (elastic#80579) Allow the default space to be accessed via `/s/default` (elastic#77109) Add script to identify plugin dependencies for TS project references migration (elastic#80463) [Search] Client side session service (elastic#76889) feat: 🎸 add separator for different context menu groups (elastic#80498) Lazy load reporting (elastic#80492) ...
Summary
Allows the default space to be accessed via
/s/defaultas well as/.Resolves #62053