forked from openedx/frontend-app-admin-console
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAuthZTitle.tsx
More file actions
68 lines (62 loc) · 1.72 KB
/
AuthZTitle.tsx
File metadata and controls
68 lines (62 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { ComponentType, isValidElement, ReactNode } from 'react';
import { Link } from 'react-router-dom';
import {
Breadcrumb, Col, Container, Row, Button, Badge,
} from '@openedx/paragon';
interface BreadcrumbLink {
label: string;
to?: string;
}
interface Action {
label: string;
icon?: ComponentType;
onClick: () => void;
}
export interface AuthZTitleProps {
activeLabel: string;
pageTitle: string;
pageSubtitle: string | ReactNode;
navLinks?: BreadcrumbLink[];
actions?: (Action | ReactNode)[];
}
const AuthZTitle = ({
activeLabel, navLinks = [], pageTitle, pageSubtitle, actions = [],
}: AuthZTitleProps) => (
<Container className="p-5 bg-light-100">
<Breadcrumb
linkAs={Link}
links={navLinks}
activeLabel={activeLabel}
/>
<Row className="mt-4">
<Col xs={12} md={8} className="mb-4">
<h1 className="text-primary">{pageTitle}</h1>
{typeof pageSubtitle === 'string'
? <h3><Badge className="py-2 px-3 font-weight-normal" variant="light">{pageSubtitle}</Badge></h3>
: pageSubtitle}
</Col>
<Col xs={12} md={4}>
<div className="d-flex justify-content-md-end">
{
actions.map((action) => {
if (isValidElement(action)) {
return action;
}
const { label, icon, onClick } = action as Action;
return (
<Button
key={`authz-header-action-${label}`}
iconBefore={icon}
onClick={onClick}
>
{label}
</Button>
);
})
}
</div>
</Col>
</Row>
</Container>
);
export default AuthZTitle;