[ARVADOS-WORKBENCH2] updated: 1.1.4-483-gf7cdbfa
Git user
git at public.curoverse.com
Mon Aug 6 08:22:46 EDT 2018
Summary of changes:
src/models/link.ts | 10 +--------
src/models/tag.ts | 20 +++++++++++++++++
src/services/tag-service/tag-service.ts | 25 ++++++++++++----------
.../collection-panel/collection-panel-action.ts | 23 ++++++++++----------
.../collection-panel/collection-panel-reducer.ts | 4 ++--
src/views/collection-panel/collection-panel.tsx | 8 +++----
6 files changed, 52 insertions(+), 38 deletions(-)
create mode 100644 src/models/tag.ts
via f7cdbfa28c3867076fe25feb5d89b62592a9bf81 (commit)
from 2e60bb998178752c3a126f077cbb891b597ed91e (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 f7cdbfa28c3867076fe25feb5d89b62592a9bf81
Author: Janicki Artur <artur.janicki at contractors.roche.com>
Date: Mon Aug 6 14:22:37 2018 +0200
create tag model and change code
Feature #13854
Arvados-DCO-1.1-Signed-off-by: Janicki Artur <artur.janicki at contractors.roche.com>
diff --git a/src/models/link.ts b/src/models/link.ts
index 8665c9e..da9dfd0 100644
--- a/src/models/link.ts
+++ b/src/models/link.ts
@@ -9,15 +9,7 @@ export interface LinkResource extends Resource {
tailUuid: string;
linkClass: string;
name: string;
- properties: {
- key?: string;
- value?: any;
- };
-}
-
-export enum TailType {
- COLLECTION = 'Collection',
- JOB = 'Job'
+ properties: {};
}
export enum LinkClass {
diff --git a/src/models/tag.ts b/src/models/tag.ts
new file mode 100644
index 0000000..9c229af
--- /dev/null
+++ b/src/models/tag.ts
@@ -0,0 +1,20 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { LinkResource } from "./link";
+
+export interface TagResource extends LinkResource {
+ tailUuid: TagTailType;
+ properties: TagProperty;
+}
+
+export interface TagProperty {
+ key: string;
+ value: string;
+}
+
+export enum TagTailType {
+ COLLECTION = 'Collection',
+ JOB = 'Job'
+}
\ No newline at end of file
diff --git a/src/services/tag-service/tag-service.ts b/src/services/tag-service/tag-service.ts
index 78c930d..d8caca2 100644
--- a/src/services/tag-service/tag-service.ts
+++ b/src/services/tag-service/tag-service.ts
@@ -3,34 +3,37 @@
// SPDX-License-Identifier: AGPL-3.0
import { LinkService } from "../link-service/link-service";
-import { LinkResource, LinkClass, TailType } from "../../models/link";
+import { LinkClass } from "../../models/link";
import { FilterBuilder } from "../../common/api/filter-builder";
+import { TagTailType, TagResource } from "../../models/tag";
export class TagService {
constructor(private linkService: LinkService) { }
create(uuid: string, data: { key: string; value: string } ) {
- return this.linkService.create({
- headUuid: uuid,
- tailUuid: TailType.COLLECTION,
- linkClass: LinkClass.TAG,
- name: '',
- properties: data
- });
+ return this.linkService
+ .create({
+ headUuid: uuid,
+ tailUuid: TagTailType.COLLECTION,
+ linkClass: LinkClass.TAG,
+ name: '',
+ properties: data
+ })
+ .then(tag => tag as TagResource );
}
list(uuid: string) {
const filters = FilterBuilder
- .create<LinkResource>()
+ .create<TagResource>()
.addEqual("headUuid", uuid)
- .addEqual("tailUuid", TailType.COLLECTION)
+ .addEqual("tailUuid", TagTailType.COLLECTION)
.addEqual("linkClass", LinkClass.TAG);
return this.linkService
.list({ filters })
.then(results => {
- return results.items;
+ return results.items.map((tag => tag as TagResource ));
});
}
diff --git a/src/store/collection-panel/collection-panel-action.ts b/src/store/collection-panel/collection-panel-action.ts
index 083e548..01f430c 100644
--- a/src/store/collection-panel/collection-panel-action.ts
+++ b/src/store/collection-panel/collection-panel-action.ts
@@ -8,15 +8,16 @@ import { ResourceKind } from "../../models/resource";
import { CollectionResource } from "../../models/collection";
import { RootState } from "../store";
import { ServiceRepository } from "../../services/services";
-import { LinkClass, LinkResource } from "../../models/link";
+import { TagResource, TagProperty } from "../../models/tag";
+import { snackbarActions } from "../snackbar/snackbar-actions";
export const collectionPanelActions = unionize({
LOAD_COLLECTION: ofType<{ uuid: string, kind: ResourceKind }>(),
LOAD_COLLECTION_SUCCESS: ofType<{ item: CollectionResource }>(),
LOAD_COLLECTION_TAGS: ofType<{ uuid: string }>(),
- LOAD_COLLECTION_TAGS_SUCCESS: ofType<{ tags: LinkResource[] }>(),
+ LOAD_COLLECTION_TAGS_SUCCESS: ofType<{ tags: TagResource[] }>(),
CREATE_COLLECTION_TAG: ofType<{ data: any }>(),
- CREATE_COLLECTION_TAG_SUCCESS: ofType<{ tag: LinkResource }>()
+ CREATE_COLLECTION_TAG_SUCCESS: ofType<{ tag: TagResource }>()
}, { tag: 'type', value: 'payload' });
export type CollectionPanelAction = UnionOf<typeof collectionPanelActions>;
@@ -42,18 +43,16 @@ export const loadCollectionTags = (uuid: string) =>
};
-export const createCollectionTag = (uuid: string, data: {}) =>
+export const createCollectionTag = (uuid: string, data: TagProperty) =>
(dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- const linkResource = {
- key: 'testowanie',
- value: 'by Arturo'
- };
-
- dispatch(collectionPanelActions.CREATE_COLLECTION_TAG({ data: linkResource }));
+ dispatch(collectionPanelActions.CREATE_COLLECTION_TAG({ data }));
return services.tagService
- .create(uuid, linkResource)
+ .create(uuid, data)
.then(tag => {
- console.log('tag: ', tag);
dispatch(collectionPanelActions.CREATE_COLLECTION_TAG_SUCCESS({ tag }));
+ dispatch(snackbarActions.OPEN_SNACKBAR({
+ message: "Tag has been successfully added.",
+ hideDuration: 2000
+ }));
});
};
diff --git a/src/store/collection-panel/collection-panel-reducer.ts b/src/store/collection-panel/collection-panel-reducer.ts
index 61f4127..ac07ae3 100644
--- a/src/store/collection-panel/collection-panel-reducer.ts
+++ b/src/store/collection-panel/collection-panel-reducer.ts
@@ -4,11 +4,11 @@
import { collectionPanelActions, CollectionPanelAction } from "./collection-panel-action";
import { CollectionResource } from "../../models/collection";
-import { LinkResource } from "../../models/link";
+import { TagResource } from "../../models/tag";
export interface CollectionPanelState {
item: CollectionResource | null;
- tags: LinkResource[];
+ tags: TagResource[];
}
const initialState = {
diff --git a/src/views/collection-panel/collection-panel.tsx b/src/views/collection-panel/collection-panel.tsx
index 3296190..271fb8b 100644
--- a/src/views/collection-panel/collection-panel.tsx
+++ b/src/views/collection-panel/collection-panel.tsx
@@ -16,7 +16,7 @@ import { DetailsAttribute } from '../../components/details-attribute/details-att
import { CollectionResource } from '../../models/collection';
import * as CopyToClipboard from 'react-copy-to-clipboard';
import { createCollectionTag } from '../../store/collection-panel/collection-panel-action';
-import { LinkResource } from '../../models/link';
+import { TagResource } from '../../models/tag';
type CssRules = 'card' | 'iconHeader' | 'tag' | 'copyIcon';
@@ -41,7 +41,7 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
interface CollectionPanelDataProps {
item: CollectionResource;
- tags: LinkResource[];
+ tags: TagResource[];
}
interface CollectionPanelActionProps {
@@ -125,7 +125,7 @@ export const CollectionPanel = withStyles(styles)(
// Temporary method to add new tag
addTag = () => {
- this.props.dispatch<any>(createCollectionTag(this.props.item.uuid, 'dodalem nowy'));
+ this.props.dispatch<any>(createCollectionTag(this.props.item.uuid, { key: 'test', value: 'value for tag'}));
}
componentWillReceiveProps({ match, item, onItemRouteChange }: CollectionPanelProps) {
@@ -138,7 +138,7 @@ export const CollectionPanel = withStyles(styles)(
)
);
-const renderTagLabel = (tag: LinkResource) => {
+const renderTagLabel = (tag: TagResource) => {
const { properties } = tag;
return `${properties.key}: ${properties.value}`;
};
\ No newline at end of file
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list