From: Stas Vilchik Date: Fri, 12 Aug 2016 08:23:57 +0000 (+0200) Subject: SONAR-7919 remove old key from recent history X-Git-Tag: 6.1-RC1~412 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9ae5317b5e30245dd85b88723af06c995816d406;p=sonarqube.git SONAR-7919 remove old key from recent history --- diff --git a/server/sonar-web/src/main/js/apps/project-admin/key/BulkUpdate.js b/server/sonar-web/src/main/js/apps/project-admin/key/BulkUpdate.js index 10524a81dcd..e872b567c58 100644 --- a/server/sonar-web/src/main/js/apps/project-admin/key/BulkUpdate.js +++ b/server/sonar-web/src/main/js/apps/project-admin/key/BulkUpdate.js @@ -30,6 +30,7 @@ import { closeAllGlobalMessages } from '../../../components/store/globalMessages'; import { reloadUpdateKeyPage } from './utils'; +import RecentHistory from '../../../main/nav/component/RecentHistory'; class BulkUpdate extends React.Component { static propTypes = { @@ -59,6 +60,10 @@ class BulkUpdate extends React.Component { const result = r.keys.find(result => result.key === component.key); const newComponentKey = result != null ? result.newKey : component.key; + if (newComponentKey !== component.key) { + RecentHistory.remove(component.key); + } + this.props.addGlobalSuccessMessage(translate('update_key.key_updated')); this.setState({ updating: false }); reloadUpdateKeyPage(newComponentKey); diff --git a/server/sonar-web/src/main/js/apps/project-admin/key/Key.js b/server/sonar-web/src/main/js/apps/project-admin/key/Key.js index b7c7b307ef4..609e192b08a 100644 --- a/server/sonar-web/src/main/js/apps/project-admin/key/Key.js +++ b/server/sonar-web/src/main/js/apps/project-admin/key/Key.js @@ -35,6 +35,7 @@ import { } from '../../../components/store/globalMessages'; import { parseError } from '../../code/utils'; import { reloadUpdateKeyPage } from './utils'; +import RecentHistory from '../../../main/nav/component/RecentHistory'; class Key extends React.Component { static propTypes = { @@ -63,6 +64,7 @@ class Key extends React.Component { this.props.addGlobalSuccessMessage(translate('update_key.key_updated')); if (key === this.props.component.key) { + RecentHistory.remove(key); reloadUpdateKeyPage(newKey); } }).catch(e => { diff --git a/server/sonar-web/src/main/js/main/nav/component/RecentHistory.js b/server/sonar-web/src/main/js/main/nav/component/RecentHistory.js index 12fa283cf93..6454cfe8afb 100644 --- a/server/sonar-web/src/main/js/main/nav/component/RecentHistory.js +++ b/server/sonar-web/src/main/js/main/nav/component/RecentHistory.js @@ -57,4 +57,10 @@ export default class RecentHistory { RecentHistory.set(newHistory); } } + + static remove (componentKey) { + const history = RecentHistory.get(); + const newHistory = _.reject(history, entry => entry.key === componentKey); + RecentHistory.set(newHistory); + } }