Vulcan/packages/vulcan-admin/lib/components/AdminLayout.jsx

34 lines
849 B
React
Raw Normal View History

2019-01-08 16:22:14 +01:00
/**
* @Author: Apollinaire Lecocq <apollinaire>
* @Date: 08-01-19
* @Last modified by: apollinaire
2019-01-09 11:29:25 +01:00
* @Last modified time: 09-01-19
2019-01-08 16:22:14 +01:00
*/
import React from 'react';
2019-01-09 11:29:25 +01:00
import {registerComponent, Components, withAccess} from 'meteor/vulcan:core';
// we need a component to wrap the `withAccess` hoc around something
function EmptyComponent({children}) {
return children;
}
EmptyComponent.displayName = 'EmptyComponent';
const RestrictToAdmins = withAccess({groups: ['admins']})(EmptyComponent);
2019-01-08 16:22:14 +01:00
/**
* A simple component that renders the existing layout and checks wether the currentUser is an admin or not.
*/
2019-01-09 11:29:25 +01:00
function AdminLayout({children}) {
return (
<Components.Layout>
<RestrictToAdmins>{children}</RestrictToAdmins>
</Components.Layout>
);
2019-01-08 16:22:14 +01:00
}
registerComponent({
name: 'AdminLayout',
component: AdminLayout,
});