|
|
@@ -1,46 +1,41 @@ |
|
|
|
import makeArvadosRequest from 'make-arvados-request';
|
|
|
|
import arvadosTypeName from 'arvados-type-name';
|
|
|
|
import arvadosObjectName from 'arvados-object-name';
|
|
|
|
|
|
|
|
function fetchObjectParents(arvHost, arvToken, uuid) {
|
|
|
|
let parents = [];
|
|
|
|
|
|
|
|
let cb = xhr => {
|
|
|
|
let objectType = arvadosTypeName(xhr.response['uuid'].split('-')[1]);
|
|
|
|
|
|
|
|
let item = {
|
|
|
|
'uuid': xhr.response['uuid']
|
|
|
|
};
|
|
|
|
|
|
|
|
if (objectType === 'user') {
|
|
|
|
item['name'] = xhr.response['first_name'] + ' ' + xhr.response['last_name'];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
item['name'] = xhr.response['name'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (objectType === 'group') {
|
|
|
|
item['group_class'] = xhr.response['group_class'];
|
|
|
|
}
|
|
|
|
const item = xhr.response.items[0];
|
|
|
|
if (!item)
|
|
|
|
return parents.reverse();
|
|
|
|
|
|
|
|
item.name = arvadosObjectName(item);
|
|
|
|
parents.push(item);
|
|
|
|
|
|
|
|
if (!xhr.response['owner_uuid'] ||
|
|
|
|
xhr.response['owner_uuid'].endsWith('-tpzed-000000000000000')) {
|
|
|
|
if (!item.owner_uuid ||
|
|
|
|
item.owner_uuid.endsWith('-tpzed-000000000000000')) {
|
|
|
|
|
|
|
|
return parents.reverse();
|
|
|
|
}
|
|
|
|
|
|
|
|
objectType = arvadosTypeName(xhr.response['owner_uuid'].split('-')[1]);
|
|
|
|
const objectType = arvadosTypeName(item.owner_uuid);
|
|
|
|
const filters = [
|
|
|
|
['uuid', '=', item.owner_uuid]
|
|
|
|
];
|
|
|
|
|
|
|
|
return makeArvadosRequest(arvHost, arvToken,
|
|
|
|
'/arvados/v1/' + objectType + 's' +
|
|
|
|
'/' + xhr.response['owner_uuid']).then(cb);
|
|
|
|
'?filters=' + encodeURIComponent(JSON.stringify(filters))).then(cb);
|
|
|
|
};
|
|
|
|
|
|
|
|
let objectType = arvadosTypeName(uuid.split('-')[1]);
|
|
|
|
const objectType = arvadosTypeName(uuid);
|
|
|
|
const filters = [
|
|
|
|
['uuid', '=', uuid]
|
|
|
|
];
|
|
|
|
let prom = makeArvadosRequest(arvHost, arvToken,
|
|
|
|
'/arvados/v1/' + objectType + 's' +
|
|
|
|
'/' + uuid);
|
|
|
|
'?filters=' + encodeURIComponent(JSON.stringify(filters)));
|
|
|
|
prom = prom.then(cb);
|
|
|
|
|
|
|
|
return prom;
|
|
|
|