Skip to content

Commit

Permalink
ui: add published date to preview header
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Garcia Garcia <[email protected]>
  • Loading branch information
miguelgrc committed Apr 26, 2024
1 parent 826e34c commit cb37f86
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 11 deletions.
3 changes: 3 additions & 0 deletions cap/modules/fixtures/schemas/cms-questionnaire.json
Original file line number Diff line number Diff line change
Expand Up @@ -1830,6 +1830,9 @@
"ui:order": ["options", "comments"]
},
"fitting_model": {
"comments": {
"ui:widget": "textarea"
},
"ui:order": ["options", "comments"]
},
"stats": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ const DraftHeader = ({
newText.trim() != "" && updateGeneralTitle(newText)
}
/>
{!canEdit(canAdmin, canUpdate) && <Tag color="gold">READ ONLY</Tag>}
{!canEdit(canAdmin, canUpdate) && (
<Tag color="gold-inverse">Read-only</Tag>
)}
</Space>
<Space size="middle">
{!screens.lg && (
Expand Down
44 changes: 39 additions & 5 deletions ui/cap-react/src/antd/published/components/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,27 @@ import { transformSchema } from "../../partials/Utils/schema";
import { COLLECTION_BASE } from "../../routes";
import { shouldDisplayTabButton } from "../utils";
import SideBar from "./SideBar";
import { EditOutlined } from "@ant-design/icons";
import { Space, Tag, Button, Row, Col, Radio, Grid, Layout } from "antd";
import {
EditOutlined,
ExportOutlined,
InfoCircleOutlined,
} from "@ant-design/icons";
import {
Space,
Tag,
Button,
Row,
Col,
Radio,
Grid,
Layout,
Tooltip,
} from "antd";
import { PageHeader } from "@ant-design/pro-layout";
import PropTypes from "prop-types";
import { useState } from "react";
import { Link } from "react-router-dom";
import dayjs from "dayjs";

const Preview = ({
history,
Expand All @@ -21,6 +36,7 @@ const Preview = ({
id,
metadata = { general_title: "" },
schemas = { schema: {}, uiSchema: {} },
updated,
}) => {
const [display, setDisplay] = useState(
schemas.uiSchema["ui:object"] == "tabView" ? "tabView" : "list"
Expand All @@ -39,19 +55,36 @@ const Preview = ({
<Space direction="vertical">
{metadata.general_title}
<Space style={{ width: "100%" }} wrap>
<Tag color="purple">Published</Tag>
<Tag>{id}</Tag>
<Tag bordered={false} color="purple-inverse">
Published
</Tag>
<Tag bordered={false} color="magenta">
{id}
</Tag>
{schemaType && (
<Link
to={`${COLLECTION_BASE}/${schemaType.name}/${
schemaType.version || ""
}`}
>
<Tag color="geekblue">
<Tag
bordered={false}
color="geekblue"
icon={<ExportOutlined />}
>
{schemaType.fullname} v{schemaType.version}
</Tag>
</Link>
)}
<Tooltip
title={`Last publication: ${dayjs(updated).format(
"DD/MM/YYYY HH:mm:ss"
)}`}
>
<Tag bordered={false} icon={<InfoCircleOutlined />}>
{dayjs(updated).format("DD/MM/YYYY")}
</Tag>
</Tooltip>
</Space>
</Space>
}
Expand Down Expand Up @@ -146,6 +179,7 @@ Preview.propTypes = {
canUpdate: PropTypes.bool,
files: PropTypes.object,
status: PropTypes.string,
updated: PropTypes.string,
};

export default Preview;
8 changes: 3 additions & 5 deletions ui/cap-react/src/antd/published/containers/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ const mapStateToProps = state => ({
files: state.published.get("files"),
schemas: state.published.get("schemas"),
schemaType: state.published.get("schema"),
status: state.published.get("status")
status: state.published.get("status"),
updated: state.published.get("updated"),
});

const mapDispatchToProps = {};

export default connect(
mapStateToProps,
mapDispatchToProps
)(Preview);
export default connect(mapStateToProps, mapDispatchToProps)(Preview);

0 comments on commit cb37f86

Please sign in to comment.