diff options
author | Jeremy Davis <jeremy.davis@sonarsource.com> | 2022-05-30 18:43:36 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-06-01 20:03:02 +0000 |
commit | 14c4a42e54297912ed40e32b6a14081aa62102d8 (patch) | |
tree | 5f92665fd6a13040b85fe24736c759f0cc62ad7e /server | |
parent | 6b96853817dc3c3eb7d71fc71f0ed1ef24d7f2f6 (diff) | |
download | sonarqube-14c4a42e54297912ed40e32b6a14081aa62102d8.tar.gz sonarqube-14c4a42e54297912ed40e32b6a14081aa62102d8.zip |
SONAR-14654 Hide indexation banner after completion
Diffstat (limited to 'server')
2 files changed, 14 insertions, 1 deletions
diff --git a/server/sonar-web/src/main/js/app/components/indexation/IndexationNotification.tsx b/server/sonar-web/src/main/js/app/components/indexation/IndexationNotification.tsx index 52bb015e917..28c9eae4420 100644 --- a/server/sonar-web/src/main/js/app/components/indexation/IndexationNotification.tsx +++ b/server/sonar-web/src/main/js/app/components/indexation/IndexationNotification.tsx @@ -38,6 +38,8 @@ interface State { notificationType?: IndexationNotificationType; } +const COMPLETED_NOTIFICATION_DISPLAY_DURATION = 5000; + export class IndexationNotification extends React.PureComponent<Props, State> { state: State = {}; isSystemAdmin = false; @@ -77,6 +79,11 @@ export class IndexationNotification extends React.PureComponent<Props, State> { notificationType: IndexationNotificationType.Completed }); IndexationNotificationHelper.markCompletedNotificationAsDisplayed(); + + // Hide after some time + setTimeout(() => { + this.refreshNotification(); + }, COMPLETED_NOTIFICATION_DISPLAY_DURATION); } else { this.setState({ notificationType: undefined }); } diff --git a/server/sonar-web/src/main/js/app/components/indexation/__tests__/IndexationNotification-test.tsx b/server/sonar-web/src/main/js/app/components/indexation/__tests__/IndexationNotification-test.tsx index 6367883eaf6..b144dd38fa4 100644 --- a/server/sonar-web/src/main/js/app/components/indexation/__tests__/IndexationNotification-test.tsx +++ b/server/sonar-web/src/main/js/app/components/indexation/__tests__/IndexationNotification-test.tsx @@ -61,7 +61,8 @@ describe('Completed banner', () => { expect(wrapper.state().notificationType).toBe(IndexationNotificationType.Completed); }); - it('should be hidden on refresh once displayed', () => { + it('should be hidden once displayed', () => { + jest.useFakeTimers(); (IndexationNotificationHelper.shouldDisplayCompletedNotification as jest.Mock).mockReturnValueOnce( true ); @@ -74,6 +75,11 @@ describe('Completed banner', () => { expect(wrapper.state().notificationType).toBe(IndexationNotificationType.Completed); expect(IndexationNotificationHelper.markCompletedNotificationAsDisplayed).toHaveBeenCalled(); + + jest.runAllTimers(); + expect(wrapper.state().notificationType).toBeUndefined(); + + jest.useRealTimers(); }); }); |