}));
}
- update(uuid: string) {
- throw new Error("Not implemented");
+ update(uuid: string, data: any) {
+ return CommonResourceService.defaultResponse(
+ this.serverApi
+ .put<T>(this.resourceType + uuid, data));
+
}
}
return collectionService
.get(uuid)
.then(item => {
- dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item: item as CollectionResource }));
+ dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item }));
});
};
import { RootState } from "../../store";
import { collectionService } from '../../../services/services';
import { CollectionResource } from '../../../models/collection';
+import { initialize } from 'redux-form';
+import { collectionPanelActions } from "../../collection-panel/collection-panel-action";
export const collectionUpdatorActions = unionize({
- OPEN_COLLECTION_UPDATOR: ofType<{ ownerUuid: string }>(),
+ OPEN_COLLECTION_UPDATOR: ofType<{ uuid: string }>(),
CLOSE_COLLECTION_UPDATOR: ofType<{}>(),
- UPDATE_COLLECTION: ofType<{}>(),
UPDATE_COLLECTION_SUCCESS: ofType<{}>(),
}, {
tag: 'type',
value: 'payload'
});
+
+export const COLLECTION_FORM_NAME = 'collectionEditDialog';
+
+export const openUpdator = (uuid: string) =>
+ (dispatch: Dispatch, getState: () => RootState) => {
+ dispatch(collectionUpdatorActions.OPEN_COLLECTION_UPDATOR({ uuid }));
+ const item = getState().collectionPanel.item;
+ if(item) {
+ dispatch(initialize(COLLECTION_FORM_NAME, { name: item.name, description: item.description }));
+ }
+ };
+
export const updateCollection = (collection: Partial<CollectionResource>) =>
(dispatch: Dispatch, getState: () => RootState) => {
- const { ownerUuid } = getState().collections.creator;
- const collectiontData = { ownerUuid, ...collection };
- dispatch(collectionUpdatorActions.UPDATE_COLLECTION(collectiontData));
+ const { uuid } = getState().collections.updator;
return collectionService
- // change for update
- .create(collectiontData)
- .then(collection => dispatch(collectionUpdatorActions.UPDATE_COLLECTION_SUCCESS(collection)));
+ .update(uuid, collection)
+ .then(collection => {
+ dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item: collection }));
+ dispatch(collectionUpdatorActions.UPDATE_COLLECTION_SUCCESS());
+ }
+ );
};
export type CollectionUpdatorAction = UnionOf<typeof collectionUpdatorActions>;
\ No newline at end of file
interface CollectionUpdator {
opened: boolean;
- ownerUuid: string;
+ uuid: string;
}
const updateCollection = (state: CollectionUpdatorState, updator?: Partial<CollectionUpdator>) => ({
const initialState: CollectionUpdatorState = {
opened: false,
- ownerUuid: ''
+ uuid: ''
};
export const collectionCreationReducer = (state: CollectionUpdatorState = initialState, action: CollectionUpdatorAction) => {
return collectionUpdatorActions.match(action, {
- OPEN_COLLECTION_UPDATOR: ({ ownerUuid }) => updateCollection(state, { ownerUuid, opened: true }),
+ OPEN_COLLECTION_UPDATOR: ({ uuid }) => updateCollection(state, { uuid, opened: true }),
CLOSE_COLLECTION_UPDATOR: () => updateCollection(state, { opened: false }),
- UPDATE_COLLECTION: () => updateCollection(state),
- UPDATE_COLLECTION_SUCCESS: () => updateCollection(state, { opened: false, ownerUuid: "" }),
+ UPDATE_COLLECTION_SUCCESS: () => updateCollection(state, { opened: false, uuid: "" }),
default: () => state
});
};
import { dataExplorerActions } from "../../../store/data-explorer/data-explorer-action";
import { FAVORITE_PANEL_ID } from "../../../views/favorite-panel/favorite-panel";
import { RenameIcon, ShareIcon, MoveToIcon, CopyIcon, DetailsIcon, ProvenanceGraphIcon, AdvancedIcon, RemoveIcon } from "../../../components/icon/icon";
-import { collectionUpdatorActions } from "../../../store/collections/updator/collection-updator-action";
+import { openUpdator } from "../../../store/collections/updator/collection-updator-action";
export const collectionActionSet: ContextMenuActionSet = [[
{
icon: RenameIcon,
name: "Edit collection",
execute: (dispatch, resource) => {
- dispatch(collectionUpdatorActions.OPEN_COLLECTION_UPDATOR({ ownerUuid: resource.uuid }));
+ dispatch<any>(openUpdator(resource.uuid));
}
},
{
import { ArvadosTheme } from '../../common/custom-theme';
import { Dialog, DialogActions, DialogContent, DialogTitle, TextField, StyleRulesCallback, withStyles, WithStyles, Button, CircularProgress } from '../../../node_modules/@material-ui/core';
import { COLLECTION_NAME_VALIDATION, COLLECTION_DESCRIPTION_VALIDATION } from '../../validators/create-project/create-project-validator';
+import { COLLECTION_FORM_NAME } from '../../store/collections/updator/collection-updator-action';
type CssRules = 'content' | 'actions' | 'textField' | 'buttonWrapper' | 'saveButton' | 'circularProgress';
}
export const DialogCollectionUpdate = compose(
- reduxForm({ form: 'collectionEditDialog' }),
+ reduxForm({ form: COLLECTION_FORM_NAME }),
withStyles(styles))(
class DialogCollectionUpdate extends React.Component<DialogCollectionProps> {
<MoreOptionsIcon />
</IconButton>
}
- title={item && item.name } />
+ title={item && item.name }
+ subheader={item && item.description} />
<CardContent>
<Grid container direction="column">
<Grid item xs={6}>
- <DetailsAttribute label='Collection UUID' value={item && item.uuid}>
- Here I will add copy
- </DetailsAttribute>
+ <DetailsAttribute label='Collection UUID' value={item && item.uuid} />
<DetailsAttribute label='Content size' value='54 MB' />
<DetailsAttribute label='Owner' value={item && item.ownerUuid} />
</Grid>