Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>
import { DetailsData } from "./details-data";
import { CollectionDetailsAttributes } from 'views/collection-panel/collection-panel';
import { RootState } from 'store/store';
-import { filterResources, getResource } from 'store/resources/resources';
+import { filterResources, getResource, ResourcesState } from 'store/resources/resources';
import { connect } from 'react-redux';
import { Button, Grid, ListItem, StyleRulesCallback, Typography, withStyles, WithStyles } from '@material-ui/core';
import { formatDate, formatFileSize } from 'common/formatters';
import { navigateTo } from 'store/navigation/navigation-action';
import { openContextMenu, resourceUuidToContextMenuKind } from 'store/context-menu/context-menu-actions';
import { openCollectionUpdateDialog } from 'store/collections/collection-update-actions';
+import { resourceIsFrozen } from 'common/frozen-resources';
export type CssRules = 'versionBrowserHeader'
| 'versionBrowserItem'
}
interface CollectionInfoDataProps {
+ resources: ResourcesState;
currentCollection: CollectionResource | undefined;
}
const ciMapStateToProps = (state: RootState): CollectionInfoDataProps => {
return {
+ resources: state.resources,
currentCollection: getResource<CollectionResource>(state.detailsPanel.resourceUuid)(state.resources),
};
};
const CollectionInfo = withStyles(styles)(
connect(ciMapStateToProps, ciMapDispatchToProps)(
- ({ currentCollection, editCollection, classes }: CollectionInfoProps) =>
+ ({ currentCollection, resources, editCollection, classes }: CollectionInfoProps) =>
currentCollection !== undefined
? <div>
<Button
+ disabled={resourceIsFrozen(currentCollection, resources)}
className={classes.editButton} variant='contained'
data-cy='details-panel-edit-btn' color='primary' size='small'
onClick={() => editCollection(currentCollection)}>
import { toggleDetailsPanel, SLIDE_TIMEOUT, openDetailsPanel } from 'store/details-panel/details-panel-action';
import { FileDetails } from 'views-components/details-panel/file-details';
import { getNode } from 'models/tree';
+import { resourceIsFrozen } from 'common/frozen-resources';
type CssRules = 'root' | 'container' | 'opened' | 'headerContainer' | 'headerIcon' | 'tabContainer';
const file = resource
? undefined
: getNode(detailsPanel.resourceUuid)(collectionPanelFiles);
+
+ let isFrozen = false;
+ if (resource) {
+ isFrozen = resourceIsFrozen(resource, resources);
+ }
+
return {
+ isFrozen,
authConfig: auth.config,
isOpened: detailsPanel.isOpened,
tabNr: detailsPanel.tabNr,
isOpened: boolean;
tabNr: number;
res: DetailsResource;
+ isFrozen: boolean;
}
type DetailsPanelProps = DetailsPanelDataProps & WithStyles<CssRules>;
import { ResourceWithName } from '../data-explorer/renderers';
import { GroupClass } from "models/group";
import { openProjectUpdateDialog, ProjectUpdateFormDialogData } from 'store/projects/project-update-actions';
+import { RootState } from 'store/store';
+import { ResourcesState } from 'store/resources/resources';
+import { resourceIsFrozen } from 'common/frozen-resources';
export class ProjectDetails extends DetailsData<ProjectResource> {
getIcon(className?: string) {
onClick: (prj: ProjectUpdateFormDialogData) => () => void;
}
+const mapStateToProps = (state: RootState): { resources: ResourcesState } => {
+ return {
+ resources: state.resources
+ };
+};
+
const mapDispatchToProps = (dispatch: Dispatch) => ({
onClick: (prj: ProjectUpdateFormDialogData) =>
() => dispatch<any>(openProjectUpdateDialog(prj)),
type ProjectDetailsComponentProps = ProjectDetailsComponentDataProps & ProjectDetailsComponentActionProps & WithStyles<CssRules>;
-const ProjectDetailsComponent = connect(null, mapDispatchToProps)(
+const ProjectDetailsComponent = connect(mapStateToProps, mapDispatchToProps)(
withStyles(styles)(
- ({ classes, project, onClick }: ProjectDetailsComponentProps) => <div>
+ ({ classes, project, resources, onClick }: ProjectDetailsComponentProps & { resources: ResourcesState }) => <div>
{project.groupClass !== GroupClass.FILTER ?
<Button onClick={onClick({
uuid: project.uuid,
description: project.description,
properties: project.properties,
})}
+ disabled={resourceIsFrozen(project, resources)}
className={classes.editButton} variant='contained'
data-cy='details-panel-edit-btn' color='primary' size='small'>
<RenameIcon className={classes.editIcon} /> Edit
import { Link as ButtonLink } from '@material-ui/core';
import { ResourceWithName, ResponsiblePerson } from 'views-components/data-explorer/renderers';
import { MPVContainer, MPVPanelContent, MPVPanelState } from 'components/multi-panel-view/multi-panel-view';
+import { resourceIsFrozen } from 'common/frozen-resources';
type CssRules = 'root'
| 'button'
}
}
}
+
+ if (item) {
+ isWritable = !resourceIsFrozen(item, state.resources);
+ }
+
return { item, isWritable, isOldVersion };
})(
class extends React.Component<CollectionPanelProps> {