I18n: Translate Dashboard Starred notification (#59138)
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
import { lastValueFrom } from 'rxjs';
|
import { lastValueFrom } from 'rxjs';
|
||||||
|
|
||||||
|
import { AppEvents } from '@grafana/data';
|
||||||
import { BackendSrvRequest } from '@grafana/runtime';
|
import { BackendSrvRequest } from '@grafana/runtime';
|
||||||
import { appEvents } from 'app/core/app_events';
|
import { appEvents } from 'app/core/app_events';
|
||||||
|
import { t } from 'app/core/internationalization';
|
||||||
import { getBackendSrv } from 'app/core/services/backend_srv';
|
import { getBackendSrv } from 'app/core/services/backend_srv';
|
||||||
import { saveDashboard } from 'app/features/manage-dashboards/state/actions';
|
import { saveDashboard } from 'app/features/manage-dashboards/state/actions';
|
||||||
import { DashboardMeta } from 'app/types';
|
import { DashboardMeta } from 'app/types';
|
||||||
@@ -92,23 +94,27 @@ export class DashboardSrv {
|
|||||||
|
|
||||||
starDashboard(dashboardId: string, isStarred: boolean) {
|
starDashboard(dashboardId: string, isStarred: boolean) {
|
||||||
const backendSrv = getBackendSrv();
|
const backendSrv = getBackendSrv();
|
||||||
let promise;
|
|
||||||
|
|
||||||
if (isStarred) {
|
const request = {
|
||||||
promise = backendSrv.delete('/api/user/stars/dashboard/' + dashboardId).then(() => {
|
showSuccessAlert: false,
|
||||||
return false;
|
url: '/api/user/stars/dashboard/' + dashboardId,
|
||||||
});
|
method: isStarred ? 'DELETE' : 'POST',
|
||||||
} else {
|
};
|
||||||
promise = backendSrv.post('/api/user/stars/dashboard/' + dashboardId).then(() => {
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return promise.then((res: boolean) => {
|
return backendSrv.request(request).then(() => {
|
||||||
if (this.dashboard && this.dashboard.id === dashboardId) {
|
const newIsStarred = !isStarred;
|
||||||
this.dashboard.meta.isStarred = res;
|
|
||||||
|
if (this.dashboard?.id === dashboardId) {
|
||||||
|
this.dashboard.meta.isStarred = newIsStarred;
|
||||||
}
|
}
|
||||||
return res;
|
|
||||||
|
const message = newIsStarred
|
||||||
|
? t('notifications.starred-dashboard', 'Dashboard starred')
|
||||||
|
: t('notifications.unstarred-dashboard', 'Dashboard unstarred');
|
||||||
|
|
||||||
|
appEvents.emit(AppEvents.alertSuccess, [message]);
|
||||||
|
|
||||||
|
return newIsStarred;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -318,6 +318,10 @@
|
|||||||
"news": {
|
"news": {
|
||||||
"title": "Das Neueste aus dem Blog"
|
"title": "Das Neueste aus dem Blog"
|
||||||
},
|
},
|
||||||
|
"notifications": {
|
||||||
|
"starred-dashboard": "",
|
||||||
|
"unstarred-dashboard": ""
|
||||||
|
},
|
||||||
"panel": {
|
"panel": {
|
||||||
"header-menu": {
|
"header-menu": {
|
||||||
"hide-legend": "",
|
"hide-legend": "",
|
||||||
|
|||||||
@@ -318,6 +318,10 @@
|
|||||||
"news": {
|
"news": {
|
||||||
"title": "Latest from the blog"
|
"title": "Latest from the blog"
|
||||||
},
|
},
|
||||||
|
"notifications": {
|
||||||
|
"starred-dashboard": "Dashboard starred",
|
||||||
|
"unstarred-dashboard": "Dashboard unstarred"
|
||||||
|
},
|
||||||
"panel": {
|
"panel": {
|
||||||
"header-menu": {
|
"header-menu": {
|
||||||
"hide-legend": "Hide legend",
|
"hide-legend": "Hide legend",
|
||||||
|
|||||||
@@ -318,6 +318,10 @@
|
|||||||
"news": {
|
"news": {
|
||||||
"title": "Últimas entradas del blog"
|
"title": "Últimas entradas del blog"
|
||||||
},
|
},
|
||||||
|
"notifications": {
|
||||||
|
"starred-dashboard": "",
|
||||||
|
"unstarred-dashboard": ""
|
||||||
|
},
|
||||||
"panel": {
|
"panel": {
|
||||||
"header-menu": {
|
"header-menu": {
|
||||||
"hide-legend": "",
|
"hide-legend": "",
|
||||||
|
|||||||
@@ -318,6 +318,10 @@
|
|||||||
"news": {
|
"news": {
|
||||||
"title": "Dernières nouvelles sur le blog"
|
"title": "Dernières nouvelles sur le blog"
|
||||||
},
|
},
|
||||||
|
"notifications": {
|
||||||
|
"starred-dashboard": "",
|
||||||
|
"unstarred-dashboard": ""
|
||||||
|
},
|
||||||
"panel": {
|
"panel": {
|
||||||
"header-menu": {
|
"header-menu": {
|
||||||
"hide-legend": "",
|
"hide-legend": "",
|
||||||
|
|||||||
@@ -318,6 +318,10 @@
|
|||||||
"news": {
|
"news": {
|
||||||
"title": "Ŀäŧęşŧ ƒřőm ŧĥę þľőģ"
|
"title": "Ŀäŧęşŧ ƒřőm ŧĥę þľőģ"
|
||||||
},
|
},
|
||||||
|
"notifications": {
|
||||||
|
"starred-dashboard": "Đäşĥþőäřđ şŧäřřęđ",
|
||||||
|
"unstarred-dashboard": "Đäşĥþőäřđ ūʼnşŧäřřęđ"
|
||||||
|
},
|
||||||
"panel": {
|
"panel": {
|
||||||
"header-menu": {
|
"header-menu": {
|
||||||
"hide-legend": "Ħįđę ľęģęʼnđ",
|
"hide-legend": "Ħįđę ľęģęʼnđ",
|
||||||
|
|||||||
@@ -318,6 +318,10 @@
|
|||||||
"news": {
|
"news": {
|
||||||
"title": "最新博客"
|
"title": "最新博客"
|
||||||
},
|
},
|
||||||
|
"notifications": {
|
||||||
|
"starred-dashboard": "",
|
||||||
|
"unstarred-dashboard": ""
|
||||||
|
},
|
||||||
"panel": {
|
"panel": {
|
||||||
"header-menu": {
|
"header-menu": {
|
||||||
"hide-legend": "",
|
"hide-legend": "",
|
||||||
|
|||||||
Reference in New Issue
Block a user