Skip to content

Commit

Permalink
Revert changes to DatasetAlerts.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
ekraffmiller committed Jun 29, 2024
1 parent 23fad9a commit a0b155c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
16 changes: 6 additions & 10 deletions src/sections/dataset/Dataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { BreadcrumbsGenerator } from '../shared/hierarchy/BreadcrumbsGenerator'
import { useAlertContext } from '../alerts/AlertContext'
import { AlertMessageKey } from '../../alert/domain/models/Alert'
import { DatasetRepository } from '../../dataset/domain/repositories/DatasetRepository'
import { Alerts } from '../alerts/Alerts'
import { DatasetAlerts } from './dataset-alerts/DatasetAlerts'
import usePollDatasetLocks from './usePollDatasetLocks'

interface DatasetProps {
Expand All @@ -40,9 +40,10 @@ export function Dataset({
const { dataset, isLoading } = useDataset()
const { t } = useTranslation('dataset')
const { hideModal, isModalOpen } = useNotImplementedModal()
const { addDatasetAlert, setDatasetAlerts } = useAlertContext()
const { datasetAlerts, addDatasetAlert, removeDatasetAlert, setDatasetAlerts } = useAlertContext()

if (created) {
console.log('created')
addDatasetAlert({ messageKey: AlertMessageKey.DATASET_CREATED, variant: 'success' })
}

Expand All @@ -54,15 +55,10 @@ export function Dataset({
if (setDatasetAlerts) {
if (publishInProgress) {
console.log('state.publishInProgress', publishInProgress)
setDatasetAlerts([{ messageKey: AlertMessageKey.PUBLISH_IN_PROGRESS, variant: 'info' }])
} else {
console.log('else condition setting alerts')
if (dataset && setDatasetAlerts) {
setDatasetAlerts(dataset.alerts)
}
addDatasetAlert({ messageKey: AlertMessageKey.PUBLISH_IN_PROGRESS, variant: 'info' })
}
}
}, [publishInProgress, dataset, setDatasetAlerts])
}, [publishInProgress, dataset, removeDatasetAlert, addDatasetAlert])

Check warning on line 61 in src/sections/dataset/Dataset.tsx

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'setDatasetAlerts'. Either include it or remove the dependency array

usePollDatasetLocks(publishInProgress, dataset, datasetRepository)

Expand All @@ -82,7 +78,7 @@ export function Dataset({
<div className={styles.container}>
<Row>
<Col>
<Alerts></Alerts>
<DatasetAlerts alerts={datasetAlerts}></DatasetAlerts>
</Col>
</Row>
</div>
Expand Down
5 changes: 3 additions & 2 deletions src/sections/dataset/dataset-alerts/DatasetAlerts.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useAlertContext } from '../../alerts/AlertContext'
import { Alerts } from '../../alerts/Alerts'
import { Alert } from '../../../alert/domain/models/Alert'

Expand All @@ -6,7 +7,7 @@ interface DatasetAlertsProps {
}

export function DatasetAlerts({ alerts }: DatasetAlertsProps) {
console.log('DatasetAlerts', alerts)

const { addDatasetAlert } = useAlertContext()
alerts.forEach((alert) => addDatasetAlert(alert))
return <Alerts></Alerts>
}

0 comments on commit a0b155c

Please sign in to comment.