const grey600 = grey["600"];
const grey700 = grey["700"];
const grey900 = grey["900"];
+const rocheBlue = '#06C';
const themeOptions: ArvadosThemeOptions = {
customs: {
color: purple800
}
}
+ },
+ MuiChip: {
+ root: {
+ color: 'white',
+ backgroundColor: rocheBlue
+ }
}
},
mixins: {
},
palette: {
primary: {
- main: '#06C',
+ main: rocheBlue,
dark: blue.A100
}
}
tailUuid: string;
linkClass: string;
name: string;
- properties: {};
+ properties: {
+ key?: string;
+ value?: any;
+ };
+}
+
+export enum TailType {
+ COLLECTION = 'Collection',
+ JOB = 'Job'
}
export enum LinkClass {
- STAR = 'star'
+ STAR = 'star',
+ TAG = 'tag'
}
\ No newline at end of file
import { FavoriteService } from "./favorite-service/favorite-service";
import { AxiosInstance } from "axios";
import { CommonResourceService } from "../common/api/common-resource-service";
-import { CollectionResource } from "../models/collection";
import { Resource } from "../models/resource";
import { CollectionService } from "./collection-service/collection-service";
+import { TagService } from "./tag-service/tag-service";
import Axios from "axios";
export interface ServiceRepository {
linkService: LinkService;
favoriteService: FavoriteService;
collectionService: CommonResourceService<Resource>;
+ tagService: TagService;
}
export const createServices = (baseUrl: string): ServiceRepository => {
const linkService = new LinkService(apiClient);
const favoriteService = new FavoriteService(linkService, groupsService);
const collectionService = new CollectionService(apiClient);
-
+ const tagService = new TagService(linkService);
+
return {
apiClient,
authService,
projectService,
linkService,
favoriteService,
- collectionService
+ collectionService,
+ tagService
};
};
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { LinkService } from "../link-service/link-service";
+import { LinkResource, LinkClass, TailType } from "../../models/link";
+import { FilterBuilder } from "../../common/api/filter-builder";
+
+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
+ });
+ }
+
+ list(uuid: string) {
+ const filters = FilterBuilder
+ .create<LinkResource>()
+ .addEqual("headUuid", uuid)
+ .addEqual("tailUuid", TailType.COLLECTION)
+ .addEqual("linkClass", LinkClass.TAG);
+
+ return this.linkService
+ .list({ filters })
+ .then(results => {
+ return results.items;
+ });
+ }
+
+}
\ No newline at end of file
import { CollectionResource } from "../../models/collection";
import { RootState } from "../store";
import { ServiceRepository } from "../../services/services";
+import { LinkClass, LinkResource } from "../../models/link";
export const collectionPanelActions = unionize({
LOAD_COLLECTION: ofType<{ uuid: string, kind: ResourceKind }>(),
- LOAD_COLLECTION_SUCCESS: ofType<{ item: CollectionResource }>()
+ LOAD_COLLECTION_SUCCESS: ofType<{ item: CollectionResource }>(),
+ LOAD_COLLECTION_TAGS: ofType<{ uuid: string }>(),
+ LOAD_COLLECTION_TAGS_SUCCESS: ofType<{ tags: LinkResource[] }>(),
+ CREATE_COLLECTION_TAG: ofType<{ data: any }>(),
+ CREATE_COLLECTION_TAG_SUCCESS: ofType<{ tag: LinkResource }>()
}, { tag: 'type', value: 'payload' });
export type CollectionPanelAction = UnionOf<typeof collectionPanelActions>;
});
};
+export const loadCollectionTags = (uuid: string) =>
+ (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ dispatch(collectionPanelActions.LOAD_COLLECTION_TAGS({ uuid }));
+ return services.tagService
+ .list(uuid)
+ .then(tags => {
+ dispatch(collectionPanelActions.LOAD_COLLECTION_TAGS_SUCCESS({ tags }));
+ });
+ };
+export const createCollectionTag = (uuid: string, data: {}) =>
+ (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ const linkResource = {
+ key: 'testowanie',
+ value: 'by Arturo'
+ };
+
+ dispatch(collectionPanelActions.CREATE_COLLECTION_TAG({ data: linkResource }));
+ return services.tagService
+ .create(uuid, linkResource)
+ .then(tag => {
+ console.log('tag: ', tag);
+ dispatch(collectionPanelActions.CREATE_COLLECTION_TAG_SUCCESS({ tag }));
+ });
+ };
import { collectionPanelActions, CollectionPanelAction } from "./collection-panel-action";
import { CollectionResource } from "../../models/collection";
+import { LinkResource } from "../../models/link";
export interface CollectionPanelState {
item: CollectionResource | null;
+ tags: LinkResource[];
}
const initialState = {
- item: null
+ item: null,
+ tags: []
};
export const collectionPanelReducer = (state: CollectionPanelState = initialState, action: CollectionPanelAction) =>
collectionPanelActions.match(action, {
default: () => state,
- LOAD_COLLECTION: () => state,
LOAD_COLLECTION_SUCCESS: ({ item }) => ({ ...state, item }),
+ LOAD_COLLECTION_TAGS_SUCCESS: ({ tags }) => ({...state, tags}),
+ CREATE_COLLECTION_TAG_SUCCESS: ({ tag }) => ({...state, tags: [...state.tags, tag] })
});
import * as React from 'react';
import {
StyleRulesCallback, WithStyles, withStyles, Card,
- CardHeader, IconButton, CardContent, Grid, Chip
+ CardHeader, IconButton, CardContent, Grid, Chip, TextField, Button
} from '@material-ui/core';
-import { connect } from 'react-redux';
+import { connect, DispatchProp } from "react-redux";
import { RouteComponentProps } from 'react-router';
import { ArvadosTheme } from '../../common/custom-theme';
import { RootState } from '../../store/store';
import { DetailsAttribute } from '../../components/details-attribute/details-attribute';
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';
type CssRules = 'card' | 'iconHeader' | 'tag' | 'copyIcon';
copyIcon: {
marginLeft: theme.spacing.unit,
fontSize: '1.125rem',
+ color: theme.palette.grey["500"],
cursor: 'pointer'
}
});
interface CollectionPanelDataProps {
item: CollectionResource;
+ tags: LinkResource[];
}
interface CollectionPanelActionProps {
onContextMenu: (event: React.MouseEvent<HTMLElement>, item: CollectionResource) => void;
}
-type CollectionPanelProps = CollectionPanelDataProps & CollectionPanelActionProps
+type CollectionPanelProps = CollectionPanelDataProps & CollectionPanelActionProps & DispatchProp
& WithStyles<CssRules> & RouteComponentProps<{ id: string }>;
export const CollectionPanel = withStyles(styles)(
- connect((state: RootState) => ({ item: state.collectionPanel.item }))(
+ connect((state: RootState) => ({
+ item: state.collectionPanel.item,
+ tags: state.collectionPanel.tags
+ }))(
class extends React.Component<CollectionPanelProps> {
render() {
- const { classes, item, onContextMenu } = this.props;
+ const { classes, item, tags, onContextMenu } = this.props;
return <div>
<Card className={classes.card}>
<CardHeader
<CardHeader title="Tags" />
<CardContent>
<Grid container direction="column">
- <Grid item xs={4}>
- <Chip label="Tag 1" className={classes.tag}/>
- <Chip label="Tag 2" className={classes.tag}/>
- <Chip label="Tag 3" className={classes.tag}/>
+ <Grid item xs={12}>
+ {/* Temporarty button to add new tag */}
+ <Button onClick={this.addTag}>Add Tag</Button>
+ </Grid>
+ <Grid item xs={12}>
+ {
+ tags.map(tag => {
+ return <Chip key={tag.etag} className={classes.tag}
+ label={renderTagLabel(tag)} />;
+ })
+ }
</Grid>
</Grid>
</CardContent>
</div>;
}
+ // Temporary method to add new tag
+ addTag = () => {
+ this.props.dispatch<any>(createCollectionTag(this.props.item.uuid, 'dodalem nowy'));
+ }
+
componentWillReceiveProps({ match, item, onItemRouteChange }: CollectionPanelProps) {
if (!item || match.params.id !== item.uuid) {
onItemRouteChange(match.params.id);
}
)
-);
\ No newline at end of file
+);
+
+const renderTagLabel = (tag: LinkResource) => {
+ const { properties } = tag;
+ return `${properties.key}: ${properties.value}`;
+};
\ No newline at end of file
import { favoritePanelActions } from '../../store/favorite-panel/favorite-panel-action';
import { CreateCollectionDialog } from '../../views-components/create-collection-dialog/create-collection-dialog';
import { CollectionPanel } from '../collection-panel/collection-panel';
-import { loadCollection } from '../../store/collection-panel/collection-panel-action';
+import { loadCollection, loadCollectionTags } from '../../store/collection-panel/collection-panel-action';
import { getCollectionUrl } from '../../models/collection';
import { UpdateCollectionDialog } from '../../views-components/update-collection-dialog/update-collection-dialog.';
import { AuthService } from "../../services/auth-service/auth-service";
}
renderCollectionPanel = (props: RouteComponentProps<{ id: string }>) => <CollectionPanel
- onItemRouteChange={(collectionId) => this.props.dispatch<any>(loadCollection(collectionId, ResourceKind.COLLECTION))}
+ onItemRouteChange={(collectionId) => {
+ this.props.dispatch<any>(loadCollection(collectionId, ResourceKind.COLLECTION));
+ this.props.dispatch<any>(loadCollectionTags(collectionId));
+ }}
onContextMenu={(event, item) => {
this.openContextMenu(event, {
uuid: item.uuid,