Improve version mismatch warning (#469)
This commit is contained in:
parent
4ada990ba4
commit
2fdce0504b
2 changed files with 9 additions and 32 deletions
|
|
@ -3,7 +3,6 @@ from datetime import timedelta
|
|||
import humanize
|
||||
import pytz
|
||||
from django.apps import apps
|
||||
from django.conf import settings
|
||||
from django.utils import timezone
|
||||
from rest_framework import fields, serializers
|
||||
|
||||
|
|
@ -110,25 +109,7 @@ class CurrentOrganizationSerializer(OrganizationSerializer):
|
|||
|
||||
def get_limits(self, obj):
|
||||
user = self.context["request"].user
|
||||
if not settings.OSS_INSTALLATION:
|
||||
return obj.notifications_limit_web_report(user)
|
||||
|
||||
# show a version warning on OSS installations in case backend and frontend are different versions
|
||||
frontend_version = self.context["request"].headers.get("X-OnCall-Plugin-Version")
|
||||
backend_version = settings.VERSION
|
||||
version_warning = {}
|
||||
if backend_version and frontend_version and backend_version != frontend_version:
|
||||
text = (
|
||||
"Version mismatch! Please make sure you have the same versions of the Grafana OnCall plugin "
|
||||
"and Grafana OnCall engine, "
|
||||
"otherwise there could be issues with your Grafana OnCall installation! "
|
||||
f"Current plugin version: {frontend_version}, current engine version: {backend_version}. "
|
||||
"Please see the update instructions: "
|
||||
"https://grafana.com/docs/oncall/latest/open-source/#update-grafana-oncall-oss"
|
||||
)
|
||||
version_warning = {"period_title": "Version mismatch", "show_limits_warning": True, "warning_text": text}
|
||||
|
||||
return version_warning or obj.notifications_limit_web_report(user)
|
||||
return obj.notifications_limit_web_report(user)
|
||||
|
||||
def get_env_status(self, obj):
|
||||
LiveSetting.populate_settings_if_needed()
|
||||
|
|
|
|||
|
|
@ -93,8 +93,14 @@ const DefaultPageLayout: FC<DefaultPageLayoutProps> = observer((props) => {
|
|||
{store.backendLicense === GRAFANA_LICENSE_OSS &&
|
||||
store.backendVersion &&
|
||||
plugin?.version &&
|
||||
store.backendVersion !== plugin?.version && (
|
||||
<Alert className={styles.alert} severity="warning" title={'Version mismatch!'}>
|
||||
store.backendVersion !== plugin?.version &&
|
||||
!getItem(`version_mismatch_${store.backendVersion}_${plugin?.version}`) && (
|
||||
<Alert
|
||||
className={styles.alert}
|
||||
severity="warning"
|
||||
title={'Version mismatch!'}
|
||||
onRemove={getRemoveAlertHandler(`version_mismatch_${store.backendVersion}_${plugin?.version}`)}
|
||||
>
|
||||
Please make sure you have the same versions of the Grafana OnCall plugin and the Grafana OnCall engine,
|
||||
otherwise there could be issues with your Grafana OnCall installation!
|
||||
<br />
|
||||
|
|
@ -107,16 +113,6 @@ const DefaultPageLayout: FC<DefaultPageLayoutProps> = observer((props) => {
|
|||
.
|
||||
</Alert>
|
||||
)}
|
||||
{currentTeam?.limits.show_limits_warning &&
|
||||
currentTeam?.limits.period_title !== 'Version mismatch' && // don't show version mismatch warning twice
|
||||
!getItem(currentTeam.limits.warning_text) && (
|
||||
<Alert
|
||||
className={styles.alert}
|
||||
severity="warning"
|
||||
title={currentTeam?.limits.warning_text}
|
||||
onRemove={getRemoveAlertHandler(currentTeam?.limits.warning_text)}
|
||||
/>
|
||||
)}
|
||||
{Boolean(
|
||||
currentTeam &&
|
||||
currentUser &&
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue