Skip to content

Commit

Permalink
Hide publish based on permissions on code app (#2887)
Browse files Browse the repository at this point in the history
  • Loading branch information
agalin920 authored Jul 30, 2024
1 parent 88613eb commit f3271c2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { Save } from "./Save";
import { Publish } from "./Publish";

import styles from "./EditorActions.less";
import { usePermission } from "../../../../../../../../shell/hooks/use-permissions";
export const EditorActions = memo(function EditorActions(props) {
const canPublish = usePermission("PUBLISH");
return (
<div className={styles.EditorActions}>
<Save
Expand All @@ -13,12 +15,14 @@ export const EditorActions = memo(function EditorActions(props) {
fileType={props.fileType}
status={props.status}
/>
<Publish
dispatch={props.dispatch}
fileZUID={props.fileZUID}
version={props.version}
status={props.status}
/>
{canPublish && (
<Publish
dispatch={props.dispatch}
fileZUID={props.fileZUID}
version={props.version}
status={props.status}
/>
)}
</div>
);
});
25 changes: 16 additions & 9 deletions src/apps/code-editor/src/app/components/FileList/FileList.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faCloudUploadAlt } from "@fortawesome/free-solid-svg-icons";
import { resolvePathPart, publishFile } from "../../../store/files";
import { collapseNavItem } from "../../../store/navCode";

import { usePermission } from "../../../../../../shell/hooks/use-permissions";
import styles from "./FileList.less";
export const FileList = memo(function FileList(props) {
const canPublish = usePermission("PUBLISH");
// const [branch, setBranch] = useState(props.branch);
const [shownFiles, setShownFiles] = useState(
props.navCode.tree.sort(byLabel)
Expand Down Expand Up @@ -47,14 +48,20 @@ export const FileList = memo(function FileList(props) {
};

const actions = [
<FontAwesomeIcon
title="Publish file"
icon={faCloudUploadAlt}
className={styles.Action}
showIcon={true}
available={(file) => !file.isLive}
onClick={(file) => props.dispatch(publishFile(file.ZUID, file.status))}
/>,
...(canPublish
? [
<FontAwesomeIcon
title="Publish file"
icon={faCloudUploadAlt}
className={styles.Action}
showIcon={true}
available={(file) => !file.isLive}
onClick={(file) =>
props.dispatch(publishFile(file.ZUID, file.status))
}
/>,
]
: []),
];

return (
Expand Down

0 comments on commit f3271c2

Please sign in to comment.