Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>
import { customEncodeURI } from "common/url";
import { FilterBuilder } from "services/api/filter-builder";
import { ListArguments } from "services/common-service/common-service";
+import { Session } from "models/session";
export type UploadProgress = (fileId: number, loaded: number, total: number, currentTime: number) => void;
]);
}
- async get(uuid: string, showErrors?: boolean, select?: string[]) {
+ async get(uuid: string, showErrors?: boolean, select?: string[], session?: Session) {
super.validateUuid(uuid);
// We use a filtered list request to avoid getting the manifest text
const filters = new FilterBuilder().addEqual('uuid', uuid).getFilters();
if (select) {
listArgs.select = select;
}
- const lst = await super.list(listArgs, showErrors);
- return lst.items[0];
+
+ if (session) {
+ const lst = await super.list(listArgs, showErrors);
+ return lst.items[0];
+ } else {
+ return super.get(uuid, showErrors, session);
+ }
}
create(data?: Partial<CollectionResource>) {
// SPDX-License-Identifier: AGPL-3.0
import { camelCase, isPlainObject, isArray, snakeCase } from "lodash";
-import { AxiosInstance, AxiosPromise } from "axios";
+import { AxiosInstance, AxiosPromise, AxiosRequestConfig } from "axios";
import uuid from "uuid/v4";
import { ApiActions } from "services/api/api-actions";
import QueryString from "query-string";
+import { Session } from "models/session";
interface Errors {
status: number;
);
}
- get(uuid: string, showErrors?: boolean) {
+ get(uuid: string, showErrors?: boolean, select?: string[], session?: Session) {
this.validateUuid(uuid);
+
+ const cfg: AxiosRequestConfig = {};
+ if (session) {
+ cfg.baseURL = session.baseUrl;
+ cfg.headers = { 'Authorization': 'Bearer ' + session.token };
+ }
+
return CommonService.defaultResponse(
this.serverApi
- .get<T>(`/${this.resourceType}/${uuid}`),
+ .get<T>(`/${this.resourceType}/${uuid}`, session ? cfg : undefined),
this.actions,
true, // mapKeys
showErrors
import { Link } from 'react-router-dom';
import { StyleRulesCallback, withStyles, WithStyles } from '@material-ui/core';
import { ArvadosTheme } from 'common/custom-theme';
+import { getSearchSessions } from 'store/search-bar/search-bar-actions';
export enum SearchResultsPanelColumnNames {
CLUSTER = "Cluster",
const homeCluster = props.user.uuid.substring(0, 5);
const loggedIn = props.sessions.filter((ss) => ss.loggedIn && ss.userIsActive);
const [selectedItem, setSelectedItem] = useState('');
- let itemPath: string[] = [];
useEffect(() => {
- if (selectedItem !== '') {
- itemPath = [];
+ let itemPath: string[] = [];
- (async () => {
+ (async () => {
+ if (selectedItem !== '') {
let searchUuid = selectedItem;
let itemKind = extractUuidKind(searchUuid);
while (itemKind !== ResourceKind.USER) {
- console.log(itemKind);
- const { name, ownerUuid } = await servicesProvider.getServices().groupsService.get(searchUuid);
- itemKind = extractUuidKind(ownerUuid);
- searchUuid = ownerUuid;
- itemPath.push(name);
+ const clusterId = searchUuid.split('-')[0];
+ const serviceType = itemKind?.replace('arvados#', '');
+ const service = Object.values(servicesProvider.getServices())
+ .filter(({resourceType}) => !!resourceType)
+ .find(({resourceType}) => resourceType.indexOf(serviceType) > -1);
+ const sessions = getSearchSessions(clusterId, props.sessions);
+
+ if (sessions.length > 0) {
+ const session = sessions[0];
+ const { name, ownerUuid } = await (service as any).get(searchUuid, false, session);
+ itemPath.push(name);
+ searchUuid = ownerUuid;
+ itemKind = extractUuidKind(searchUuid);
+ } else {
+ break;
+ }
}
- const rootFolder = props.user.uuid === searchUuid ? 'Projects' : 'Shared with me';
- itemPath.push(rootFolder);
+ itemPath.push(props.user.uuid === searchUuid ? 'Projects' : 'Shared with me');
+ props.onPathDisplay(`/ ${itemPath.reverse().join(' / ')}`);
+ }
+ })();
- console.log(itemPath.reverse().join('/'));
- })();
- }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, [selectedItem]);
const onItemClick = useCallback((uuid) => {
setSelectedItem(uuid);
props.onItemClick(uuid);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
},[props.onItemClick]);
- return <span data-cy='search-results'><DataExplorer
+ return <span data-cy='search-results'>
+ <DataExplorer
id={SEARCH_RESULTS_PANEL_ID}
onRowClick={onItemClick}
onRowDoubleClick={props.onItemDoubleClick}
import { User } from "models/user";
import { Config } from 'common/config';
import { Session } from "models/session";
+import { snackbarActions, SnackbarKind } from "store/snackbar/snackbar-actions";
export interface SearchResultsPanelDataProps {
data: SearchBarAdvancedFormData;
onContextMenu: (event: React.MouseEvent<HTMLElement>, item: string) => void;
onDialogOpen: (ownerUuid: string) => void;
onItemDoubleClick: (item: string) => void;
+ onPathDisplay: (path: string) => void;
}
export type SearchResultsPanelProps = SearchResultsPanelDataProps & SearchResultsPanelActionProps;
},
onItemDoubleClick: uuid => {
dispatch<any>(navigateTo(uuid));
- }
+ },
+ onPathDisplay: (path: string) => {
+ dispatch(snackbarActions.SHIFT_MESSAGES());
+ dispatch(snackbarActions.OPEN_SNACKBAR({
+ message: path,
+ kind: SnackbarKind.INFO,
+ hideDuration: 9999999999,
+ }));
+ },
});
export const SearchResultsPanel = connect(mapStateToProps, mapDispatchToProps)(SearchResultsPanelView);