[ARVADOS-WORKBENCH2] updated: 1.4.1-105-g796a3ce0

Git user git at public.curoverse.com
Tue Nov 12 14:55:16 UTC 2019


Summary of changes:
 src/models/vocabulary.ts                        | 16 ++++++++++++++-
 src/views/collection-panel/collection-panel.tsx | 27 ++++++++++++++++---------
 2 files changed, 32 insertions(+), 11 deletions(-)

       via  796a3ce005800d37ef5711b367c926ac720577d5 (commit)
      from  45ee419ff7952fc722a139666c327a321a92cc81 (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 796a3ce005800d37ef5711b367c926ac720577d5
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date:   Tue Nov 12 11:54:04 2019 -0300

    15067: Renders properties' key/values by their labels when possible.
    
    Also, the "copy to clipboard" feature remain copying the key/value ids.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>

diff --git a/src/models/vocabulary.ts b/src/models/vocabulary.ts
index 158d8058..ebef70f0 100644
--- a/src/models/vocabulary.ts
+++ b/src/models/vocabulary.ts
@@ -50,6 +50,14 @@ export const getTagValueID = (tagKeyID:string, tagValueLabel:string, vocabulary:
             l => l.label === tagValueLabel) !== undefined) || ''
     : '';
 
+export const getTagValueLabel = (tagKeyID:string, tagValueID:string, vocabulary: Vocabulary) =>
+    vocabulary.tags[tagKeyID] &&
+    vocabulary.tags[tagKeyID].values &&
+    vocabulary.tags[tagKeyID].values![tagValueID] &&
+    vocabulary.tags[tagKeyID].values![tagValueID].labels.length > 0
+        ? vocabulary.tags[tagKeyID].values![tagValueID].labels[0].label
+        : tagValueID;
+
 const compare = (a: PropFieldSuggestion, b: PropFieldSuggestion) => {
     if (a.label < b.label) {return -1;}
     if (a.label > b.label) {return 1;}
@@ -86,4 +94,10 @@ export const getTags = ({ tags }: Vocabulary) => {
 export const getTagKeyID = (tagKeyLabel:string, vocabulary: Vocabulary) =>
     Object.keys(vocabulary.tags).find(
         k => vocabulary.tags[k].labels.find(
-            l => l.label === tagKeyLabel) !== undefined) || '';
+            l => l.label === tagKeyLabel) !== undefined
+        ) || '';
+
+export const getTagKeyLabel = (tagKeyID:string, vocabulary: Vocabulary) =>
+    vocabulary.tags[tagKeyID] && vocabulary.tags[tagKeyID].labels.length > 0
+    ? vocabulary.tags[tagKeyID].labels[0].label
+    : tagKeyID;
diff --git a/src/views/collection-panel/collection-panel.tsx b/src/views/collection-panel/collection-panel.tsx
index 77d91558..f4d6532e 100644
--- a/src/views/collection-panel/collection-panel.tsx
+++ b/src/views/collection-panel/collection-panel.tsx
@@ -7,6 +7,7 @@ import {
     StyleRulesCallback, WithStyles, withStyles, Card,
     CardHeader, IconButton, CardContent, Grid, Chip, Tooltip
 } from '@material-ui/core';
+import { compose } from "redux";
 import { connect, DispatchProp } from "react-redux";
 import { RouteComponentProps } from 'react-router';
 import { ArvadosTheme } from '~/common/custom-theme';
@@ -26,6 +27,8 @@ import { ResourceData } from "~/store/resources-data/resources-data-reducer";
 import { openDetailsPanel } from '~/store/details-panel/details-panel-action';
 import * as CopyToClipboard from 'react-copy-to-clipboard';
 import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions';
+import { connectVocabulary, VocabularyProp } from '~/views-components/resource-properties-form/property-field-common';
+import { getTagValueLabel, getTagKeyLabel } from '~/models/vocabulary';
 
 type CssRules = 'card' | 'iconHeader' | 'tag' | 'label' | 'value' | 'link';
 
@@ -65,16 +68,19 @@ interface CollectionPanelDataProps {
 type CollectionPanelProps = CollectionPanelDataProps & DispatchProp
     & WithStyles<CssRules> & RouteComponentProps<{ id: string }>;
 
-export const CollectionPanel = withStyles(styles)(
-    connect((state: RootState, props: RouteComponentProps<{ id: string }>) => {
-        const item = getResource(props.match.params.id)(state.resources);
-        const data = getResourceData(props.match.params.id)(state.resourcesData);
-        return { item, data };
-    })(
-        class extends React.Component<CollectionPanelProps> {
+export const CollectionPanel = compose(
+    connectVocabulary,
+    withStyles(styles))(
+        connect((state: RootState, props: RouteComponentProps<{ id: string }> & VocabularyProp) => {
+            const item = getResource(props.match.params.id)(state.resources);
+            const data = getResourceData(props.match.params.id)(state.resourcesData);
+            const vocabulary = props.vocabulary;
+            return { item, data, vocabulary };
+        })(
+        class extends React.Component<CollectionPanelProps & VocabularyProp> {
 
             render() {
-                const { classes, item, data, dispatch } = this.props;
+                const { classes, item, data, dispatch, vocabulary } = this.props;
                 return item
                     ? <>
                         <Card className={classes.card}>
@@ -132,8 +138,9 @@ export const CollectionPanel = withStyles(styles)(
                                     <Grid item xs={12}>
                                         {
                                             Object.keys(item.properties).map(k => {
-                                                const label = `${k}: ${item.properties[k]}`;
-                                                return <CopyToClipboard key={k} text={label} onCopy={() => this.onCopy("Copied")}>
+                                                const ids = `${k}: ${item.properties[k]}`;
+                                                const label = `${getTagKeyLabel(k, vocabulary)}: ${getTagValueLabel(k, item.properties[k], vocabulary)}`;
+                                                return <CopyToClipboard key={k} text={ids} onCopy={() => this.onCopy("Copied")}>
                                                     <Chip className={classes.tag}
                                                         onDelete={this.handleDelete(k)}
                                                         label={label} />

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list