Skip to content

Commit

Permalink
Fix integration removal timing (opensearch-project#781)
Browse files Browse the repository at this point in the history
* Fix integration removal timing

Signed-off-by: Simeon Widdis <[email protected]>

* Remove unused commented code

Signed-off-by: Simeon Widdis <[email protected]>

---------

Signed-off-by: Simeon Widdis <[email protected]>
  • Loading branch information
Swiddis authored Aug 3, 2023
1 parent 3e1eb69 commit 4d33d82
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { HttpStart } from '../../../../../../src/core/public';
export interface AddedIntegrationsTableProps {
loading: boolean;
data: AddedIntegrationsList;
setData: React.Dispatch<React.SetStateAction<AddedIntegrationsList>>;
http: HttpStart;
}

Expand Down Expand Up @@ -57,7 +58,7 @@ export function AddedIntegrationOverviewPage(props: AddedIntegrationOverviewPage
<EuiPage>
<EuiPageBody component="div">
{IntegrationHeader()}
{AddedIntegrationsTable({ data, loading: false, http })}
{AddedIntegrationsTable({ data, setData, loading: false, http })}
</EuiPageBody>
</EuiPage>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import { INTEGRATIONS_BASE } from '../../../../common/constants/shared';
import { useToast } from '../../../../public/components/common/toast';

export function AddedIntegrationsTable(props: AddedIntegrationsTableProps) {
const integrations = props.data.hits;

const { http } = props;

const { setToast } = useToast();
Expand Down Expand Up @@ -90,6 +88,9 @@ export function AddedIntegrationsTable(props: AddedIntegrationsTableProps) {
.delete(`${INTEGRATIONS_BASE}/store/${integrationInstance}`)
.then(() => {
setToast(`${name} integration successfully deleted!`, 'success');
props.setData({
hits: props.data.hits.filter((i) => i.id !== integrationInstance),
});
})
.catch((err) => {
setToast(`Error deleting ${name} or its assets`, 'danger');
Expand Down Expand Up @@ -137,7 +138,7 @@ export function AddedIntegrationsTable(props: AddedIntegrationsTableProps) {
],
};

const entries = integrations.map((integration) => {
const entries = props.data.hits.map((integration) => {
const id = integration.id;
const templateName = integration.templateName;
const creationDate = integration.creationDate;
Expand Down

0 comments on commit 4d33d82

Please sign in to comment.