[ARVADOS-WORKBENCH2] updated: 1.2.0-949-ga20fe4f

Git user git at public.curoverse.com
Mon Nov 26 09:06:57 EST 2018


Summary of changes:
 src/models/resource.ts                             |   3 +
 src/store/advanced-tab/advanced-tab.ts             | 113 ++++++++++++++-------
 .../context-menu/action-sets/ssh-key-action-set.ts |   3 +-
 3 files changed, 80 insertions(+), 39 deletions(-)

       via  a20fe4fc8e5f3705310db8e9a68a2ff266d85fba (commit)
      from  fec23dba0d04028d842cc0e2f832ec84828f5bae (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 a20fe4fc8e5f3705310db8e9a68a2ff266d85fba
Author: Janicki Artur <artur.janicki at contractors.roche.com>
Date:   Mon Nov 26 15:06:48 2018 +0100

    add advance tab for ssh key, refactor code
    
    Feature #14528_advance_tab_action_for_ssh_key
    
    Arvados-DCO-1.1-Signed-off-by: Janicki Artur <artur.janicki at contractors.roche.com>

diff --git a/src/models/resource.ts b/src/models/resource.ts
index 5fa6179..006d0a2 100644
--- a/src/models/resource.ts
+++ b/src/models/resource.ts
@@ -44,6 +44,7 @@ export enum ResourceObjectType {
     REPOSITORY = 's0uqq',
     USER = 'tpzed',
     WORKFLOW = '7fd4e',
+    SSH_KEY = 'fngyi'
 }
 
 export const RESOURCE_UUID_PATTERN = '.{5}-.{5}-.{15}';
@@ -78,6 +79,8 @@ export const extractUuidKind = (uuid: string = '') => {
             return ResourceKind.WORKFLOW;
         case ResourceObjectType.REPOSITORY:
             return ResourceKind.REPOSITORY;
+        case ResourceObjectType.SSH_KEY:
+            return ResourceKind.SSH_KEY;
         default:
             return undefined;
     }
diff --git a/src/store/advanced-tab/advanced-tab.ts b/src/store/advanced-tab/advanced-tab.ts
index c5f600d..2d742ce 100644
--- a/src/store/advanced-tab/advanced-tab.ts
+++ b/src/store/advanced-tab/advanced-tab.ts
@@ -15,10 +15,11 @@ import { ProjectResource } from '~/models/project';
 import { ServiceRepository } from '~/services/services';
 import { FilterBuilder } from '~/services/api/filter-builder';
 import { RepositoryResource } from '~/models/repositories';
+import { SshKeyResource } from '../../models/ssh-key';
 
 export const ADVANCED_TAB_DIALOG = 'advancedTabDialog';
 
-export interface AdvancedTabDialogData {
+interface AdvancedTabDialogData {
     apiResponse: any;
     metadata: any;
     user: string;
@@ -52,40 +53,62 @@ enum RepositoryData {
     CREATED_AT = 'created_at'
 }
 
+enum SshKeyData {
+    SSH_KEY = 'authorized_keys',
+    CREATED_AT = 'created_at'
+}
+
 export const openAdvancedTabDialog = (uuid: string, index?: number) =>
+    (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+        const kind = extractUuidKind(uuid);
+        switch (kind) {
+            case ResourceKind.COLLECTION:
+                const { data: dataCollection, metadata: metaCollection, user: userCollection } = dispatch<any>(getDataForAdvancedTab(uuid));
+                const advanceDataCollection: AdvancedTabDialogData = advancedTabData(uuid, metaCollection, userCollection, collectionApiResponse, dataCollection, CollectionData.COLLECTION, GroupContentsResourcePrefix.COLLECTION, CollectionData.STORAGE_CLASSES_CONFIRMED, dataCollection.storageClassesConfirmed);
+                dispatch<any>(dialogActions.OPEN_DIALOG({ id: ADVANCED_TAB_DIALOG, data: advanceDataCollection }));
+                break;
+            case ResourceKind.PROCESS:
+                const { data: dataProcess, metadata: metaProcess, user: userProcess } = dispatch<any>(getDataForAdvancedTab(uuid));
+                const advancedDataProcess: AdvancedTabDialogData = advancedTabData(uuid, metaProcess, userProcess, containerRequestApiResponse, dataProcess, ProcessData.CONTAINER_REQUEST, GroupContentsResourcePrefix.PROCESS, ProcessData.OUTPUT_NAME, dataProcess.outputName);
+                dispatch<any>(dialogActions.OPEN_DIALOG({ id: ADVANCED_TAB_DIALOG, data: advancedDataProcess }));
+                break;
+            case ResourceKind.PROJECT:
+                const { data: dataProject, metadata: metaProject, user: userProject } = dispatch<any>(getDataForAdvancedTab(uuid));
+                const advanceDataProject: AdvancedTabDialogData = advancedTabData(uuid, metaProject, userProject, groupRequestApiResponse, dataProject, ProjectData.GROUP, GroupContentsResourcePrefix.PROJECT, ProjectData.DELETE_AT, dataProject.deleteAt);
+                dispatch<any>(dialogActions.OPEN_DIALOG({ id: ADVANCED_TAB_DIALOG, data: advanceDataProject }));
+                break;
+            case ResourceKind.REPOSITORY:
+                const dataRepository = getState().repositories.items[index!];
+                const advanceDataRepository: AdvancedTabDialogData = advancedTabData(uuid, '', '', repositoryApiResponse, dataRepository, RepositoryData.REPOSITORY, 'repositories', RepositoryData.CREATED_AT, dataRepository.createdAt);
+                dispatch<any>(dialogActions.OPEN_DIALOG({ id: ADVANCED_TAB_DIALOG, data: advanceDataRepository }));
+                break;
+            case ResourceKind.SSH_KEY:
+                const dataSshKey = getState().auth.sshKeys[index!];
+                const advanceDataSshKey: AdvancedTabDialogData = advancedTabData(uuid, '', '', sshKeyApiResponse, dataSshKey, SshKeyData.SSH_KEY, 'authorized_keys', SshKeyData.CREATED_AT, dataSshKey.createdAt);
+                dispatch<any>(dialogActions.OPEN_DIALOG({ id: ADVANCED_TAB_DIALOG, data: advanceDataSshKey }));
+                break;
+            default:
+                dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Could not open advanced tab for this resource.", hideDuration: 2000, kind: SnackbarKind.ERROR }));
+        }
+    };
+
+const getDataForAdvancedTab = (uuid: string) =>
     async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
         const { resources } = getState();
-        const kind = extractUuidKind(uuid);
         const data = getResource<any>(uuid)(resources);
-        const repositoryData = getState().repositories.items[index!];
-        if (data || repositoryData) {
-            if (data) {
-                const metadata = await services.linkService.list({
-                    filters: new FilterBuilder()
-                        .addEqual('headUuid', uuid)
-                        .getFilters()
-                });
-                const user = metadata.itemsAvailable && await services.userService.get(metadata.items[0].tailUuid);
-                if (kind === ResourceKind.COLLECTION) {
-                    const dataCollection: AdvancedTabDialogData = advancedTabData(uuid, metadata, user, collectionApiResponse, data, CollectionData.COLLECTION, GroupContentsResourcePrefix.COLLECTION, CollectionData.STORAGE_CLASSES_CONFIRMED, data.storageClassesConfirmed);
-                    dispatch(dialogActions.OPEN_DIALOG({ id: ADVANCED_TAB_DIALOG, data: dataCollection }));
-                } else if (kind === ResourceKind.PROCESS) {
-                    const dataProcess: AdvancedTabDialogData = advancedTabData(uuid, metadata, user, containerRequestApiResponse, data, ProcessData.CONTAINER_REQUEST, GroupContentsResourcePrefix.PROCESS, ProcessData.OUTPUT_NAME, data.outputName);
-                    dispatch(dialogActions.OPEN_DIALOG({ id: ADVANCED_TAB_DIALOG, data: dataProcess }));
-                } else if (kind === ResourceKind.PROJECT) {
-                    const dataProject: AdvancedTabDialogData = advancedTabData(uuid, metadata, user, groupRequestApiResponse, data, ProjectData.GROUP, GroupContentsResourcePrefix.PROJECT, ProjectData.DELETE_AT, data.deleteAt);
-                    dispatch(dialogActions.OPEN_DIALOG({ id: ADVANCED_TAB_DIALOG, data: dataProject }));
-                }
-            } else if (kind === ResourceKind.REPOSITORY) {
-                const dataRepository: AdvancedTabDialogData = advancedTabData(uuid, '', '', repositoryApiResponse, repositoryData, RepositoryData.REPOSITORY, 'repositories', RepositoryData.CREATED_AT, repositoryData.createdAt);
-                dispatch(dialogActions.OPEN_DIALOG({ id: ADVANCED_TAB_DIALOG, data: dataRepository }));
-            }
-        } else {
-            dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Could not open advanced tab for this resource.", hideDuration: 2000, kind: SnackbarKind.ERROR }));
-        }
+        const metadata = await services.linkService.list({
+            filters: new FilterBuilder()
+                .addEqual('headUuid', uuid)
+                .getFilters()
+        });
+        const user = metadata.itemsAvailable && await services.userService.get(metadata.items[0].tailUuid);
+        return { data, metadata, user };
     };
 
-const advancedTabData = (uuid: string, metadata: any, user: any, apiResponseKind: any, data: any, resourceKind: CollectionData | ProcessData | ProjectData | RepositoryData, resourcePrefix: GroupContentsResourcePrefix | 'repositories', resourceKindProperty: CollectionData | ProcessData | ProjectData | RepositoryData, property: any) => {
+type AdvanceResourceKind = CollectionData | ProcessData | ProjectData | RepositoryData | SshKeyData;
+type AdvanceResourcePrefix = GroupContentsResourcePrefix | 'repositories' | 'authorized_keys';
+
+const advancedTabData = (uuid: string, metadata: any, user: any, apiResponseKind: any, data: any, resourceKind: AdvanceResourceKind, resourcePrefix: AdvanceResourcePrefix, resourceKindProperty: AdvanceResourceKind, property: any) => {
     return {
         uuid,
         user,
@@ -108,7 +131,7 @@ const pythonHeader = (resourceKind: string) =>
 const pythonExample = (uuid: string, resourcePrefix: string) => {
     const pythonExample = `import arvados
 
- x = arvados.api().${resourcePrefix}().get(uuid='${uuid}').execute()`;
+x = arvados.api().${resourcePrefix}().get(uuid='${uuid}').execute()`;
 
     return pythonExample;
 };
@@ -118,7 +141,7 @@ const cliGetHeader = (resourceKind: string) =>
 
 const cliGetExample = (uuid: string, resourceKind: string) => {
     const cliGetExample = `arv ${resourceKind} get \\
- --uuid ${uuid}`;
+  --uuid ${uuid}`;
 
     return cliGetExample;
 };
@@ -127,9 +150,9 @@ const cliUpdateHeader = (resourceKind: string, resourceName: string) =>
     `An example arv command to update the "${resourceName}" attribute for the current ${resourceKind}:`;
 
 const cliUpdateExample = (uuid: string, resourceKind: string, resource: string | string[], resourceName: string) => {
-    const CLIUpdateCollectionExample = `arv ${resourceKind} update \\ 
- --uuid ${uuid} \\
- --${resourceKind} '{"${resourceName}":${resource}}'`;
+    const CLIUpdateCollectionExample = `arv ${resourceKind} update \\
+  --uuid ${uuid} \\
+  --${resourceKind} '{"${resourceName}":${resource}}'`;
 
     return CLIUpdateCollectionExample;
 };
@@ -139,10 +162,10 @@ const curlHeader = (resourceKind: string, resource: string) =>
 
 const curlExample = (uuid: string, resourcePrefix: string, resource: string | string[], resourceKind: string, resourceName: string) => {
     const curlExample = `curl -X PUT \\
- -H "Authorization: OAuth2 $ARVADOS_API_TOKEN" \\
- --data-urlencode ${resourceKind}@/dev/stdin \\
- https://$ARVADOS_API_HOST/arvados/v1/${resourcePrefix}/${uuid} \\
- <<EOF
+  -H "Authorization: OAuth2 $ARVADOS_API_TOKEN" \\
+  --data-urlencode ${resourceKind}@/dev/stdin \\
+  https://$ARVADOS_API_HOST/arvados/v1/${resourcePrefix}/${uuid} \\
+  <<EOF
 {
   "${resourceName}": ${resource}
 }
@@ -253,4 +276,18 @@ const repositoryApiResponse = (apiResponse: RepositoryResource) => {
 "created_at": "${createdAt}"`;
 
     return response;
+};
+
+const sshKeyApiResponse = (apiResponse: SshKeyResource) => {
+    const { uuid, ownerUuid, createdAt, modifiedAt, modifiedByClientUuid, modifiedByUserUuid, name, authorizedUserUuid, expiresAt } = apiResponse;
+    const response = `"uuid": "${uuid}",
+"owner_uuid": "${ownerUuid}",
+"authorized_user_uuid": "${authorizedUserUuid}",
+"modified_by_client_uuid": ${stringify(modifiedByClientUuid)},
+"modified_by_user_uuid": ${stringify(modifiedByUserUuid)},
+"modified_at": ${stringify(modifiedAt)},
+"name": ${stringify(name)},
+"created_at": "${createdAt}",
+"expires_at": "${expiresAt}"`;
+    return response;
 };
\ No newline at end of file
diff --git a/src/views-components/context-menu/action-sets/ssh-key-action-set.ts b/src/views-components/context-menu/action-sets/ssh-key-action-set.ts
index 3fa2f16..6e86b2b 100644
--- a/src/views-components/context-menu/action-sets/ssh-key-action-set.ts
+++ b/src/views-components/context-menu/action-sets/ssh-key-action-set.ts
@@ -5,6 +5,7 @@
 import { ContextMenuActionSet } from "~/views-components/context-menu/context-menu-action-set";
 import { AdvancedIcon, RemoveIcon, AttributesIcon } from "~/components/icon/icon";
 import { openSshKeyRemoveDialog, openSshKeyAttributesDialog } from '~/store/auth/auth-action';
+import { openAdvancedTabDialog } from '~/store/advanced-tab/advanced-tab';
 
 export const sshKeyActionSet: ContextMenuActionSet = [[{
     name: "Attributes",
@@ -16,7 +17,7 @@ export const sshKeyActionSet: ContextMenuActionSet = [[{
     name: "Advanced",
     icon: AdvancedIcon,
     execute: (dispatch, { uuid, index }) => {
-        // ToDo
+        dispatch<any>(openAdvancedTabDialog(uuid, index));
     }
 }, {
     name: "Remove",

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list