Skip to content

Commit

Permalink
Support new notebooks URL for reporting (#373)
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Li <joshuali925@gmail.com>
  • Loading branch information
joshuali925 committed Apr 17, 2023
1 parent e6208d0 commit 2f78f54
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ describe('Test legacy route helpers', () => {
},
] as Location[];
const expected = [
'/app/observability-dashboards#/notebooks/GQ5icXwBJCegTOBKO4Um',
'/app/observability-dashboards#/notebooks/clPiPXwBEM7l9gC0xTpA?view=view_both',
`/testBasePath/app/observability-dashboards#/notebooks/GQ5icXwBJCegTOBKO4Um?_g=(time:(from:'2021-10-15T20:25:09.556Z',to:'2021-10-15T20:55:09.556Z'))&view=output_only&security_tenant=global`,
] as RedirectProps['to'][];
'/app/observability-notebooks#/GQ5icXwBJCegTOBKO4Um',
'/app/observability-notebooks#/clPiPXwBEM7l9gC0xTpA?view=view_both',
`/testBasePath/app/observability-notebooks#/GQ5icXwBJCegTOBKO4Um?_g=(time:(from:'2021-10-15T20:25:09.556Z',to:'2021-10-15T20:55:09.556Z'))&view=output_only&security_tenant=global`,
] as Array<RedirectProps['to']>;
expect(locations.map((location) => convertLegacyNotebooksUrl(location))).toEqual(expected);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { observabilityID } from "../../../../../common/constants/shared";
import { observabilityNotebookID } from '../../../../../common/constants/shared';

export const convertLegacyNotebooksUrl = (location: Location)=> {
const pathname = location.pathname.replace('notebooks-dashboards', observabilityID);
const hash = `#/notebooks${location.hash.replace(/^#/, '')}${
export const convertLegacyNotebooksUrl = (location: Location) => {
const pathname = location.pathname.replace('notebooks-dashboards', observabilityNotebookID);
const hash = `${location.hash}${
location.hash.includes('?') ? location.search.replace(/^\?/, '&') : location.search
}`;
return pathname + hash;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ export const generateInContextReport = async (
toggleReportingLoadingModal(true);
let baseUrl =
location.pathname +
location.hash.replace(/\?view=(view_both|input_only|output_only)/, '') +
'?view=output_only';
location.hash.replace(/view=(view_both|input_only|output_only)/, 'view=output_only');
// Add selected tenant info to url
try {
const tenant = await getTenantInfoIfExists();
Expand Down

0 comments on commit 2f78f54

Please sign in to comment.