Account for days in formatter matcher

pull/10616/head
Luke Morris 2017-12-18 15:49:45 -08:00
parent df75b96116
commit bf21fde425
3 changed files with 58 additions and 12 deletions

View File

@ -208,8 +208,27 @@ export const removeDatabaseDeleteCode = database => ({
},
})
export const editRetentionPolicy = (database, retentionPolicy, updates) => ({
type: 'INFLUXDB_EDIT_RETENTION_POLICY',
export const editRetentionPolicyRequested = (
database,
retentionPolicy,
updates
) => ({
type: 'INFLUXDB_EDIT_RETENTION_POLICY_REQUESTED',
payload: {
database,
retentionPolicy,
updates,
},
})
export const editRetentionPolicyCompleted = syncRetentionPolicy
export const editRetentionPolicyFailed = (
database,
retentionPolicy,
updates
) => ({
type: 'INFLUXDB_EDIT_RETENTION_POLICY_FAILED',
payload: {
database,
retentionPolicy,
@ -334,23 +353,21 @@ export const createRetentionPolicyAsync = (
export const updateRetentionPolicyAsync = (
database,
retentionPolicy,
updates
oldRP,
newRP
) => async dispatch => {
try {
dispatch(editRetentionPolicy(database, retentionPolicy, updates))
const {data} = await updateRetentionPolicyAJAX(
retentionPolicy.links.self,
updates
)
dispatch(editRetentionPolicyRequested(database, oldRP, newRP))
const {data} = await updateRetentionPolicyAJAX(oldRP.links.self, newRP)
dispatch(editRetentionPolicyCompleted(database, oldRP, data))
dispatch(
publishAutoDismissingNotification(
'success',
'Retention policy updated successfully'
)
)
dispatch(syncRetentionPolicy(database, retentionPolicy, data))
} catch (error) {
dispatch(editRetentionPolicyFailed(database, oldRP))
dispatch(
errorThrown(
error,

View File

@ -164,7 +164,7 @@ const adminInfluxDB = (state = initialState, action) => {
return {...state, ...newState}
}
case 'INFLUXDB_EDIT_RETENTION_POLICY': {
case 'INFLUXDB_EDIT_RETENTION_POLICY_REQUESTED': {
const {database, retentionPolicy, updates} = action.payload
const newState = {
@ -187,6 +187,29 @@ const adminInfluxDB = (state = initialState, action) => {
return {...state, ...newState}
}
case 'INFLUXDB_EDIT_RETENTION_POLICY_FAILED': {
const {database, retentionPolicy} = action.payload
const newState = {
databases: state.databases.map(
db =>
db.links.self === database.links.self
? {
...db,
retentionPolicies: db.retentionPolicies.map(
rp =>
rp.links.self === retentionPolicy.links.self
? {...rp, ...retentionPolicy}
: rp
),
}
: db
),
}
return {...state, ...newState}
}
case 'INFLUXDB_DELETE_USER': {
const {user} = action.payload
const newState = {

View File

@ -137,7 +137,13 @@ export const formatRPDuration = duration => {
let adjustedTime = duration
const durationMatcher = /(?:(\d*)d)?(?:(\d*)h)?(?:(\d*)m)?(?:(\d*)s)?/
const [__, days, hours, minutes, seconds] = duration.match(durationMatcher) // eslint-disable-line no-unused-vars
const [
_match, // eslint-disable-line no-unused-vars
days = 0,
hours = 0,
minutes = 0,
seconds = 0,
] = duration.match(durationMatcher)
const hoursInDay = 24
if (days) {