mirror of
https://github.com/grafana/grafana.git
synced 2025-01-24 15:27:01 -06:00
431f454d57
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Resolve type errors resulted from merge
* Part2: Unicons implementation (#23266)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and empty list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Icons update
* Add optional chaining to for isFontAwesome variable
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Part3: Unicons implementation (#23356)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and empty list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Update icons in Explore
* Update icons in alerting
* Update + and x buttons
* Update icons in configurations and settings
* Update close icons
* Update icons in rich history
* Update alert messages
* Add optional chaining to for isFontAwesome variable
* Remove icon mock, set up jest.config
* Fix navbar plus icon
* Fir enable-bacground to enableBackgournd
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Merge remote branch origin master to icons-unicons
* Revert "Merge remote branch origin master to icons-unicons"
This reverts commit 3f25d50a39
.
* Size-up dashnav icons
* Fix alerting icons, panel headers, update tests
* Fix typecheck error
* Adjustments - add panel icon, spacing
* Set TerserPlugin sourceMap to false to prevent running out of memory when publishing storybook
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
135 lines
4.0 KiB
TypeScript
135 lines
4.0 KiB
TypeScript
import React, { PureComponent } from 'react';
|
|
import { hot } from 'react-hot-loader';
|
|
import { connect } from 'react-redux';
|
|
import Page from 'app/core/components/Page/Page';
|
|
import { Tooltip, Icon } from '@grafana/ui';
|
|
import { NavModel } from '@grafana/data';
|
|
import { SlideDown } from 'app/core/components/Animations/SlideDown';
|
|
import { getNavModel } from 'app/core/selectors/navModel';
|
|
import { StoreState, FolderState } from 'app/types';
|
|
import { DashboardAcl, PermissionLevel, NewDashboardAclItem } from 'app/types/acl';
|
|
import {
|
|
getFolderByUid,
|
|
getFolderPermissions,
|
|
updateFolderPermission,
|
|
removeFolderPermission,
|
|
addFolderPermission,
|
|
} from './state/actions';
|
|
import { getLoadingNav } from './state/navModel';
|
|
import PermissionList from 'app/core/components/PermissionList/PermissionList';
|
|
import AddPermission from 'app/core/components/PermissionList/AddPermission';
|
|
import PermissionsInfo from 'app/core/components/PermissionList/PermissionsInfo';
|
|
|
|
export interface Props {
|
|
navModel: NavModel;
|
|
folderUid: string;
|
|
folder: FolderState;
|
|
getFolderByUid: typeof getFolderByUid;
|
|
getFolderPermissions: typeof getFolderPermissions;
|
|
updateFolderPermission: typeof updateFolderPermission;
|
|
removeFolderPermission: typeof removeFolderPermission;
|
|
addFolderPermission: typeof addFolderPermission;
|
|
}
|
|
|
|
export interface State {
|
|
isAdding: boolean;
|
|
}
|
|
|
|
export class FolderPermissions extends PureComponent<Props, State> {
|
|
constructor(props: Props) {
|
|
super(props);
|
|
|
|
this.state = {
|
|
isAdding: false,
|
|
};
|
|
}
|
|
|
|
componentDidMount() {
|
|
this.props.getFolderByUid(this.props.folderUid);
|
|
this.props.getFolderPermissions(this.props.folderUid);
|
|
}
|
|
|
|
onOpenAddPermissions = () => {
|
|
this.setState({ isAdding: true });
|
|
};
|
|
|
|
onRemoveItem = (item: DashboardAcl) => {
|
|
this.props.removeFolderPermission(item);
|
|
};
|
|
|
|
onPermissionChanged = (item: DashboardAcl, level: PermissionLevel) => {
|
|
this.props.updateFolderPermission(item, level);
|
|
};
|
|
|
|
onAddPermission = (newItem: NewDashboardAclItem) => {
|
|
return this.props.addFolderPermission(newItem);
|
|
};
|
|
|
|
onCancelAddPermission = () => {
|
|
this.setState({ isAdding: false });
|
|
};
|
|
|
|
render() {
|
|
const { navModel, folder } = this.props;
|
|
const { isAdding } = this.state;
|
|
|
|
if (folder.id === 0) {
|
|
return (
|
|
<Page navModel={navModel}>
|
|
<Page.Contents isLoading={true}>
|
|
<span />
|
|
</Page.Contents>
|
|
</Page>
|
|
);
|
|
}
|
|
|
|
const folderInfo = { title: folder.title, url: folder.url, id: folder.id };
|
|
|
|
return (
|
|
<Page navModel={navModel}>
|
|
<Page.Contents>
|
|
<div className="page-action-bar">
|
|
<h3 className="page-sub-heading">Folder Permissions</h3>
|
|
<Tooltip placement="auto" content={<PermissionsInfo />}>
|
|
<Icon className="icon--has-hover page-sub-heading-icon" name="question-circle" />
|
|
</Tooltip>
|
|
<div className="page-action-bar__spacer" />
|
|
<button className="btn btn-primary pull-right" onClick={this.onOpenAddPermissions} disabled={isAdding}>
|
|
Add Permission
|
|
</button>
|
|
</div>
|
|
<SlideDown in={isAdding}>
|
|
<AddPermission onAddPermission={this.onAddPermission} onCancel={this.onCancelAddPermission} />
|
|
</SlideDown>
|
|
<PermissionList
|
|
items={folder.permissions}
|
|
onRemoveItem={this.onRemoveItem}
|
|
onPermissionChanged={this.onPermissionChanged}
|
|
isFetching={false}
|
|
folderInfo={folderInfo}
|
|
/>
|
|
</Page.Contents>
|
|
</Page>
|
|
);
|
|
}
|
|
}
|
|
|
|
const mapStateToProps = (state: StoreState) => {
|
|
const uid = state.location.routeParams.uid;
|
|
return {
|
|
navModel: getNavModel(state.navIndex, `folder-permissions-${uid}`, getLoadingNav(1)),
|
|
folderUid: uid,
|
|
folder: state.folder,
|
|
};
|
|
};
|
|
|
|
const mapDispatchToProps = {
|
|
getFolderByUid,
|
|
getFolderPermissions,
|
|
updateFolderPermission,
|
|
removeFolderPermission,
|
|
addFolderPermission,
|
|
};
|
|
|
|
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(FolderPermissions));
|