2019-10-31 08:36:04 +00:00
|
|
|
import React from "react";
|
|
|
|
|
import styled from "styled-components";
|
2019-11-25 05:07:27 +00:00
|
|
|
import StyledHeader from "components/designSystems/appsmith/StyledHeader";
|
2020-05-14 06:06:20 +00:00
|
|
|
import Button from "components/editorComponents/Button";
|
2020-07-17 09:59:28 +00:00
|
|
|
import { EDIT_APP } from "constants/messages";
|
2020-06-17 10:19:56 +00:00
|
|
|
import { isPermitted } from "pages/Applications/permissionHelpers";
|
2019-11-05 05:09:50 +00:00
|
|
|
const HeaderWrapper = styled(StyledHeader)`
|
2019-10-31 08:36:04 +00:00
|
|
|
position: fixed;
|
|
|
|
|
top: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
background: white;
|
2020-05-14 06:06:20 +00:00
|
|
|
display: flex;
|
|
|
|
|
justify-content: flex-end;
|
2019-10-31 08:36:04 +00:00
|
|
|
`;
|
2020-06-17 06:29:09 +00:00
|
|
|
|
|
|
|
|
const StyledButton = styled(Button)`
|
|
|
|
|
max-width: 200px;
|
|
|
|
|
`;
|
2020-05-14 06:06:20 +00:00
|
|
|
type AppViewerHeaderProps = {
|
|
|
|
|
url?: string;
|
2020-06-17 10:19:56 +00:00
|
|
|
permissionRequired: string;
|
|
|
|
|
permissions: string[];
|
2020-05-14 06:06:20 +00:00
|
|
|
};
|
2019-10-31 08:36:04 +00:00
|
|
|
|
|
|
|
|
export const AppViewerHeader = (props: AppViewerHeaderProps) => {
|
2020-06-17 10:19:56 +00:00
|
|
|
const hasPermission = isPermitted(
|
|
|
|
|
props.permissions,
|
|
|
|
|
props.permissionRequired,
|
|
|
|
|
);
|
|
|
|
|
|
2020-05-14 06:06:20 +00:00
|
|
|
return (
|
|
|
|
|
<HeaderWrapper>
|
2020-06-17 10:19:56 +00:00
|
|
|
{props.url && hasPermission && (
|
2020-06-17 06:29:09 +00:00
|
|
|
<StyledButton
|
2020-06-03 10:50:10 +00:00
|
|
|
className="t--back-to-editor"
|
2020-05-14 06:06:20 +00:00
|
|
|
href={props.url}
|
|
|
|
|
intent="primary"
|
|
|
|
|
icon="chevron-left"
|
|
|
|
|
iconAlignment="left"
|
2020-07-17 09:59:28 +00:00
|
|
|
text={EDIT_APP}
|
2020-05-14 06:06:20 +00:00
|
|
|
filled
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</HeaderWrapper>
|
|
|
|
|
);
|
2019-10-31 08:36:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default AppViewerHeader;
|