Skip to content

Commit

Permalink
Add delete ability (opensearch-project#380)
Browse files Browse the repository at this point in the history
* Update tests, builds and doc (opensearch-project#318)

* rebased with bwc tests

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* updated bwc tests

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* added release notes

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* Rename trace-analytics to observability (opensearch-project#341)

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* Event analytics unit tests (opensearch-project#342)

* tests

Signed-off-by: Eric Wei <menwe@amazon.com>

* updated some snapshots

Signed-off-by: Eric Wei <menwe@amazon.com>

* resolved few failing tests

Signed-off-by: Eric Wei <menwe@amazon.com>

* few modifications

Signed-off-by: Eric Wei <menwe@amazon.com>

* Update service map parsing results for testing (opensearch-project#345)

Signed-off-by: Joshua Li <joshuali925@gmail.com>

* bumping version to 1.2.2 (opensearch-project#346)

* bumping version to 1.2.2

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* update PR in release notes

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* updating readme and badges (opensearch-project#352)

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* Application Analytics (opensearch-project#299)

* Add database schema for application

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Finished front end for Application overview
Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Finished application detail page tabs
Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* WIP: Overview Page
Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Rough sketch of App Analytics UI
Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Create dummy page
Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Create app complete. Stabilizing dashboard component.
Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Update to 1.2 Observability

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* notebooks internal error

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Address comments on PR: copyright headers, indentation, unnecessary render props

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Set max width of app and event

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Remove optional after description

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Change to singular

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Remove count badge for log source

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#290: Change form row label to ppl base query

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#291: Change description and help text for log source

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Pass down proper props

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Resolve gradle error and module not found error

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Resolve kotlin errors

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Fix parsers

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Add praseItemList

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Camelcase fields

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Remove whitespace, add copyright

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#292: Add autocomplete to Log Source accordion

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Lexicographic kotlin import

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Add newline at end of files

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#293: Add service map to create page

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#304: Activate Clear All button for services

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#305: Add button to clear base query

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#295: Add eui combo box for trace groups

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Separate out configuration renders

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* debug adding filters traces

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#296: Add traces table to config

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Change from tsx to ts

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#309: Add page props and add app specific filters

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#308: Add button to clear trace groups

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#311: Allow services and traces to be selected

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Remove link to traces on table

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Disable clear all if nothing selected

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* disable clear all when no log source

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Remove comment, add style to constant, temporarily remove availability

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Address PR comments

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Revert type assignment

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Update tests, builds and doc (opensearch-project#318)

* rebased with bwc tests

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* updated bwc tests

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* added release notes

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* Fix errors and address comments

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#319: Disable create until required fields are filled out

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#329: Add missing field tool tip

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Remove unnecessary imports

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#320: Add clear modal for friction

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

Co-authored-by: Shenoy Pratik <sgguruda@amazon.com>

* Fix merge conflict

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Update Workflow (opensearch-project#360)

* updated snapshot in workflow to 1.2.3

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* replaced variable with 1.2.3-snapshot

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* revert string to variable

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* Application Analytics (opensearch-project#299)

* Add database schema for application

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Finished front end for Application overview
Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Finished application detail page tabs
Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* WIP: Overview Page
Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Rough sketch of App Analytics UI
Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Create dummy page
Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Create app complete. Stabilizing dashboard component.
Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Update to 1.2 Observability

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* notebooks internal error

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Address comments on PR: copyright headers, indentation, unnecessary render props

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Set max width of app and event

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Remove optional after description

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Change to singular

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Remove count badge for log source

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#290: Change form row label to ppl base query

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#291: Change description and help text for log source

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Pass down proper props

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Resolve gradle error and module not found error

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Resolve kotlin errors

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Fix parsers

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Add praseItemList

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Camelcase fields

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Remove whitespace, add copyright

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#292: Add autocomplete to Log Source accordion

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Lexicographic kotlin import

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Add newline at end of files

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#293: Add service map to create page

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#304: Activate Clear All button for services

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#305: Add button to clear base query

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#295: Add eui combo box for trace groups

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Separate out configuration renders

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* debug adding filters traces

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#296: Add traces table to config

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Change from tsx to ts

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#309: Add page props and add app specific filters

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#308: Add button to clear trace groups

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#311: Allow services and traces to be selected

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Remove link to traces on table

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Disable clear all if nothing selected

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* disable clear all when no log source

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Remove comment, add style to constant, temporarily remove availability

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Address PR comments

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Revert type assignment

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Update tests, builds and doc (opensearch-project#318)

* rebased with bwc tests

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* updated bwc tests

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* added release notes

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* Fix errors and address comments

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#319: Disable create until required fields are filled out

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#329: Add missing field tool tip

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Remove unnecessary imports

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#320: Add clear modal for friction

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

Co-authored-by: Shenoy Pratik <sgguruda@amazon.com>

* Application Analytics (opensearch-project#299)

* Add database schema for application

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Finished front end for Application overview
Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Finished application detail page tabs
Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* WIP: Overview Page
Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Rough sketch of App Analytics UI
Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Create dummy page
Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Create app complete. Stabilizing dashboard component.
Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Update to 1.2 Observability

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* notebooks internal error

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Address comments on PR: copyright headers, indentation, unnecessary render props

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Set max width of app and event

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Remove optional after description

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Change to singular

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Remove count badge for log source

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#290: Change form row label to ppl base query

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#291: Change description and help text for log source

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Pass down proper props

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Resolve gradle error and module not found error

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Resolve kotlin errors

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Fix parsers

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Add praseItemList

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Camelcase fields

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Remove whitespace, add copyright

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#292: Add autocomplete to Log Source accordion

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Lexicographic kotlin import

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Add newline at end of files

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#293: Add service map to create page

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#304: Activate Clear All button for services

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#305: Add button to clear base query

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#295: Add eui combo box for trace groups

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Separate out configuration renders

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* debug adding filters traces

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#296: Add traces table to config

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Change from tsx to ts

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#309: Add page props and add app specific filters

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#308: Add button to clear trace groups

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#311: Allow services and traces to be selected

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Remove link to traces on table

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Disable clear all if nothing selected

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* disable clear all when no log source

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Remove comment, add style to constant, temporarily remove availability

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Address PR comments

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Revert type assignment

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Update tests, builds and doc (opensearch-project#318)

* rebased with bwc tests

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* updated bwc tests

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* added release notes

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* Fix errors and address comments

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#319: Disable create until required fields are filled out

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#329: Add missing field tool tip

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Remove unnecessary imports

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#320: Add clear modal for friction

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

Co-authored-by: Shenoy Pratik <sgguruda@amazon.com>

* Fix merge conflict

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#321: Add clear modal for services (opensearch-project#355)

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#322: Add clear modal for traces (opensearch-project#356)

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Adds tests for application creation (opensearch-project#357)

* Remove unnecessary memoization

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Add tests for create page

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Remove conflict

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Add create route for app analytics

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#325: Return to app table on cancel

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Remove unnecessary import

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#340: Apps selectable, actions correctly disabled

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Fix mapping update

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#327: Rename application

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#376: Fetch all applications for home page

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* opensearch-project#343: Enable deletion of application

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Add exception catch

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* More specific exception
:

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Log error instead of warn

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Remove generic exception

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Debug assert

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Fix type

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Fix Lint

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Address comments

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* 343: Enable deletion of application

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Remove duplicate import

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Bump version to 1.3

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

* Bump workflow

Signed-off-by: Eugene Lee <eugenesk@amazon.com>

Co-authored-by: Shenoy Pratik <sgguruda@amazon.com>
Co-authored-by: Joshua Li <joshuali925@gmail.com>
Co-authored-by: Eric Wei <menwe@amazon.com>
  • Loading branch information
4 people committed Jan 25, 2022
1 parent ad1ab89 commit 53aade0
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: Test and Build OpenSearch Observability Backend Plugin
on: [pull_request, push]

env:
OPENSEARCH_VERSION: '1.2.3-SNAPSHOT'
OPENSEARCH_BRANCH: '1.2'
OPENSEARCH_VERSION: '1.3.0-SNAPSHOT'
OPENSEARCH_BRANCH: '1.3'
COMMON_UTILS_BRANCH: 'main'

jobs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,24 @@ import _ from 'lodash';
import React, { ReactElement, useEffect, useState } from 'react';
import { AppAnalyticsComponentDeps } from '../home';
import { getCustomModal } from '../../custom_panels/helpers/modal_containers';
import { getClearModal } from '../helpers/modal_containers';
import { pageStyles } from '../../../../common/constants/shared';
import { ApplicationListType } from '../../../../common/types/app_analytics';
import { ApplicationListType } from '../../../../common/constants/application_analytics';

interface AppTableProps extends AppAnalyticsComponentDeps {
loading: boolean;
applications: Array<ApplicationListType>;
fetchApplications: () => void;
renameApplication: (newAppName: string, appId: string) => void;
deleteApplication: (appList: string[], toastMessage?: string) => void;
};

export function AppTable(props: AppTableProps) {
const [isModalVisible, setIsModalVisible] = useState(false);
const [isActionsPopoverOpen, setIsActionsPopoverOpen] = useState(false);
const [modalLayout, setModalLayout] = useState(<EuiOverlayMask></EuiOverlayMask>);
const [selectedApplications, setSelectedApplications] = useState<ApplicationListType[]>([]);
const { chrome, applications, parentBreadcrumb, fetchApplications, renameApplication } = props;
const { chrome, applications, parentBreadcrumb, fetchApplications, renameApplication, deleteApplication } = props;

useEffect(() => {
chrome.setBreadcrumbs(
Expand All @@ -72,13 +74,24 @@ export function AppTable(props: AppTableProps) {
closeModal();
};

const onDelete = async () => {
const toastMessage = `Application${
selectedApplications.length > 1 ? 's' : ' "' + selectedApplications[0].name + '"'
} successfully deleted!`;
await deleteApplication(
selectedApplications.map((app) => app.id),
toastMessage
);
closeModal();
};

const renameApp = () => {
setModalLayout(
getCustomModal(
onRename,
closeModal,
'Name',
'Rename Application',
'Rename application',
'Cancel',
'Rename',
selectedApplications[0].name
Expand All @@ -87,6 +100,19 @@ export function AppTable(props: AppTableProps) {
showModal();
};

const deleteApp = () => {
const applicationString = `application${selectedApplications.length > 1 ? 's' : ''}`;
setModalLayout(
getClearModal(
closeModal,
onDelete,
`Delete ${selectedApplications.length} ${applicationString}`,
`Are you sure you want to delete the selected ${selectedApplications.length} ${applicationString}?`
)
);
showModal();
};

const popoverButton = (
<EuiButton
iconType="arrowDown"
Expand Down Expand Up @@ -117,6 +143,10 @@ export function AppTable(props: AppTableProps) {
<EuiContextMenuItem
key="delete"
disabled={applications.length === 0 || selectedApplications.length === 0}
onClick={() => {
setIsActionsPopoverOpen(false);
deleteApp();
}}
>
Delete
</EuiContextMenuItem>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import TimestampUtils from 'public/services/timestamp/timestamp';
import { handleIndicesExistRequest } from '../trace_analytics/requests/request_handler';
import { ObservabilitySideBar } from '../common/side_nav';
import { NotificationsStart } from '../../../../../src/core/public';
import { optionType, APP_ANALYTICS_API_PREFIX, ApplicationListType } from '../../../common/types/app_analytics';
import { APP_ANALYTICS_API_PREFIX } from '../../../common/constants/application_analytics';
import { optionType, ApplicationListType } from '../../../common/types/app_analytics';
import { isNameValid } from './helpers/utils';
import { EuiGlobalToastList } from '@elastic/eui';
import { Toast } from '@elastic/eui/src/components/toast/global_toast_list';
Expand Down Expand Up @@ -93,7 +94,7 @@ export const Home = (props: HomeProps) => {
const fetchApps = () => {
return http
.get(`${APP_ANALYTICS_API_PREFIX}/`)
.then(async (res) => {
.then((res) => {
setApplicationData(res.data);
})
.catch((err) => {
Expand Down Expand Up @@ -122,7 +123,7 @@ export const Home = (props: HomeProps) => {
.post(`${APP_ANALYTICS_API_PREFIX}/`, {
body: JSON.stringify(requestBody)
})
.then(async (res) => {
.then((res) => {
setToast(`Application "${name}" successfully created!`);
window.location.assign(`${parentBreadcrumb.href}${res.newAppId}`)
})
Expand All @@ -148,7 +149,7 @@ export const Home = (props: HomeProps) => {
.patch(`${APP_ANALYTICS_API_PREFIX}/rename`, {
body: JSON.stringify(requestBody)
})
.then(async (res) => {
.then((res) => {
setApplicationData((prevApplicationData) => {
const newApplicationData = [...prevApplicationData];
const renamedApplication = newApplicationData.find(
Expand All @@ -165,6 +166,25 @@ export const Home = (props: HomeProps) => {
});
};

// Delete existing applications
const deleteApp = (appList: string[], toastMessage?: string) => {
return http
.delete(`${APP_ANALYTICS_API_PREFIX}/${appList.join(',')}`)
.then((res) => {
setApplicationData((prevApplicationData) => {
return prevApplicationData.filter((app) => !appList.includes(app.id))
});
const message =
toastMessage || `Application${appList.length > 1 ? 's' : ''} successfully deleted!`;
setToast(message);
return res;
})
.catch((err: any) => {
setToast('Error occured while deleting application', 'danger');
console.error(err);
});
};

return (
<div>
<EuiGlobalToastList
Expand All @@ -185,6 +205,7 @@ export const Home = (props: HomeProps) => {
applications={applicationData}
fetchApplications={fetchApps}
renameApplication={renameApp}
deleteApplication={deleteApp}
{...commonProps} />
</ObservabilitySideBar>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,13 @@ export class AppAnalyticsAdaptor {
const updateApplicationBody = {
name: name,
};
try {
const response = await this.updateApp(client, appId, updateApplicationBody);
try {
const response = await client.callAsCurrentUser('observability.updateObjectById', {
objectId: appId,
body: {
application: updateApplicationBody,
}
})
return response.objectId;
} catch (err: any) {
throw new Error('Rename Application Error: ' + err);
Expand All @@ -86,7 +91,23 @@ export class AppAnalyticsAdaptor {
});
return response;
} catch (err: any) {
throw new Error('Update Panel Error: ' + err)
throw new Error('Update Panel Error: ' + err);
}
}

// Delete existing applications
deleteApp = async (
client: ILegacyScopedClusterClient,
appList: string,
) => {
try {
const response = await client.callAsCurrentUser('observability.deleteObjectByIdList', {
objectIdList: appList,
});
return { status: 'OK', message: response };
} catch (err: any) {
throw new Error('Delete Application Error: ' + err);
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,38 @@ export function registerAppAnalyticsRouter(router: IRouter) {
}
);

}
// Delete applications
router.delete(
{
path: `${API_PREFIX}/{appList}`,
validate: {
params: schema.object({
appList: schema.string(),
}),
},
},
async (
context,
request,
response
): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {
const opensearchClient: ILegacyScopedClusterClient = context.observability_plugin.observabilityClient.asScoped(
request
);
try {
const delResponse = await appAnalyticsBackend.deleteApp(
opensearchClient,
request.params.appList
);
return response.ok({
body: delResponse,
});
} catch (err: any) {
return response.custom({
statusCode: err.statusCode || 500,
body: err.message,
});
}
}
);
}
2 changes: 1 addition & 1 deletion opensearch-observability/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.opensearch.gradle.testclusters.StandaloneRestIntegTestTask

buildscript {
ext {
opensearch_version = System.getProperty("opensearch.version", "1.2.3-SNAPSHOT")
opensearch_version = System.getProperty("opensearch.version", "1.3.0-SNAPSHOT")
// 1.0.0 -> 1.0.0.0, and 1.0.0-SNAPSHOT -> 1.0.0.0-SNAPSHOT
opensearch_build = opensearch_version.replaceAll(/(\.\d)([^\d]*)$/, '$1.0$2')
common_utils_version = System.getProperty("common_utils.version", opensearch_build)
Expand Down

0 comments on commit 53aade0

Please sign in to comment.