mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
3c6e0e8ef8
* Add and configure eslint-plugin-import * Fix the lint:ts npm command * Autofix + prettier all the files * Manually fix remaining files * Move jquery code in jest-setup to external file to safely reorder imports * Resolve issue caused by circular dependencies within Prometheus * Update .betterer.results * Fix missing // @ts-ignore * ignore iconBundle.ts * Fix missing // @ts-ignore
54 lines
1.7 KiB
TypeScript
54 lines
1.7 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,
|
|
navModel: 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, navModel }: Props) => {
|
|
useEffect(() => {
|
|
getFolderByUid(uid);
|
|
}, [getFolderByUid, uid]);
|
|
|
|
const canListUsers = contextSrv.hasPermission(AccessControlAction.OrgUsersRead);
|
|
const canSetPermissions = contextSrv.hasPermission(AccessControlAction.FoldersPermissionsWrite);
|
|
|
|
return (
|
|
<Page navModel={navModel}>
|
|
<Page.Contents>
|
|
<Permissions
|
|
resource="folders"
|
|
resourceId={uid}
|
|
canListUsers={canListUsers}
|
|
canSetPermissions={canSetPermissions}
|
|
/>
|
|
</Page.Contents>
|
|
</Page>
|
|
);
|
|
};
|
|
|
|
export default connector(AccessControlFolderPermissions);
|