adding success alert message for topic deletion (#2094)
This commit is contained in:
parent
a211c41207
commit
9eae6b1f0a
2 changed files with 29 additions and 14 deletions
|
@ -368,7 +368,16 @@ describe('topics Slice', () => {
|
||||||
describe('Thunks', () => {
|
describe('Thunks', () => {
|
||||||
const store = mockStoreCreator;
|
const store = mockStoreCreator;
|
||||||
const topicName = topic.name;
|
const topicName = topic.name;
|
||||||
|
const RealDate = Date.now;
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
global.Date.now = jest.fn(() =>
|
||||||
|
new Date('2019-04-07T10:20:30Z').getTime()
|
||||||
|
);
|
||||||
|
});
|
||||||
|
afterAll(() => {
|
||||||
|
global.Date.now = RealDate;
|
||||||
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
fetchMock.restore();
|
fetchMock.restore();
|
||||||
store.clearActions();
|
store.clearActions();
|
||||||
|
@ -495,6 +504,18 @@ describe('topics Slice', () => {
|
||||||
|
|
||||||
expect(getTypeAndPayload(store)).toEqual([
|
expect(getTypeAndPayload(store)).toEqual([
|
||||||
{ type: deleteTopic.pending.type },
|
{ type: deleteTopic.pending.type },
|
||||||
|
{ type: showSuccessAlert.pending.type },
|
||||||
|
{
|
||||||
|
type: alertAdded.type,
|
||||||
|
payload: {
|
||||||
|
id: 'message-topic-local',
|
||||||
|
title: '',
|
||||||
|
type: 'success',
|
||||||
|
createdAt: global.Date.now(),
|
||||||
|
message: 'Topic successfully deleted!',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ type: showSuccessAlert.fulfilled.type },
|
||||||
{
|
{
|
||||||
type: deleteTopic.fulfilled.type,
|
type: deleteTopic.fulfilled.type,
|
||||||
payload: { topicName },
|
payload: { topicName },
|
||||||
|
@ -662,17 +683,6 @@ describe('topics Slice', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('updateTopicPartitionsCount', () => {
|
describe('updateTopicPartitionsCount', () => {
|
||||||
const RealDate = Date.now;
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
global.Date.now = jest.fn(() =>
|
|
||||||
new Date('2019-04-07T10:20:30Z').getTime()
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(() => {
|
|
||||||
global.Date.now = RealDate;
|
|
||||||
});
|
|
||||||
it('updateTopicPartitionsCount/fulfilled', async () => {
|
it('updateTopicPartitionsCount/fulfilled', async () => {
|
||||||
fetchMock.patchOnce(
|
fetchMock.patchOnce(
|
||||||
`/api/clusters/${clusterName}/topics/${topicName}/partitions`,
|
`/api/clusters/${clusterName}/topics/${topicName}/partitions`,
|
||||||
|
|
|
@ -201,11 +201,16 @@ export const updateTopic = createAsyncThunk<
|
||||||
export const deleteTopic = createAsyncThunk<
|
export const deleteTopic = createAsyncThunk<
|
||||||
{ topicName: TopicName },
|
{ topicName: TopicName },
|
||||||
DeleteTopicRequest
|
DeleteTopicRequest
|
||||||
>('topic/deleteTopic', async (payload, { rejectWithValue }) => {
|
>('topic/deleteTopic', async (payload, { rejectWithValue, dispatch }) => {
|
||||||
try {
|
try {
|
||||||
const { topicName } = payload;
|
const { topicName, clusterName } = payload;
|
||||||
await topicsApiClient.deleteTopic(payload);
|
await topicsApiClient.deleteTopic(payload);
|
||||||
|
dispatch(
|
||||||
|
showSuccessAlert({
|
||||||
|
id: `message-${topicName}-${clusterName}`,
|
||||||
|
message: 'Topic successfully deleted!',
|
||||||
|
})
|
||||||
|
);
|
||||||
return { topicName };
|
return { topicName };
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return rejectWithValue(await getResponse(err as Response));
|
return rejectWithValue(await getResponse(err as Response));
|
||||||
|
|
Loading…
Add table
Reference in a new issue