[ARVADOS-WORKBENCH2] updated: 1.2.0-128-gc4489d5
Git user
git at public.curoverse.com
Thu Aug 23 11:58:15 EDT 2018
Summary of changes:
src/models/user.ts | 18 ++++-
.../ancestors-service/ancestors-service.ts | 44 ++++++++++++
src/services/services.ts | 22 +++++-
.../user-service.ts} | 10 +--
src/store/properties/properties-actions.ts | 12 ++++
src/store/properties/properties-reducer.ts | 14 ++++
src/store/properties/properties.ts | 23 ++++++
src/store/store.ts | 84 +++++++++-------------
8 files changed, 170 insertions(+), 57 deletions(-)
create mode 100644 src/services/ancestors-service/ancestors-service.ts
copy src/services/{link-service/link-service.ts => user-service/user-service.ts} (65%)
create mode 100644 src/store/properties/properties-actions.ts
create mode 100644 src/store/properties/properties-reducer.ts
create mode 100644 src/store/properties/properties.ts
via c4489d532c800a91ea66f3aaec98fc4a299e3e1e (commit)
via e9a65be7cd7d5889d885794bf46ac3c6277eca3c (commit)
from 540750a7749cb71ea0a8fde4b7a3689eeaa1c3dd (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 c4489d532c800a91ea66f3aaec98fc4a299e3e1e
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date: Thu Aug 23 17:57:59 2018 +0200
Add resource service helpers, add user service, add ancestors-service
Feature #14102
Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
diff --git a/src/models/user.ts b/src/models/user.ts
index 4cc29ba..c2f21e5 100644
--- a/src/models/user.ts
+++ b/src/models/user.ts
@@ -2,6 +2,8 @@
//
// SPDX-License-Identifier: AGPL-3.0
+import { Resource, ResourceKind } from '~/models/resource';
+
export interface User {
email: string;
firstName: string;
@@ -12,4 +14,18 @@ export interface User {
export const getUserFullname = (user?: User) => {
return user ? `${user.firstName} ${user.lastName}` : "";
-};
\ No newline at end of file
+};
+
+export interface UserResource extends Resource {
+ kind: ResourceKind.USER;
+ email: string;
+ username: string;
+ firstName: string;
+ lastName: string;
+ identityUrl: string;
+ isAdmin: boolean;
+ prefs: string;
+ defaultOwnerUuid: string;
+ isActive: boolean;
+ writableBy: string[];
+}
\ No newline at end of file
diff --git a/src/services/ancestors-service/ancestors-service.ts b/src/services/ancestors-service/ancestors-service.ts
new file mode 100644
index 0000000..5eab842
--- /dev/null
+++ b/src/services/ancestors-service/ancestors-service.ts
@@ -0,0 +1,44 @@
+import { GroupsService } from "~/services/groups-service/groups-service";
+import { UserService } from '../user-service/user-service';
+import { GroupResource } from '~/models/group';
+import { UserResource } from '../../models/user';
+import { extractUuidObjectType, ResourceObjectType } from "~/models/resource";
+
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+export class AncestorService {
+ constructor(
+ private groupsService: GroupsService,
+ private userService: UserService
+ ) { }
+
+ async ancestors(uuid: string, rootUuid: string): Promise<Array<UserResource | GroupResource>> {
+ const service = this.getService(extractUuidObjectType(uuid));
+ if (service) {
+ const resource = await service.get(uuid);
+ if (uuid === rootUuid) {
+ return [resource];
+ } else {
+ return [
+ ...await this.ancestors(resource.ownerUuid, rootUuid),
+ resource
+ ];
+ }
+ } else {
+ return [];
+ }
+ }
+
+ private getService = (objectType?: string) => {
+ switch (objectType) {
+ case ResourceObjectType.GROUP:
+ return this.groupsService;
+ case ResourceObjectType.USER:
+ return this.userService;
+ default:
+ return undefined;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/services/services.ts b/src/services/services.ts
index 0e1f4b4..6295527 100644
--- a/src/services/services.ts
+++ b/src/services/services.ts
@@ -14,6 +14,9 @@ import { CollectionFilesService } from "./collection-files-service/collection-fi
import { KeepService } from "./keep-service/keep-service";
import { WebDAV } from "../common/webdav";
import { Config } from "../common/config";
+import { UserService } from './user-service/user-service';
+import { AncestorService } from "~/services/ancestors-service/ancestors-service";
+import { ResourceKind } from "~/models/resource";
export type ServiceRepository = ReturnType<typeof createServices>;
@@ -33,6 +36,8 @@ export const createServices = (config: Config) => {
const collectionService = new CollectionService(apiClient, webdavClient, authService);
const tagService = new TagService(linkService);
const collectionFilesService = new CollectionFilesService(collectionService);
+ const userService = new UserService(apiClient);
+ const ancestorsService = new AncestorService(groupsService, userService);
return {
apiClient,
@@ -45,6 +50,21 @@ export const createServices = (config: Config) => {
favoriteService,
collectionService,
tagService,
- collectionFilesService
+ collectionFilesService,
+ userService,
+ ancestorsService,
};
};
+
+export const getResourceService = (kind?: ResourceKind) => (serviceRepository: ServiceRepository) => {
+ switch (kind) {
+ case ResourceKind.USER:
+ return serviceRepository.userService;
+ case ResourceKind.GROUP:
+ return serviceRepository.groupsService;
+ case ResourceKind.COLLECTION:
+ return serviceRepository.collectionService;
+ default:
+ return undefined;
+ }
+};
\ No newline at end of file
diff --git a/src/services/user-service/user-service.ts b/src/services/user-service/user-service.ts
new file mode 100644
index 0000000..3c09a87
--- /dev/null
+++ b/src/services/user-service/user-service.ts
@@ -0,0 +1,13 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { AxiosInstance } from "axios";
+import { CommonResourceService } from "~/common/api/common-resource-service";
+import { UserResource } from "~/models/user";
+
+export class UserService extends CommonResourceService<UserResource> {
+ constructor(serverApi: AxiosInstance) {
+ super(serverApi, "users");
+ }
+}
\ No newline at end of file
commit e9a65be7cd7d5889d885794bf46ac3c6277eca3c
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date: Thu Aug 23 14:53:00 2018 +0200
Create store for custom properties
Feature #14102
Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
diff --git a/src/store/properties/properties-actions.ts b/src/store/properties/properties-actions.ts
new file mode 100644
index 0000000..8647a9c
--- /dev/null
+++ b/src/store/properties/properties-actions.ts
@@ -0,0 +1,12 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { unionize, ofType, UnionOf } from '~/common/unionize';
+
+export const propertiesActions = unionize({
+ SET_PROPERTY: ofType<{ key: string, value: any }>(),
+ DELETE_PROPERTY: ofType<string>(),
+});
+
+export type PropertiesAction = UnionOf<typeof propertiesActions>;
diff --git a/src/store/properties/properties-reducer.ts b/src/store/properties/properties-reducer.ts
new file mode 100644
index 0000000..27fdf85
--- /dev/null
+++ b/src/store/properties/properties-reducer.ts
@@ -0,0 +1,14 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { PropertiesState, setProperty, deleteProperty } from './properties';
+import { PropertiesAction, propertiesActions } from './properties-actions';
+
+
+export const propertiesReducer = (state: PropertiesState = {}, action: PropertiesAction) =>
+ propertiesActions.match(action, {
+ SET_PROPERTY: ({ key, value }) => setProperty(key, value)(state),
+ DELETE_PROPERTY: key => deleteProperty(key)(state),
+ default: () => state,
+ });
\ No newline at end of file
diff --git a/src/store/properties/properties.ts b/src/store/properties/properties.ts
new file mode 100644
index 0000000..bee5b19
--- /dev/null
+++ b/src/store/properties/properties.ts
@@ -0,0 +1,23 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+export type PropertiesState = { [key: string]: any };
+
+export const getProperty = <T>(id: string) =>
+ (state: PropertiesState): T | undefined =>
+ state[id];
+
+export const setProperty = <T>(id: string, data: T) =>
+ (state: PropertiesState) => ({
+ ...state,
+ [id]: data
+ });
+
+export const deleteProperty = (id: string) =>
+ (state: PropertiesState) => {
+ const newState = { ...state };
+ delete newState[id];
+ return newState;
+ };
+
diff --git a/src/store/store.ts b/src/store/store.ts
index eb36fa4..0e548c5 100644
--- a/src/store/store.ts
+++ b/src/store/store.ts
@@ -3,79 +3,44 @@
// SPDX-License-Identifier: AGPL-3.0
import { createStore, applyMiddleware, compose, Middleware, combineReducers, Store, Action, Dispatch } from 'redux';
-import { routerMiddleware, routerReducer, RouterState } from "react-router-redux";
+import { routerMiddleware, routerReducer } from "react-router-redux";
import thunkMiddleware from 'redux-thunk';
import { History } from "history";
-import { projectsReducer, ProjectState } from "./project/project-reducer";
-import { sidePanelReducer, SidePanelState } from './side-panel/side-panel-reducer';
-import { authReducer, AuthState } from "./auth/auth-reducer";
-import { dataExplorerReducer, DataExplorerState } from './data-explorer/data-explorer-reducer';
-import { detailsPanelReducer, DetailsPanelState } from './details-panel/details-panel-reducer';
-import { contextMenuReducer, ContextMenuState } from './context-menu/context-menu-reducer';
+import { projectsReducer } from "./project/project-reducer";
+import { authReducer } from "./auth/auth-reducer";
+import { dataExplorerReducer } from './data-explorer/data-explorer-reducer';
+import { detailsPanelReducer } from './details-panel/details-panel-reducer';
+import { contextMenuReducer } from './context-menu/context-menu-reducer';
import { reducer as formReducer } from 'redux-form';
-import { FavoritesState, favoritesReducer } from './favorites/favorites-reducer';
-import { snackbarReducer, SnackbarState } from './snackbar/snackbar-reducer';
-import { CollectionPanelFilesState } from './collection-panel/collection-panel-files/collection-panel-files-state';
+import { favoritesReducer } from './favorites/favorites-reducer';
+import { snackbarReducer } from './snackbar/snackbar-reducer';
import { collectionPanelFilesReducer } from './collection-panel/collection-panel-files/collection-panel-files-reducer';
import { dataExplorerMiddleware } from "./data-explorer/data-explorer-middleware";
import { FAVORITE_PANEL_ID } from "./favorite-panel/favorite-panel-action";
import { PROJECT_PANEL_ID } from "./project-panel/project-panel-action";
import { ProjectPanelMiddlewareService } from "./project-panel/project-panel-middleware-service";
import { FavoritePanelMiddlewareService } from "./favorite-panel/favorite-panel-middleware-service";
-import { CollectionPanelState, collectionPanelReducer } from './collection-panel/collection-panel-reducer';
-import { DialogState, dialogReducer } from './dialog/dialog-reducer';
-import { CollectionsState, collectionsReducer } from './collections/collections-reducer';
+import { collectionPanelReducer } from './collection-panel/collection-panel-reducer';
+import { dialogReducer } from './dialog/dialog-reducer';
+import { collectionsReducer } from './collections/collections-reducer';
import { ServiceRepository } from "~/services/services";
import { treePickerReducer } from './tree-picker/tree-picker-reducer';
-import { TreePicker } from './tree-picker/tree-picker';
-import { ResourcesState } from '~/store/resources/resources';
import { resourcesReducer } from '~/store/resources/resources-reducer';
+import { propertiesReducer } from './properties/properties-reducer';
+import { RootState } from './store';
const composeEnhancers =
(process.env.NODE_ENV === 'development' &&
window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) ||
compose;
-export interface RootState {
- auth: AuthState;
- projects: ProjectState;
- collections: CollectionsState;
- router: RouterState;
- dataExplorer: DataExplorerState;
- sidePanel: SidePanelState;
- collectionPanel: CollectionPanelState;
- detailsPanel: DetailsPanelState;
- contextMenu: ContextMenuState;
- favorites: FavoritesState;
- snackbar: SnackbarState;
- collectionPanelFiles: CollectionPanelFilesState;
- dialog: DialogState;
- treePicker: TreePicker;
- resources: ResourcesState;
-}
+export type RootState = ReturnType<ReturnType<typeof createRootReducer>>;
export type RootStore = Store<RootState, Action> & { dispatch: Dispatch<any> };
export function configureStore(history: History, services: ServiceRepository): RootStore {
- const rootReducer = combineReducers({
- auth: authReducer(services),
- projects: projectsReducer,
- collections: collectionsReducer,
- router: routerReducer,
- dataExplorer: dataExplorerReducer,
- sidePanel: sidePanelReducer,
- collectionPanel: collectionPanelReducer,
- detailsPanel: detailsPanelReducer,
- contextMenu: contextMenuReducer,
- form: formReducer,
- favorites: favoritesReducer,
- snackbar: snackbarReducer,
- collectionPanelFiles: collectionPanelFilesReducer,
- dialog: dialogReducer,
- treePicker: treePickerReducer,
- resources: resourcesReducer,
- });
+ const rootReducer = createRootReducer(services);
const projectPanelMiddleware = dataExplorerMiddleware(
new ProjectPanelMiddlewareService(services, PROJECT_PANEL_ID)
@@ -93,3 +58,22 @@ export function configureStore(history: History, services: ServiceRepository): R
const enhancer = composeEnhancers(applyMiddleware(...middlewares));
return createStore(rootReducer, enhancer);
}
+
+const createRootReducer = (services: ServiceRepository) => combineReducers({
+ auth: authReducer(services),
+ projects: projectsReducer,
+ collections: collectionsReducer,
+ router: routerReducer,
+ dataExplorer: dataExplorerReducer,
+ collectionPanel: collectionPanelReducer,
+ detailsPanel: detailsPanelReducer,
+ contextMenu: contextMenuReducer,
+ form: formReducer,
+ favorites: favoritesReducer,
+ snackbar: snackbarReducer,
+ collectionPanelFiles: collectionPanelFilesReducer,
+ dialog: dialogReducer,
+ treePicker: treePickerReducer,
+ resources: resourcesReducer,
+ properties: propertiesReducer,
+});
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list