cleaned up some debug code w/ burnettk

This commit is contained in:
jasquat 2022-12-30 15:30:32 -05:00
parent 9058a27b10
commit 3506b19f66
4 changed files with 14 additions and 74 deletions

View File

@ -14,7 +14,6 @@ import { ErrorForDisplay } from './interfaces';
import { AbilityContext } from './contexts/Can';
import UserService from './services/UserService';
import { Notification } from './components/Notification';
import ErrorDisplay from './components/ErrorDisplay';
export default function App() {
@ -32,52 +31,6 @@ export default function App() {
const ability = defineAbility(() => {});
// let errorTag = null;
// if (errorObject) {
// let sentryLinkTag = null;
// if (errorObject.sentry_link) {
// sentryLinkTag = (
// <span>
// {
// ': Find details about this error here (it may take a moment to become available): '
// }
// <a href={errorObject.sentry_link} target="_blank" rel="noreferrer">
// {errorObject.sentry_link}
// </a>
// </span>
// );
// }
//
// let message = <div>{errorObject.message}</div>;
// let title = 'Error:';
// if ('task_name' in errorObject && errorObject.task_name) {
// title = 'Error in python script:';
// message = (
// <>
// <br />
// <div>
// Task: {errorObject.task_name} ({errorObject.task_id})
// </div>
// <div>File name: {errorObject.file_name}</div>
// <div>Line number in script task: {errorObject.line_number}</div>
// <br />
// <div>{errorObject.message}</div>
// </>
// );
// }
//
// errorTag = (
// <Notification
// title={title}
// onClose={() => setErrorObject(null)}
// type="error"
// >
// {message}
// {sentryLinkTag}
// </Notification>
// );
// }
return (
<div className="cds--white">
{/* @ts-ignore */}

View File

@ -1,5 +1,5 @@
import { useContext } from 'react';
import ErrorContext from 'src/contexts/ErrorContext';
import ErrorContext from '../contexts/ErrorContext';
import { Notification } from './Notification';
export default function ErrorDisplay() {

View File

@ -35,14 +35,6 @@ export const usePermissionFetcher = (
}
});
ability.update(rules);
console.log('SETTING PERMISSIONS');
const thePERMMap = (ability as any).j;
console.log(
'thePERMMAP',
thePERMMap.get(
'/v1.0/process-models/misc:category_number_one:workflow_one/files'
)
);
setPermissionsLoaded(true);
};
if (Object.keys(permissionsToCheck).length !== 0) {
@ -55,5 +47,5 @@ export const usePermissionFetcher = (
}
});
return { ability, permissionsLoaded, setPermissionsLoaded };
return { ability, permissionsLoaded };
};

View File

@ -73,8 +73,9 @@ export default function ProcessModelShow() {
[targetUris.processInstanceCreatePath]: ['POST'],
[targetUris.processModelFileCreatePath]: ['POST', 'PUT', 'GET', 'DELETE'],
};
const { ability, permissionsLoaded, setPermissionsLoaded } =
usePermissionFetcher(permissionRequestData);
const { ability, permissionsLoaded } = usePermissionFetcher(
permissionRequestData
);
const modifiedProcessModelId = modifyProcessIdentifierForPathParam(
`${params.process_model_id}`
@ -231,12 +232,17 @@ export default function ProcessModelShow() {
isPrimaryBpmnFile: boolean
) => {
const elements = [];
// So there is a bug in here. Since we use a react context for error messages, and since
// its provider wraps the entire app, child components will re-render when there is an
// error displayed. This is normally fine, but it interacts badly with the casl ability.can
// functionality. We have observed that permissionsLoaded is never set to false. So when
// you run a process and it fails, for example, process model show will re-render, the ability
// will be cleared out and it will start fetching permissions from the server, but this
// component still thinks permissionsLoaded is telling the truth (it says true, but it's actually false).
// The only bad effect that we know of is that the Edit icon becomes an eye icon even for admins.
let icon = View;
let actionWord = 'View';
console.log(
'targetUris.processModelFileCreatePath',
targetUris.processModelFileCreatePath
);
if (ability.can('PUT', targetUris.processModelFileCreatePath)) {
icon = Edit;
actionWord = 'Edit';
@ -309,17 +315,6 @@ export default function ProcessModelShow() {
if (!processModel || !permissionsLoaded) {
return null;
}
const permLoad = JSON.stringify(permissionsLoaded);
console.log('permLoad', permLoad);
const theMap = (ability as any).j;
// console.log('theMap', theMap[targetUris.processModelFileCreatePath]);
// console.log('theMap', theMap);
console.log(
'theMap',
theMap.get(
'/v1.0/process-models/misc:category_number_one:workflow_one/files'
)
);
let constructedTag;
const tags = processModel.files.map((processModelFile: ProcessFile) => {
const isPrimaryBpmnFile =