-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send and receive explicit restoration events #1673
Changes from 15 commits
7386060
12dc38a
ee4a77e
218a020
0fe29d1
9f5e046
eeec28c
be64fab
2fea19d
b192c0a
eb877a3
fe41e7b
e55d06a
37b6681
02990a7
44bea21
3abf8ea
0afb270
0a89342
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { createSlice } from '@reduxjs/toolkit'; | ||
import { maybeUpdateInstanceHealth } from './instances'; | ||
import { upsertInstances, maybeUpdateInstanceHealth } from './instances'; | ||
|
||
const initialState = { | ||
loading: false, | ||
|
@@ -27,8 +27,11 @@ export const databasesListSlice = createSlice({ | |
appendDatabase: (state, action) => { | ||
state.databases = [...state.databases, action.payload]; | ||
}, | ||
appendDatabaseInstance: (state, action) => { | ||
state.databaseInstances = [...state.databaseInstances, action.payload]; | ||
upsertDatabaseInstances: (state, action) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really like this now. |
||
state.databaseInstances = upsertInstances( | ||
state.databaseInstances, | ||
action.payload | ||
); | ||
}, | ||
removeDatabase: (state, { payload: { id } }) => { | ||
state.databases = state.databases.filter( | ||
|
@@ -101,6 +104,7 @@ export const databasesListSlice = createSlice({ | |
|
||
export const DATABASE_REGISTERED = 'DATABASE_REGISTERED'; | ||
export const DATABASE_DEREGISTERED = 'DATABASE_DEREGISTERED'; | ||
export const DATABASE_RESTORED = 'DATABASE_RESTORED'; | ||
export const DATABASE_HEALTH_CHANGED = 'DATABASE_HEALTH_CHANGED'; | ||
export const DATABASE_INSTANCE_REGISTERED = 'DATABASE_INSTANCE_REGISTERED'; | ||
export const DATABASE_INSTANCE_DEREGISTERED = 'DATABASE_INSTANCE_DEREGISTERED'; | ||
|
@@ -116,7 +120,7 @@ export const { | |
appendDatabase, | ||
removeDatabase, | ||
removeDatabaseInstance, | ||
appendDatabaseInstance, | ||
upsertDatabaseInstances, | ||
updateDatabaseHealth, | ||
updateDatabaseInstanceHealth, | ||
updateDatabaseInstanceSystemReplication, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
import { put, takeEvery } from 'redux-saga/effects'; | ||
|
||
import { notify } from '@state/actions/notifications'; | ||
import { CLUSTER_DEREGISTERED, removeCluster } from '@state/clusters'; | ||
import { | ||
CLUSTER_DEREGISTERED, | ||
CLUSTER_RESTORED, | ||
appendCluster, | ||
removeCluster, | ||
} from '@state/clusters'; | ||
|
||
export function* clusterDeregistered({ payload: { name, id } }) { | ||
yield put(removeCluster({ id })); | ||
|
@@ -13,6 +18,20 @@ export function* clusterDeregistered({ payload: { name, id } }) { | |
); | ||
} | ||
|
||
export function* clusterRestored({ payload }) { | ||
yield put(appendCluster(payload)); | ||
yield put( | ||
notify({ | ||
text: `Cluster, ${payload.name}, has been restored.`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @abravosuse Do we want to use this notifications with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd remove the |
||
icon: 'ℹ️', | ||
}) | ||
); | ||
} | ||
|
||
export function* watchClusterDeregistered() { | ||
yield takeEvery(CLUSTER_DEREGISTERED, clusterDeregistered); | ||
} | ||
|
||
export function* watchClusterRestored() { | ||
yield takeEvery(CLUSTER_RESTORED, clusterRestored); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,14 @@ import { put, select, takeEvery } from 'redux-saga/effects'; | |
import { | ||
DATABASE_REGISTERED, | ||
DATABASE_DEREGISTERED, | ||
DATABASE_RESTORED, | ||
DATABASE_HEALTH_CHANGED, | ||
DATABASE_INSTANCE_REGISTERED, | ||
DATABASE_INSTANCE_DEREGISTERED, | ||
DATABASE_INSTANCE_HEALTH_CHANGED, | ||
DATABASE_INSTANCE_SYSTEM_REPLICATION_CHANGED, | ||
appendDatabase, | ||
appendDatabaseInstance, | ||
upsertDatabaseInstances, | ||
updateDatabaseHealth, | ||
updateDatabaseInstanceHealth, | ||
updateDatabaseInstanceSystemReplication, | ||
|
@@ -17,7 +18,7 @@ import { | |
} from '@state/databases'; | ||
|
||
import { | ||
appendDatabaseInstanceToSapSystem, | ||
upsertDatabaseInstancesToSapSystem, | ||
removeDatabaseInstanceFromSapSystem, | ||
updateSAPSystemDatabaseInstanceHealth, | ||
updateSAPSystemDatabaseInstanceSystemReplication, | ||
|
@@ -50,8 +51,8 @@ function* databaseHealthChanged({ payload }) { | |
} | ||
|
||
function* databaseInstanceRegistered({ payload }) { | ||
yield put(appendDatabaseInstance(payload)); | ||
yield put(appendDatabaseInstanceToSapSystem(payload)); | ||
yield put(upsertDatabaseInstances([payload])); | ||
yield put(upsertDatabaseInstancesToSapSystem([payload])); | ||
yield put( | ||
notify({ | ||
text: `A new Database instance, ${payload.sid}, has been discovered.`, | ||
|
@@ -70,6 +71,17 @@ export function* databaseDeregistered({ payload }) { | |
); | ||
} | ||
|
||
export function* databaseRestored({ payload }) { | ||
yield put(appendDatabase(payload)); | ||
yield put(upsertDatabaseInstances(payload.database_instances)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we need |
||
yield put( | ||
notify({ | ||
text: `The database ${payload.sid} has been restored.`, | ||
icon: 'ℹ️', | ||
}) | ||
); | ||
} | ||
|
||
export function* databaseInstanceDeregistered({ payload }) { | ||
yield put(removeDatabaseInstance(payload)); | ||
yield put(removeDatabaseInstanceFromSapSystem(payload)); | ||
|
@@ -94,6 +106,7 @@ function* databaseInstanceSystemReplicationChanged({ payload }) { | |
export function* watchDatabase() { | ||
yield takeEvery(DATABASE_REGISTERED, databaseRegistered); | ||
yield takeEvery(DATABASE_DEREGISTERED, databaseDeregistered); | ||
yield takeEvery(DATABASE_RESTORED, databaseRestored); | ||
yield takeEvery(DATABASE_HEALTH_CHANGED, databaseHealthChanged); | ||
yield takeEvery(DATABASE_INSTANCE_REGISTERED, databaseInstanceRegistered); | ||
yield takeEvery(DATABASE_INSTANCE_DEREGISTERED, databaseInstanceDeregistered); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why a new line after this?