Skip to content

Commit

Permalink
[Bug] Fix notebook routes for savedNotebook endpoints (#2279) (#2282)
Browse files Browse the repository at this point in the history
* Fix notebook routes to remove extra slash



* revert legacy notebook api route change



---------


(cherry picked from commit 4f894de)

Signed-off-by: Shenoy Pratik <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 64e98ce commit d2911e7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
8 changes: 5 additions & 3 deletions public/components/notebooks/components/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,19 @@ export class Main extends React.Component<MainProps, MainState> {
if (this.props.dataSourceEnabled) {
// If `MDS` is enabled, only fetch from the first endpoint.
return this.props.http
.get(`${NOTEBOOKS_API_PREFIX}/savedNotebook/`)
.get(`${NOTEBOOKS_API_PREFIX}/savedNotebook`)
.then((savedNotebooksResponse) => {
this.setState({ data: savedNotebooksResponse.data });
})
.catch((err) => {
console.error('Issue in fetching the notebooks', err.body.message);
});
}
// If `MDS` is not enabled /savedNotebook/ API returns notebooks stored as saved objects, and the other one returns notebooks stored as observability objects.
// If `MDS` is not enabled /savedNotebook API returns notebooks stored as saved objects, and the other one returns notebooks stored as observability objects.
// ${NOTEBOOKS_API_PREFIX}/savedNotebook: this point to new notebooks saved in saved objects
// ${NOTEBOOKS_API_PREFIX}/: this point to old notebooks saved in observability index
return Promise.all([
this.props.http.get(`${NOTEBOOKS_API_PREFIX}/savedNotebook/`),
this.props.http.get(`${NOTEBOOKS_API_PREFIX}/savedNotebook`),
this.props.http.get(`${NOTEBOOKS_API_PREFIX}/`),
])
.then(([savedNotebooksResponse, secondResponse]) => {
Expand Down
18 changes: 9 additions & 9 deletions public/components/notebooks/components/notebook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
*/

import {
EuiSmallButton,
EuiButtonGroup,
EuiButtonGroupOptionProps,
EuiButtonIcon,
EuiCallOut,
EuiCard,
EuiContextMenu,
Expand All @@ -19,18 +19,18 @@ import {
EuiPageBody,
EuiPanel,
EuiPopover,
EuiSmallButton,
EuiSpacer,
EuiText,
EuiButtonIcon,
EuiTitle,
EuiToolTip,
} from '@elastic/eui';
import { FormattedMessage } from '@osd/i18n/react';
import CSS from 'csstype';
import moment from 'moment';
import queryString from 'query-string';
import React, { Component } from 'react';
import { RouteComponentProps } from 'react-router-dom';
import { FormattedMessage } from '@osd/i18n/react';
import {
ChromeBreadcrumb,
CoreStart,
Expand All @@ -43,6 +43,8 @@ import { CREATE_NOTE_MESSAGE, NOTEBOOKS_API_PREFIX } from '../../../../common/co
import { UI_DATE_FORMAT } from '../../../../common/constants/shared';
import { ParaType } from '../../../../common/types/notebooks';
import { setNavBreadCrumbs } from '../../../../common/utils/set_nav_bread_crumbs';
import { HeaderControlledComponentsWrapper } from '../../../../public/plugin_helpers/plugin_headerControl';
import { coreRefs } from '../../../framework/core_refs';
import PPLService from '../../../services/requests/ppl';
import { GenerateReportLoadingModal } from './helpers/custom_modals/reporting_loading_modal';
import { defaultParagraphParser } from './helpers/default_parser';
Expand All @@ -54,8 +56,6 @@ import {
generateInContextReport,
} from './helpers/reporting_context_menu_helper';
import { Paragraphs } from './paragraph_components/paragraphs';
import { HeaderControlledComponentsWrapper } from '../../../../public/plugin_helpers/plugin_headerControl';
import { coreRefs } from '../../../framework/core_refs';

const newNavigation = coreRefs.chrome?.navGroup.getNavGroupEnabled();

Expand Down Expand Up @@ -416,7 +416,7 @@ export class Notebook extends Component<NotebookProps, NotebookState> {
};

return this.props.http
.post(`${NOTEBOOKS_API_PREFIX}/savedNotebook/paragraph/`, {
.post(`${NOTEBOOKS_API_PREFIX}/savedNotebook/paragraph`, {
body: JSON.stringify(addParaObj),
})
.then((res) => {
Expand Down Expand Up @@ -468,7 +468,7 @@ export class Notebook extends Component<NotebookProps, NotebookState> {
};

return this.props.http
.post(`${NOTEBOOKS_API_PREFIX}/savedNotebook/set_paragraphs/`, {
.post(`${NOTEBOOKS_API_PREFIX}/savedNotebook/set_paragraphs`, {
body: JSON.stringify(moveParaObj),
})
.then((_res) => this.setState({ paragraphs, parsedPara }))
Expand Down Expand Up @@ -499,7 +499,7 @@ export class Notebook extends Component<NotebookProps, NotebookState> {
noteId: this.props.openedNoteId,
};
this.props.http
.put(`${NOTEBOOKS_API_PREFIX}/savedNotebook/paragraph/clearall/`, {
.put(`${NOTEBOOKS_API_PREFIX}/savedNotebook/paragraph/clearall`, {
body: JSON.stringify(clearParaObj),
})
.then((res) => {
Expand Down Expand Up @@ -537,7 +537,7 @@ export class Notebook extends Component<NotebookProps, NotebookState> {
};
const isValid = isValidUUID(this.props.openedNoteId);
const route = isValid
? `${NOTEBOOKS_API_PREFIX}/savedNotebook/paragraph/update/run/`
? `${NOTEBOOKS_API_PREFIX}/savedNotebook/paragraph/update/run`
: `${NOTEBOOKS_API_PREFIX}/paragraph/update/run/`;
return this.props.http
.post(route, {
Expand Down
10 changes: 5 additions & 5 deletions server/routes/notebooks/paraRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ export function registerParaRoute(router: IRouter) {

router.post(
{
path: `${NOTEBOOKS_API_PREFIX}/savedNotebook/paragraph/`,
path: `${NOTEBOOKS_API_PREFIX}/savedNotebook/paragraph`,
validate: {
body: schema.object({
noteId: schema.string(),
Expand Down Expand Up @@ -314,7 +314,7 @@ export function registerParaRoute(router: IRouter) {
);
router.put(
{
path: `${NOTEBOOKS_API_PREFIX}/savedNotebook/paragraph/clearall/`,
path: `${NOTEBOOKS_API_PREFIX}/savedNotebook/paragraph/clearall`,
validate: {
body: schema.object({
noteId: schema.string(),
Expand Down Expand Up @@ -377,7 +377,7 @@ export function registerParaRoute(router: IRouter) {

router.post(
{
path: `${NOTEBOOKS_API_PREFIX}/savedNotebook/paragraph/update/run/`,
path: `${NOTEBOOKS_API_PREFIX}/savedNotebook/paragraph/update/run`,
validate: {
body: schema.object({
noteId: schema.string(),
Expand Down Expand Up @@ -413,7 +413,7 @@ export function registerParaRoute(router: IRouter) {

router.put(
{
path: `${NOTEBOOKS_API_PREFIX}/savedNotebook/paragraph/`,
path: `${NOTEBOOKS_API_PREFIX}/savedNotebook/paragraph`,
validate: {
body: schema.object({
noteId: schema.string(),
Expand Down Expand Up @@ -445,7 +445,7 @@ export function registerParaRoute(router: IRouter) {
);
router.post(
{
path: `${NOTEBOOKS_API_PREFIX}/savedNotebook/set_paragraphs/`,
path: `${NOTEBOOKS_API_PREFIX}/savedNotebook/set_paragraphs`,
validate: {
body: schema.object({
noteId: schema.string(),
Expand Down

0 comments on commit d2911e7

Please sign in to comment.