aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/app/components/SystemAnnouncement.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/app/components/SystemAnnouncement.tsx')
-rw-r--r--server/sonar-web/src/main/js/app/components/SystemAnnouncement.tsx26
1 files changed, 18 insertions, 8 deletions
diff --git a/server/sonar-web/src/main/js/app/components/SystemAnnouncement.tsx b/server/sonar-web/src/main/js/app/components/SystemAnnouncement.tsx
index dd0abf833ea..89e23b08ce6 100644
--- a/server/sonar-web/src/main/js/app/components/SystemAnnouncement.tsx
+++ b/server/sonar-web/src/main/js/app/components/SystemAnnouncement.tsx
@@ -22,7 +22,11 @@ import { isEmpty, keyBy } from 'lodash';
import * as React from 'react';
import { getValues } from '../../api/settings';
import { Alert } from '../../components/ui/Alert';
+import { Feature } from '../../types/features';
import { GlobalSettingKeys, SettingValue } from '../../types/settings';
+import withAvailableFeatures, {
+ WithAvailableFeaturesProps
+} from './available-features/withAvailableFeatures';
import './SystemAnnouncement.css';
interface State {
@@ -30,29 +34,33 @@ interface State {
message: string;
}
-export default class SystemAnnouncement extends React.PureComponent<{}, State> {
+export class SystemAnnouncement extends React.PureComponent<WithAvailableFeaturesProps, State> {
state: State = { displayMessage: false, message: '' };
componentDidMount() {
- this.getSettings();
- document.addEventListener('visibilitychange', this.handleVisibilityChange);
+ if (this.props.hasFeature(Feature.Announcement)) {
+ this.getSettings();
+ document.addEventListener('visibilitychange', this.handleVisibilityChange);
+ }
}
componentWillUnmount() {
- document.removeEventListener('visibilitychange', this.handleVisibilityChange);
+ if (this.props.hasFeature(Feature.Announcement)) {
+ document.removeEventListener('visibilitychange', this.handleVisibilityChange);
+ }
}
getSettings = async () => {
const values: SettingValue[] = await getValues({
- keys: [GlobalSettingKeys.DisplaySystemMessage, GlobalSettingKeys.SystemMessage]
+ keys: [GlobalSettingKeys.DisplayAnnouncementMessage, GlobalSettingKeys.AnnouncementMessage]
});
const settings = keyBy(values, 'key');
this.setState({
- displayMessage: settings[GlobalSettingKeys.DisplaySystemMessage].value === 'true',
+ displayMessage: settings[GlobalSettingKeys.DisplayAnnouncementMessage].value === 'true',
message:
- (settings[GlobalSettingKeys.SystemMessage] &&
- settings[GlobalSettingKeys.SystemMessage].value) ||
+ (settings[GlobalSettingKeys.AnnouncementMessage] &&
+ settings[GlobalSettingKeys.AnnouncementMessage].value) ||
''
});
};
@@ -82,3 +90,5 @@ export default class SystemAnnouncement extends React.PureComponent<{}, State> {
);
}
}
+
+export default withAvailableFeatures(SystemAnnouncement);