some permission changes
the team permission in the global state was coming back empty, so am now retrieving the team permissions for file uploads in grain transacitons, also adjusted the bin visualizer to disable the slider and inventory button when they do not have write permissions so they cant even open the transaction window, this should help prevent a case in the possible future where we allow bin transactions to have uploadable files from having a bin shared to them and uploading a file but not being able to create the transaction that it would be linked to thus causing the file to be uploaded to digital ocean, but not connected in our backend to anything
This commit is contained in:
parent
1487c78466
commit
762a630659
4 changed files with 35 additions and 11 deletions
|
|
@ -9,7 +9,7 @@ import {
|
|||
Typography
|
||||
} from "@mui/material";
|
||||
import { useFileControllerAPI, useGlobalState } from "providers";
|
||||
import { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import ErrorIcon from "@mui/icons-material/Error";
|
||||
import CheckCircleOutlineIcon from "@mui/icons-material/CheckCircleOutline";
|
||||
import { getThemeType } from "theme";
|
||||
|
|
@ -25,6 +25,7 @@ interface Props {
|
|||
uniqueID?: string;
|
||||
keys?: string[];
|
||||
types?: string[];
|
||||
hasFilePermission: boolean;
|
||||
}
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => {
|
||||
|
|
@ -53,8 +54,8 @@ const useStyles = makeStyles((theme: Theme) => {
|
|||
});
|
||||
|
||||
export default function FileSelector(props: Props) {
|
||||
const { uploadEnd, uploadStart, uniqueID, toAttach, keys, types } = props;
|
||||
const [{ userTeamPermissions }] = useGlobalState();
|
||||
const { uploadEnd, uploadStart, uniqueID, toAttach, keys, types, hasFilePermission } = props;
|
||||
// const [{ userTeamPermissions }] = useGlobalState();
|
||||
const [fileList, setFileList] = useState<FileList | undefined>();
|
||||
const classes = useStyles();
|
||||
const fileAPI = useFileControllerAPI();
|
||||
|
|
@ -142,7 +143,7 @@ export default function FileSelector(props: Props) {
|
|||
disabled={
|
||||
uploading ||
|
||||
(!uploadFailed && fileID !== "") ||
|
||||
!userTeamPermissions.includes(pond.Permission.PERMISSION_FILE_MANAGEMENT)
|
||||
!hasFilePermission
|
||||
}
|
||||
multiple={false}
|
||||
name={uniqueID || "fileInput"}
|
||||
|
|
@ -163,7 +164,7 @@ export default function FileSelector(props: Props) {
|
|||
<label
|
||||
htmlFor={uniqueID || "fileInput"}
|
||||
className={
|
||||
userTeamPermissions.includes(pond.Permission.PERMISSION_FILE_MANAGEMENT)
|
||||
hasFilePermission
|
||||
? classes.fileSelect
|
||||
: classes.fileDisabled
|
||||
}>
|
||||
|
|
|
|||
|
|
@ -10,19 +10,22 @@ interface Props {
|
|||
uploadEnd: (fileID?: string, fileName?: string) => void;
|
||||
keys?: string[];
|
||||
types?: string[];
|
||||
hasFilePermission: boolean
|
||||
}
|
||||
|
||||
export default function FileUploader(props: Props) {
|
||||
const { uploadStart, uploadEnd, startingSelectorCount, toAttach, keys, types } = props;
|
||||
const { uploadStart, uploadEnd, startingSelectorCount, toAttach, keys, types, hasFilePermission } = props;
|
||||
const [numSelectors, setNumSelectors] = useState(startingSelectorCount || 1);
|
||||
const [selectors, setSelectors] = useState<JSX.Element[]>([]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
let currentSelectors: JSX.Element[] = [];
|
||||
for (let i = 0; i < numSelectors; i++) {
|
||||
currentSelectors.push(
|
||||
<Box key={i} margin={2}>
|
||||
<FileSelector
|
||||
hasFilePermission={hasFilePermission}
|
||||
toAttach={toAttach}
|
||||
keys={keys}
|
||||
types={types}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue