Merge pull request #174 from sartography/bug/filter_on_users
Bug/filter on users
This commit is contained in:
commit
e196295c77
|
@ -15,4 +15,4 @@ if app.config["ENV"] != "production":
|
||||||
app.register_blueprint(proxy_blueprint)
|
app.register_blueprint(proxy_blueprint)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(host="localhost", port=5000)
|
app.run(host="localhost", port=7004)
|
|
@ -52,6 +52,13 @@ permissions:
|
||||||
allowed_permissions: [create, read, update, delete]
|
allowed_permissions: [create, read, update, delete]
|
||||||
uri: /tasks/*
|
uri: /tasks/*
|
||||||
|
|
||||||
|
# Everybody can start all intstances
|
||||||
|
create-test-instances:
|
||||||
|
groups: [ everybody ]
|
||||||
|
users: [ ]
|
||||||
|
allowed_permissions: [ create ]
|
||||||
|
uri: /process-instances/*
|
||||||
|
|
||||||
# Everyone can see everything (all groups, and processes are visible)
|
# Everyone can see everything (all groups, and processes are visible)
|
||||||
read-all-process-groups:
|
read-all-process-groups:
|
||||||
groups: [ everybody ]
|
groups: [ everybody ]
|
||||||
|
|
|
@ -272,6 +272,7 @@ def process_instance_list_for_me(
|
||||||
with_relation_to_me=True,
|
with_relation_to_me=True,
|
||||||
report_columns=report_columns,
|
report_columns=report_columns,
|
||||||
report_filter_by=report_filter_by,
|
report_filter_by=report_filter_by,
|
||||||
|
process_initiator_username=process_initiator_username,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ import {
|
||||||
modifyProcessIdentifierForPathParam,
|
modifyProcessIdentifierForPathParam,
|
||||||
refreshAtInterval,
|
refreshAtInterval,
|
||||||
} from '../helpers';
|
} from '../helpers';
|
||||||
|
import { useUriListForPermissions } from '../hooks/UriListForPermissions';
|
||||||
|
|
||||||
import PaginationForTable from './PaginationForTable';
|
import PaginationForTable from './PaginationForTable';
|
||||||
import 'react-datepicker/dist/react-datepicker.css';
|
import 'react-datepicker/dist/react-datepicker.css';
|
||||||
|
@ -56,6 +57,7 @@ import {
|
||||||
ReportFilter,
|
ReportFilter,
|
||||||
User,
|
User,
|
||||||
ErrorForDisplay,
|
ErrorForDisplay,
|
||||||
|
PermissionsToCheck,
|
||||||
} from '../interfaces';
|
} from '../interfaces';
|
||||||
import ProcessModelSearch from './ProcessModelSearch';
|
import ProcessModelSearch from './ProcessModelSearch';
|
||||||
import ProcessInstanceReportSearch from './ProcessInstanceReportSearch';
|
import ProcessInstanceReportSearch from './ProcessInstanceReportSearch';
|
||||||
|
@ -63,6 +65,8 @@ import ProcessInstanceListDeleteReport from './ProcessInstanceListDeleteReport';
|
||||||
import ProcessInstanceListSaveAsReport from './ProcessInstanceListSaveAsReport';
|
import ProcessInstanceListSaveAsReport from './ProcessInstanceListSaveAsReport';
|
||||||
import { Notification } from './Notification';
|
import { Notification } from './Notification';
|
||||||
import useAPIError from '../hooks/UseApiError';
|
import useAPIError from '../hooks/UseApiError';
|
||||||
|
import { usePermissionFetcher } from '../hooks/PermissionService';
|
||||||
|
import { Can } from '../contexts/Can';
|
||||||
|
|
||||||
const REFRESH_INTERVAL = 5;
|
const REFRESH_INTERVAL = 5;
|
||||||
const REFRESH_TIMEOUT = 600;
|
const REFRESH_TIMEOUT = 600;
|
||||||
|
@ -107,6 +111,13 @@ export default function ProcessInstanceListTable({
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { addError, removeError } = useAPIError();
|
const { addError, removeError } = useAPIError();
|
||||||
|
|
||||||
|
const { targetUris } = useUriListForPermissions();
|
||||||
|
const permissionRequestData: PermissionsToCheck = {
|
||||||
|
[targetUris.userSearch]: ['GET'],
|
||||||
|
};
|
||||||
|
const { ability } = usePermissionFetcher(permissionRequestData);
|
||||||
|
const canSearchUsers: boolean = ability.can('GET', targetUris.userSearch);
|
||||||
|
|
||||||
const [processInstances, setProcessInstances] = useState([]);
|
const [processInstances, setProcessInstances] = useState([]);
|
||||||
const [reportMetadata, setReportMetadata] = useState<ReportMetadata | null>();
|
const [reportMetadata, setReportMetadata] = useState<ReportMetadata | null>();
|
||||||
const [pagination, setPagination] = useState<PaginationObject | null>(null);
|
const [pagination, setPagination] = useState<PaginationObject | null>(null);
|
||||||
|
@ -167,6 +178,10 @@ export default function ProcessInstanceListTable({
|
||||||
useState<string[]>([]);
|
useState<string[]>([]);
|
||||||
const [processInitiatorSelection, setProcessInitiatorSelection] =
|
const [processInitiatorSelection, setProcessInitiatorSelection] =
|
||||||
useState<User | null>(null);
|
useState<User | null>(null);
|
||||||
|
const [processInitiatorText, setProcessInitiatorText] = useState<
|
||||||
|
string | null
|
||||||
|
>(null);
|
||||||
|
|
||||||
const lastRequestedInitatorSearchTerm = useRef<string>();
|
const lastRequestedInitatorSearchTerm = useRef<string>();
|
||||||
|
|
||||||
const dateParametersToAlwaysFilterBy: dateParameters = useMemo(() => {
|
const dateParametersToAlwaysFilterBy: dateParameters = useMemo(() => {
|
||||||
|
@ -202,7 +217,7 @@ export default function ProcessInstanceListTable({
|
||||||
};
|
};
|
||||||
|
|
||||||
const searchForProcessInitiator = (inputText: string) => {
|
const searchForProcessInitiator = (inputText: string) => {
|
||||||
if (inputText) {
|
if (inputText && canSearchUsers) {
|
||||||
lastRequestedInitatorSearchTerm.current = inputText;
|
lastRequestedInitatorSearchTerm.current = inputText;
|
||||||
HttpService.makeCallToBackend({
|
HttpService.makeCallToBackend({
|
||||||
path: `/users/search?username_prefix=${inputText}`,
|
path: `/users/search?username_prefix=${inputText}`,
|
||||||
|
@ -590,6 +605,8 @@ export default function ProcessInstanceListTable({
|
||||||
|
|
||||||
if (processInitiatorSelection) {
|
if (processInitiatorSelection) {
|
||||||
queryParamString += `&process_initiator_username=${processInitiatorSelection.username}`;
|
queryParamString += `&process_initiator_username=${processInitiatorSelection.username}`;
|
||||||
|
} else if (processInitiatorText) {
|
||||||
|
queryParamString += `&process_initiator_username=${processInitiatorText}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const reportColumnsBase64 = encodeBase64(JSON.stringify(reportColumns()));
|
const reportColumnsBase64 = encodeBase64(JSON.stringify(reportColumns()));
|
||||||
|
@ -1077,24 +1094,47 @@ export default function ProcessInstanceListTable({
|
||||||
/>
|
/>
|
||||||
</Column>
|
</Column>
|
||||||
<Column md={4}>
|
<Column md={4}>
|
||||||
<ComboBox
|
<Can
|
||||||
onInputChange={searchForProcessInitiator}
|
I="GET"
|
||||||
onChange={(event: any) => {
|
a={targetUris.userSearch}
|
||||||
setProcessInitiatorSelection(event.selectedItem);
|
ability={ability}
|
||||||
}}
|
passThrough
|
||||||
id="process-instance-initiator-search"
|
>
|
||||||
data-qa="process-instance-initiator-search"
|
{(hasAccess: boolean) => {
|
||||||
items={processInstanceInitiatorOptions}
|
if (hasAccess) {
|
||||||
itemToString={(processInstanceInitatorOption: User) => {
|
return (
|
||||||
if (processInstanceInitatorOption) {
|
<ComboBox
|
||||||
return processInstanceInitatorOption.username;
|
onInputChange={searchForProcessInitiator}
|
||||||
|
onChange={(event: any) => {
|
||||||
|
setProcessInitiatorSelection(event.selectedItem);
|
||||||
|
}}
|
||||||
|
id="process-instance-initiator-search"
|
||||||
|
data-qa="process-instance-initiator-search"
|
||||||
|
items={processInstanceInitiatorOptions}
|
||||||
|
itemToString={(processInstanceInitatorOption: User) => {
|
||||||
|
if (processInstanceInitatorOption) {
|
||||||
|
return processInstanceInitatorOption.username;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}}
|
||||||
|
placeholder="Start typing username"
|
||||||
|
titleText="Process Initiator"
|
||||||
|
selectedItem={processInitiatorSelection}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return (
|
||||||
|
<TextInput
|
||||||
|
id="process-instance-initiator-search"
|
||||||
|
placeholder="Enter username"
|
||||||
|
labelText="Process Initiator"
|
||||||
|
onChange={(event: any) =>
|
||||||
|
setProcessInitiatorText(event.target.value)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
placeholder="Starting typing username"
|
</Can>
|
||||||
titleText="Process Initiator"
|
|
||||||
selectedItem={processInitiatorSelection}
|
|
||||||
/>
|
|
||||||
</Column>
|
</Column>
|
||||||
<Column md={4}>{processStatusSearch()}</Column>
|
<Column md={4}>{processStatusSearch()}</Column>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@ -1248,7 +1288,6 @@ export default function ProcessInstanceListTable({
|
||||||
</td>
|
</td>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
console.log(column.accessor);
|
|
||||||
if (column.accessor === 'process_model_display_name') {
|
if (column.accessor === 'process_model_display_name') {
|
||||||
const pmStyle = { background: 'rgba(0, 0, 0, .02)' };
|
const pmStyle = { background: 'rgba(0, 0, 0, .02)' };
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -29,6 +29,7 @@ export const useUriListForPermissions = () => {
|
||||||
processModelPublishPath: `/v1.0/process-models/${params.process_model_id}/publish`,
|
processModelPublishPath: `/v1.0/process-models/${params.process_model_id}/publish`,
|
||||||
processModelShowPath: `/v1.0/process-models/${params.process_model_id}`,
|
processModelShowPath: `/v1.0/process-models/${params.process_model_id}`,
|
||||||
secretListPath: `/v1.0/secrets`,
|
secretListPath: `/v1.0/secrets`,
|
||||||
|
userSearch: `/v1.0/users/search`,
|
||||||
};
|
};
|
||||||
}, [params]);
|
}, [params]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue