[arvados] updated: 2.7.0-6086-gcba86260ec
git repository hosting
git at public.arvados.org
Tue Mar 12 15:32:40 UTC 2024
Summary of changes:
services/workbench2/src/common/link-update-name.ts | 35 ++++++++++++----------
.../side-panel-tree/side-panel-tree-actions.ts | 35 ++++++++++++++--------
2 files changed, 42 insertions(+), 28 deletions(-)
via cba86260ec62023c8b440a974f8fe0bd63b3f004 (commit)
from 9ce086be94935233601712eb5a07e252266f4e8d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit cba86260ec62023c8b440a974f8fe0bd63b3f004
Author: Lisa Knox <lisaknox83 at gmail.com>
Date: Tue Mar 12 11:32:36 2024 -0400
21357: myfavorites now optimistically renders Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa.knox at curii.com>
diff --git a/services/workbench2/src/common/link-update-name.ts b/services/workbench2/src/common/link-update-name.ts
index 8530f5cd38..453c77941e 100644
--- a/services/workbench2/src/common/link-update-name.ts
+++ b/services/workbench2/src/common/link-update-name.ts
@@ -10,24 +10,29 @@ import { Resource, extractUuidKind } from 'models/resource';
type NameableResource = Resource & { name?: string };
-export const verifyAndUpdateLinkName = async (link: LinkResource, dispatch: Dispatch, getState: () => RootState, services: ServiceRepository):Promise<string> => {
- //check if head resource is already in the store
+export const verifyAndUpdateLink = async (link: LinkResource, dispatch: Dispatch, getState: () => RootState, services: ServiceRepository): Promise<LinkResource> => {
+ //check if head resource is already in the store
let headResource: Resource | undefined = getState().resources[link.headUuid];
//if not, fetch it
if (!headResource) {
headResource = await fetchResource(link.headUuid)(dispatch, getState, services);
- if(!headResource) {
- console.error('Could not validate link', link, 'because link head', link.headUuid, 'is not available');
- return link.name;
+ if (!headResource) {
+ if (!link.name) console.error('Could not validate link', link, 'because link head', link.headUuid, 'is not available');
+ return link;
}
}
- if (validateLinkNameProp(link, headResource) === true) return link.name;
+ if (validateLinkNameProp(link, headResource) === true) return link;
const updatedLink = updateLinkNameProp(link, headResource);
updateRemoteLinkName(updatedLink)(dispatch, getState, services);
-
- return updatedLink.name;
+
+ return updatedLink;
+};
+
+export const verifyAndUpdateLinks = async (links: LinkResource[], dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ const updatedLinks = links.map((link) => verifyAndUpdateLink(link, dispatch, getState, services));
+ return Promise.all(updatedLinks);
};
const fetchResource = (uuid: string, showErrors?: boolean) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
@@ -38,29 +43,29 @@ const fetchResource = (uuid: string, showErrors?: boolean) => async (dispatch: D
const resource = await service.get(uuid, showErrors);
return resource;
}
- } catch(e) {
+ } catch (e) {
console.error(`Could not fetch resource ${uuid}`, e);
}
return undefined;
};
const validateLinkNameProp = (link: LinkResource, head: NameableResource) => {
- if(!link.name || link.name !== head.name) return false;
+ if (!link.name || link.name !== head.name) return false;
return true;
};
const updateLinkNameProp = (link: LinkResource, head: NameableResource) => {
- const updatedLink = {...link};
- if(head.name) updatedLink.name = head.name;
- return updatedLink;
-}
+ const updatedLink = { ...link };
+ if (head.name) updatedLink.name = head.name;
+ return updatedLink;
+};
const updateRemoteLinkName = (link: LinkResource) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
try {
const kind = extractUuidKind(link.uuid);
const service = getResourceService(kind)(services);
if (service) {
- service.update(link.uuid, {name: link.name});
+ service.update(link.uuid, { name: link.name });
}
} catch (error) {
console.error('Could not update link name', link, error);
diff --git a/services/workbench2/src/store/side-panel-tree/side-panel-tree-actions.ts b/services/workbench2/src/store/side-panel-tree/side-panel-tree-actions.ts
index a136e2c1e4..ea4df655fd 100644
--- a/services/workbench2/src/store/side-panel-tree/side-panel-tree-actions.ts
+++ b/services/workbench2/src/store/side-panel-tree/side-panel-tree-actions.ts
@@ -16,8 +16,8 @@ import { OrderBuilder } from 'services/api/order-builder';
import { ResourceKind } from 'models/resource';
import { CategoriesListReducer } from 'common/plugintypes';
import { pluginConfig } from 'plugins';
-import { LinkClass } from 'models/link';
-import { verifyAndUpdateLinkName } from 'common/link-update-name';
+import { LinkClass, LinkResource } from 'models/link';
+import { verifyAndUpdateLinks } from 'common/link-update-name';
export enum SidePanelTreeCategory {
PROJECTS = 'Home Projects',
@@ -103,7 +103,8 @@ export const loadSidePanelTreeProjects = (projectUuid: string) =>
if (projectUuid === SidePanelTreeCategory.PUBLIC_FAVORITES) {
await dispatch<any>(loadPublicFavoritesTree());
} else if (projectUuid === SidePanelTreeCategory.FAVORITES) {
- await dispatch<any>(loadFavoritesTree());
+ const unverifiedLinks = await dispatch<any>(loadFavoritesTree());
+ verifyAndUpdateLinkNames(unverifiedLinks, dispatch, getState, services);
} else if (node || projectUuid !== '') {
await dispatch<any>(loadProject(projectUuid));
}
@@ -145,11 +146,7 @@ export const loadFavoritesTree = () => async (dispatch: Dispatch, getState: () =
limit: SIDEPANEL_TREE_NODE_LIMIT,
};
- let items = (await services.linkService.list(params)).items;
- for(let item of items) {
- const verifiedName = await verifyAndUpdateLinkName(item, dispatch, getState, services);
- item.name = verifiedName;
- }
+ const { items } = await services.linkService.list(params);
dispatch(
treePickerActions.LOAD_TREE_PICKER_NODE_SUCCESS({
@@ -159,7 +156,19 @@ export const loadFavoritesTree = () => async (dispatch: Dispatch, getState: () =
})
);
- dispatch(resourcesActions.SET_RESOURCES(items));
+ return items;
+};
+
+const verifyAndUpdateLinkNames = async (links: LinkResource[], dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ const verfifiedLinks = await verifyAndUpdateLinks(links, dispatch, getState, services);
+
+ dispatch(
+ treePickerActions.LOAD_TREE_PICKER_NODE_SUCCESS({
+ id: SidePanelTreeCategory.FAVORITES,
+ pickerId: SIDE_PANEL_TREE,
+ nodes: verfifiedLinks.map(item => initTreeNode({ id: item.headUuid, value: item })),
+ })
+ );
};
export const loadPublicFavoritesTree = () => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
@@ -205,10 +214,10 @@ export const loadPublicFavoritesTree = () => async (dispatch: Dispatch, getState
const filteredItems = items.filter(item => responseItems.some(responseItem => responseItem.uuid === item.headUuid));
- for(const item of filteredItems) {
- const verifiedName = await verifyAndUpdateLinkName(item, dispatch, getState, services);
- item.name = verifiedName;
- }
+ // for(const item of filteredItems) {
+ // const verifiedName = await verifyAndUpdateLinkName(item, dispatch, getState, services);
+ // item.name = verifiedName;
+ // }
dispatch(
treePickerActions.LOAD_TREE_PICKER_NODE_SUCCESS({
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list