mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
RestoreDashboards: Add link to dashboards browse view (#94000)
* feat: add button * refactor: clean up * feat: add tracking * refactor: change button copy * refactor: add payload to tracking * refactor: add subURL * refactor: user permissions * refactor: group conditions Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com> --------- Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
This commit is contained in:
parent
4224d05934
commit
f92ef0e126
@ -387,7 +387,7 @@ func (s *ServiceImpl) buildDashboardNavLinks(c *contextmodel.ReqContext) []*navt
|
||||
})
|
||||
}
|
||||
|
||||
if s.features.IsEnabled(c.Req.Context(), featuremgmt.FlagDashboardRestoreUI) && c.SignedInUser.GetOrgRole() == org.RoleAdmin {
|
||||
if s.features.IsEnabled(c.Req.Context(), featuremgmt.FlagDashboardRestoreUI) && (c.SignedInUser.GetOrgRole() == org.RoleAdmin || c.IsGrafanaAdmin) {
|
||||
dashboardChildNavs = append(dashboardChildNavs, &navtree.NavLink{
|
||||
Text: "Recently deleted",
|
||||
SubTitle: "Any items listed here for more than 30 days will be automatically deleted.",
|
||||
|
@ -4,11 +4,14 @@ import { useLocation, useParams } from 'react-router-dom-v5-compat';
|
||||
import AutoSizer from 'react-virtualized-auto-sizer';
|
||||
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { reportInteraction } from '@grafana/runtime';
|
||||
import { FilterInput, useStyles2 } from '@grafana/ui';
|
||||
import { config, reportInteraction } from '@grafana/runtime';
|
||||
import { LinkButton, FilterInput, useStyles2 } from '@grafana/ui';
|
||||
import { Page } from 'app/core/components/Page/Page';
|
||||
import { getConfig } from 'app/core/config';
|
||||
import { Trans } from 'app/core/internationalization';
|
||||
import { useDispatch } from 'app/types';
|
||||
|
||||
import { contextSrv } from '../../core/services/context_srv';
|
||||
import { buildNavModel, getDashboardsTabID } from '../folders/state/navModel';
|
||||
import { useSearchStateManager } from '../search/state/SearchStateManager';
|
||||
import { getSearchPlaceholder } from '../search/tempI18nPhrases';
|
||||
@ -81,6 +84,7 @@ const BrowseDashboardsPage = memo(() => {
|
||||
const { data: rootFolder } = useGetFolderQuery('general');
|
||||
let folder = folderDTO ? folderDTO : rootFolder;
|
||||
const { canEditFolders, canEditDashboards, canCreateDashboards, canCreateFolders } = getFolderPermissions(folder);
|
||||
const hasAdminRights = contextSrv.hasRole('Admin') || contextSrv.isGrafanaAdmin;
|
||||
|
||||
const showEditTitle = canEditFolders && folderUID;
|
||||
const canSelect = canEditFolders || canEditDashboards;
|
||||
@ -104,6 +108,12 @@ const BrowseDashboardsPage = memo(() => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleButtonClickToRecentlyDeleted = () => {
|
||||
reportInteraction('grafana_browse_dashboards_page_button_to_recently_deleted', {
|
||||
origin: window.location.pathname === getConfig().appSubUrl + '/dashboards' ? 'Dashboards' : 'Folder view',
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Page
|
||||
navId="dashboards/browse"
|
||||
@ -111,6 +121,15 @@ const BrowseDashboardsPage = memo(() => {
|
||||
onEditTitle={showEditTitle ? onEditTitle : undefined}
|
||||
actions={
|
||||
<>
|
||||
{config.featureToggles.dashboardRestore && config.featureToggles.dashboardRestoreUI && hasAdminRights && (
|
||||
<LinkButton
|
||||
variant="secondary"
|
||||
href={getConfig().appSubUrl + '/dashboard/recently-deleted'}
|
||||
onClick={handleButtonClickToRecentlyDeleted}
|
||||
>
|
||||
<Trans i18nKey="browse-dashboards.actions.button-to-recently-deleted">Recently deleted</Trans>
|
||||
</LinkButton>
|
||||
)}
|
||||
{folderDTO && <FolderActionsButton folder={folderDTO} />}
|
||||
{(canCreateDashboards || canCreateFolders) && (
|
||||
<CreateNewButton
|
||||
|
@ -329,6 +329,9 @@
|
||||
"moving": "Moving...",
|
||||
"new-folder-name-required-phrase": "Folder name is required."
|
||||
},
|
||||
"actions": {
|
||||
"button-to-recently-deleted": "Recently deleted"
|
||||
},
|
||||
"counts": {
|
||||
"alertRule_one": "{{count}} alert rule",
|
||||
"alertRule_other": "{{count}} alert rules",
|
||||
|
@ -329,6 +329,9 @@
|
||||
"moving": "Mővįʼnģ...",
|
||||
"new-folder-name-required-phrase": "Főľđęř ʼnämę įş řęqūįřęđ."
|
||||
},
|
||||
"actions": {
|
||||
"button-to-recently-deleted": "Ŗęčęʼnŧľy đęľęŧęđ"
|
||||
},
|
||||
"counts": {
|
||||
"alertRule_one": "{{count}} äľęřŧ řūľę",
|
||||
"alertRule_other": "{{count}} äľęřŧ řūľęş",
|
||||
|
Loading…
Reference in New Issue
Block a user