mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 00:25:46 -06:00
* First stab at new page layouts behind feature toggle * Simplifying PageHeader * Progress on a new model that can more easily support new and old page layouts * Progress * rename folder * Progress * Minor change * fixes * Fixing tests * Make breadcrumbs work * Add tests for old Page component * Adding tests for new Page component and behavior * fixing page header test * Fixed test * Moving user profile routes to navId * PageLayouts: Updates dashboards routes with navId * added missing navId * AppChrome outside route * Renaming folder * Minor fix * Updated * Fixing StoragePage * Updated * Updating translation ids * Updated snapshot * update nav translation ids (yes this is confusing) Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com> Co-authored-by: joshhunt <josh@trtr.co>
48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
import React, { useEffect } from 'react';
|
|
import { connect, ConnectedProps } from 'react-redux';
|
|
|
|
import { Permissions } from 'app/core/components/AccessControl';
|
|
import { Page } from 'app/core/components/Page/Page';
|
|
import { contextSrv } from 'app/core/core';
|
|
import { GrafanaRouteComponentProps } from 'app/core/navigation/types';
|
|
import { getNavModel } from 'app/core/selectors/navModel';
|
|
import { AccessControlAction, StoreState } from 'app/types';
|
|
|
|
import { getFolderByUid } from './state/actions';
|
|
import { getLoadingNav } from './state/navModel';
|
|
|
|
interface RouteProps extends GrafanaRouteComponentProps<{ uid: string }> {}
|
|
|
|
function mapStateToProps(state: StoreState, props: RouteProps) {
|
|
const uid = props.match.params.uid;
|
|
return {
|
|
uid: uid,
|
|
pageNav: getNavModel(state.navIndex, `folder-permissions-${uid}`, getLoadingNav(1)),
|
|
};
|
|
}
|
|
|
|
const mapDispatchToProps = {
|
|
getFolderByUid,
|
|
};
|
|
|
|
const connector = connect(mapStateToProps, mapDispatchToProps);
|
|
export type Props = ConnectedProps<typeof connector>;
|
|
|
|
export const AccessControlFolderPermissions = ({ uid, getFolderByUid, pageNav }: Props) => {
|
|
useEffect(() => {
|
|
getFolderByUid(uid);
|
|
}, [getFolderByUid, uid]);
|
|
|
|
const canSetPermissions = contextSrv.hasPermission(AccessControlAction.FoldersPermissionsWrite);
|
|
|
|
return (
|
|
<Page navId="dashboards/browse" pageNav={pageNav.main}>
|
|
<Page.Contents>
|
|
<Permissions resource="folders" resourceId={uid} canSetPermissions={canSetPermissions} />
|
|
</Page.Contents>
|
|
</Page>
|
|
);
|
|
};
|
|
|
|
export default connector(AccessControlFolderPermissions);
|