Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI bugfixes #1422

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/components/routes/manage/workflows/components/Actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,22 +177,30 @@ type EditWorkflowActionProps = {
export const EditWorkflowAction: React.FC<EditWorkflowActionProps> = React.memo(({ id = null, workflow = null }) => {
const { t } = useTranslation(['manageWorkflowDetail']);
const theme = useTheme();
const { user: currentUser } = useALContext();
const { user: currentUser, configuration } = useALContext();
// Editing of workflows aren't allowed if it wasn't created on the current instance
const editingDisabled = workflow?.origin !== configuration.ui.fqdn;
console.log(location);

if (!id || !currentUser.roles.includes('workflow_manage')) return null;
else if (!workflow)
return <Skeleton variant="circular" height="2.5rem" width="2.5rem" style={{ margin: theme.spacing(0.5) }} />;
else
return (
<Tooltip title={t('edit')}>
<Tooltip title={editingDisabled ? t('edit.disabled') : t('edit')}>
<div>
<IconButton
style={{ color: theme.palette.primary.main }}
component={Link}
to={`${location.pathname}${location.search}#/create/${id}`}
to={
location.pathname === '/manage/workflows'
? `/manage/workflows${location.search}#/create/${id}`
: location.pathname.replace('detail', 'create')
}
size="large"
disabled={editingDisabled}
>
<EditOutlinedIcon />
<EditOutlinedIcon color={editingDisabled ? 'disabled' : 'primary'} />
</IconButton>
</div>
</Tooltip>
Expand Down
5 changes: 2 additions & 3 deletions src/components/routes/manage/workflows/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ const WrappedWorkflowCreate = ({ id: propID = null, onClose = () => null }: Prop
const { t } = useTranslation(['manageWorkflowDetail']);
const { id: paramID } = useParams<Params>();
const theme = useTheme();
const classes = useStyles();
const location = useLocation();
const { apiCall } = useMyAPI();
const { c12nDef, configuration, user: currentUser } = useALContext();
Expand Down Expand Up @@ -168,7 +167,7 @@ const WrappedWorkflowCreate = ({ id: propID = null, onClose = () => null }: Prop
);

useEffect(() => {
if (!id || !currentUser.roles.includes('workflow_manage')) return;
if (!id || !currentUser.roles.includes('workflow_manage') || originalWorkflow) return;

apiCall<Workflow>({
url: `/api/v4/workflow/${id}/`,
Expand All @@ -188,7 +187,7 @@ const WrappedWorkflowCreate = ({ id: propID = null, onClose = () => null }: Prop
}
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currentUser.roles, id, onClose]);
}, [currentUser.roles, id, onClose, originalWorkflow]);

useEffect(() => {
setOriginalWorkflow(defaultWorkflow);
Expand Down
2 changes: 1 addition & 1 deletion src/components/routes/submission/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ function WrappedSubmissionDetail() {
{submission ? (
submission.state === 'completed' ? (
<div style={{ display: 'flex' }}>
{currentUser.roles.includes('submission_delete') && (
{(currentUser.roles.includes('administration') || (currentUser.roles.includes('submission_delete') && submission.params.submitter === currentUser.uname)) && (
<Tooltip title={t('delete')}>
<IconButton
onClick={() => setDeleteDialog(true)}
Expand Down
6 changes: 4 additions & 2 deletions src/components/routes/submit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ const Submit = () => {

const state: SubmitState = location.state as SubmitState;
const params = new URLSearchParams(location.search);
const stringInputTitle = t('urlHash.input_title');
const stringInputText = stringInputTitle + t('urlHash.input_suffix');
const stringInputTitle: string = configuration.ui.allow_url_submissions
? `${t('urlHash.input_title_hash')}/${t('urlHash.input_title_url')}`
: t('urlHash.input_title_hash');
const stringInputText: string = stringInputTitle + t('urlHash.input_suffix');

const handleChange = (event, newValue) => {
setValue(newValue);
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en/submit.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"terms3": "Terms of Service",
"urlHash.button": "Scan",
"urlHash.input_suffix": " to Scan",
"urlHash.input_title": "Hash/URL",
"urlHash.input_title_hash": "Hash",
"urlHash.input_title_url": "URL",
"validate.acceptText": "Continue",
"validate.cancelText": "Deselect external services",
"validate.text": "You've enabled URL analysis to the Internet or selected a service outside Assemblyline's infrastructure. Do you want to continue?",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/fr/submit.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"terms3": "Conditions d'utilisation",
"urlHash.button": "Analyser",
"urlHash.input_suffix": " à Analyser",
"urlHash.input_title": "Hachage/URL",
"urlHash.input_title_hash": "Hachage",
"urlHash.input_title_url": "URL",
"validate.acceptText": "Continuer",
"validate.cancelText": "Désélectionner les services externes",
"validate.text": "Vous avez activé l'analyze d'URL sur Internet ou avez selectioné un service à l'extérieur de l'infrastructure d'Assemblyline. Voulez-vous continuez?",
Expand Down