Skip to content

Commit

Permalink
Fix [Feature sets panel] inconsistent notification upon success/failu…
Browse files Browse the repository at this point in the history
…re (#2490)
  • Loading branch information
illia-prokopchuk committed May 29, 2024
1 parent 61f810e commit 2af3a8a
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 49 deletions.
8 changes: 3 additions & 5 deletions src/actions/featureStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import {
REMOVE_ENTITY,
REMOVE_FEATURE,
REMOVE_FEATURES,
REMOVE_FEATURES_ERROR,
REMOVE_FEATURE_SET,
REMOVE_FEATURE_SETS,
REMOVE_FEATURE_VECTOR,
Expand Down Expand Up @@ -80,6 +79,7 @@ import {
} from '../utils/getUniqueIdentifier'
import { parseFeatureSets } from '../utils/parseFeatureSets'
import { largeResponseCatchHandler } from '../utils/largeResponseCatchHandler'
import { showErrorNotification } from '../utils/notifications.util'

const featureStoreActions = {
createNewFeatureSet: (project, data) => dispatch => {
Expand All @@ -100,7 +100,8 @@ const featureStoreActions = {
? 'You are not permitted to create a feature set.'
: error.message

dispatch(featureStoreActions.createNewFeatureSetFailure(message))
showErrorNotification(dispatch, error, '', message)
dispatch(featureStoreActions.createNewFeatureSetFailure())

throw error
})
Expand Down Expand Up @@ -362,9 +363,6 @@ const featureStoreActions = {
removeFeatures: () => ({
type: REMOVE_FEATURES
}),
removeFeatureStoreError: () => ({
type: REMOVE_FEATURES_ERROR
}),
removeNewFeatureSet: () => ({
type: REMOVE_NEW_FEATURE_SET
}),
Expand Down
7 changes: 0 additions & 7 deletions src/components/FeatureSetsPanel/FeatureSetsPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const FeatureSetsPanel = ({
createNewFeatureSet,
featureStore,
project,
removeFeatureStoreError,
setNewFeatureSetCredentialsAccessKey,
startFeatureSetIngest
}) => {
Expand Down Expand Up @@ -99,10 +98,6 @@ const FeatureSetsPanel = ({

delete data.credentials

if (featureStore.error) {
removeFeatureStoreError()
}

createNewFeatureSet(project, data)
.then(result => {
setConfirmDialog(null)
Expand Down Expand Up @@ -166,13 +161,11 @@ const FeatureSetsPanel = ({
closePanel={closePanel}
confirmDialog={confirmDialog}
disableButtons={disableButtons}
error={featureStore.error}
featureStore={featureStore}
handleSave={handleSave}
handleSaveOnClick={handleSaveOnClick}
loading={featureStore.loading}
project={project}
removeFeatureStoreError={removeFeatureStoreError}
setConfirmDialog={setConfirmDialog}
setDisableButtons={setDisableButtons}
setNewFeatureSetCredentialsAccessKey={setNewFeatureSetCredentialsAccessKey}
Expand Down
18 changes: 1 addition & 17 deletions src/components/FeatureSetsPanel/FeatureSetsPanelView.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import React from 'react'
import PropTypes from 'prop-types'

import Accordion from '../../common/Accordion/Accordion'
import ErrorMessage from '../../common/ErrorMessage/ErrorMessage'
import FeatureSetsPanelDataSource from './FeatureSetsPanelDataSource/FeatureSetsPanelDataSource'
import FeatureSetsPanelSchema from './FeatureSetsPanelSchema/FeatureSetsPanelSchema'
import FeatureSetsPanelTargetStore from './FeatureSetsPanelTargetStore/FeatureSetsPanelTargetStore'
Expand All @@ -41,13 +40,11 @@ const FeatureSetsPanelView = ({
closePanel,
confirmDialog,
disableButtons,
error,
featureStore,
handleSave,
handleSaveOnClick,
loading,
project,
removeFeatureStoreError,
setConfirmDialog,
setDisableButtons,
setNewFeatureSetCredentialsAccessKey,
Expand Down Expand Up @@ -122,16 +119,6 @@ const FeatureSetsPanelView = ({
validation={validation}
/>
<div className="new-item-side-panel__buttons-container">
{error && (
<ErrorMessage
closeError={() => {
if (error) {
removeFeatureStoreError()
}
}}
message={error}
/>
)}
<Button
variant={TERTIARY_BUTTON}
label="Cancel"
Expand Down Expand Up @@ -164,22 +151,19 @@ const FeatureSetsPanelView = ({

FeatureSetsPanelView.defaultProps = {
confirmDialog: null,
defaultData: null,
error: false
defaultData: null
}

FeatureSetsPanelView.propTypes = {
accessKeyRequired: PropTypes.bool.isRequired,
closePanel: PropTypes.func.isRequired,
confirmDialog: PropTypes.shape({ action: PropTypes.string.isRequired }),
disableButtons: PropTypes.shape({}).isRequired,
error: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
featureStore: PropTypes.shape({}).isRequired,
handleSave: PropTypes.func.isRequired,
handleSaveOnClick: PropTypes.func.isRequired,
loading: PropTypes.bool.isRequired,
project: PropTypes.string.isRequired,
removeFeatureStoreError: PropTypes.func.isRequired,
setConfirmDialog: PropTypes.func.isRequired,
setDisableButtons: PropTypes.func.isRequired,
setNewFeatureSetCredentialsAccessKey: PropTypes.func.isRequired,
Expand Down
5 changes: 0 additions & 5 deletions src/components/FeatureStore/FeatureSets/FeatureSets.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const FeatureSets = ({
fetchFeatureSetsTags,
removeFeatureSet,
removeFeatureSets,
removeFeatureStoreError,
removeNewFeatureSet,
updateFeatureStoreData
}) => {
Expand Down Expand Up @@ -275,10 +274,6 @@ const FeatureSets = ({
const closePanel = () => {
setFeatureSetsPanelIsOpen(false)
removeNewFeatureSet()

if (featureStore.error) {
removeFeatureStoreError()
}
}

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ export const featureSetsActionCreator = {
fetchFeatureSetsTags: featureStoreActions.fetchFeatureSetsTags,
removeFeatureSet: featureStoreActions.removeFeatureSet,
removeFeatureSets: featureStoreActions.removeFeatureSets,
removeFeatureStoreError: featureStoreActions.removeFeatureStoreError,
removeNewFeatureSet: featureStoreActions.removeNewFeatureSet,
updateFeatureStoreData: featureStoreActions.updateFeatureStoreData
}
6 changes: 0 additions & 6 deletions src/components/Project/ProjectMonitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import { showErrorNotification } from '../../utils/notifications.util'
import { useNuclioMode } from '../../hooks/nuclioMode.hook'

const ProjectMonitor = ({
featureStore,
fetchNuclioV3ioStreams,
fetchProject,
fetchProjectFunctions,
Expand All @@ -56,7 +55,6 @@ const ProjectMonitor = ({
functionsStore,
nuclioStore,
projectStore,
removeFeatureStoreError,
removeFunctionsError,
removeNewFeatureSet,
removeNewFunction,
Expand Down Expand Up @@ -164,10 +162,6 @@ const ProjectMonitor = ({
const closeFeatureSetPanel = () => {
setCreateFeatureSetPanelIsOpen(false)
removeNewFeatureSet()

if (featureStore.error) {
removeFeatureStoreError()
}
}

const closeFunctionsPanel = () => {
Expand Down
1 change: 0 additions & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,6 @@ export const REMOVE_ENTITIES = 'REMOVE_ENTITIES'
export const REMOVE_ENTITY = 'REMOVE_ENTITY'
export const REMOVE_FEATURE = 'REMOVE_FEATURE'
export const REMOVE_FEATURES = 'REMOVE_FEATURES'
export const REMOVE_FEATURES_ERROR = 'REMOVE_FEATURES_ERROR'
export const REMOVE_FEATURE_SET = 'REMOVE_FEATURE_SET'
export const REMOVE_FEATURE_SETS = 'REMOVE_FEATURE_SETS'
export const REMOVE_FEATURE_VECTOR = 'REMOVE_FEATURE_VECTOR'
Expand Down
7 changes: 0 additions & 7 deletions src/reducers/featureStoreReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import {
REMOVE_ENTITY,
REMOVE_FEATURE,
REMOVE_FEATURES,
REMOVE_FEATURES_ERROR,
REMOVE_FEATURE_SET,
REMOVE_FEATURE_SETS,
REMOVE_FEATURE_VECTOR,
Expand Down Expand Up @@ -155,7 +154,6 @@ const featureStoreReducer = (state = initialState, { type, payload }) => {
case CREATE_NEW_FEATURE_SET_FAILURE:
return {
...state,
error: payload,
loading: false
}
case CREATE_NEW_FEATURE_SET_SUCCESS:
Expand Down Expand Up @@ -663,11 +661,6 @@ const featureStoreReducer = (state = initialState, { type, payload }) => {
loading: false,
error: null
}
case REMOVE_FEATURES_ERROR:
return {
...state,
error: null
}
default:
return state
}
Expand Down

0 comments on commit 2af3a8a

Please sign in to comment.