},
lastButton: {
marginLeft: theme.spacing.unit,
- marginRight: "20px",
+ marginRight: "0",
},
formContainer: {
display: "flex",
flexDirection: "column",
- marginTop: "20px",
+ paddingBottom: "0",
},
dialogTitle: {
- paddingBottom: "0"
+ paddingTop: theme.spacing.unit,
+ paddingBottom: theme.spacing.unit,
},
progressIndicator: {
position: "absolute",
minWidth: "20px",
},
dialogActions: {
- marginBottom: theme.spacing.unit * 3
+ marginBottom: theme.spacing.unit,
+ marginRight: theme.spacing.unit * 3,
}
});
const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
textField: {
- marginBottom: theme.spacing.unit * 3
+ marginBottom: theme.spacing.unit
},
rte: {
fontFamily: 'Arial',
import { uploadCollectionFiles } from './collection-upload-actions';
import { fileUploaderActions } from '~/store/file-uploader/file-uploader-actions';
import { progressIndicatorActions } from "~/store/progress-indicator/progress-indicator-actions";
-import { isItemNotInProject, isProjectOrRunProcessRoute } from '~/store/projects/project-create-actions';
+import { isProjectOrRunProcessRoute } from '~/store/projects/project-create-actions';
import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions';
import { CollectionResource } from "~/models/collection";
export const openCollectionCreateDialog = (ownerUuid: string) =>
(dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- const router = getState();
- const properties = getState().properties;
- if (isItemNotInProject(properties) || !isProjectOrRunProcessRoute(router)) {
+ const { router } = getState();
+ if (!isProjectOrRunProcessRoute(router)) {
const userUuid = getUserUuid(getState());
if (!userUuid) { return; }
- dispatch(initialize(COLLECTION_CREATE_FORM_NAME, { userUuid }));
+ dispatch(initialize(COLLECTION_CREATE_FORM_NAME, { ownerUuid: userUuid }));
} else {
dispatch(initialize(COLLECTION_CREATE_FORM_NAME, { ownerUuid }));
}
import { ServiceRepository } from '~/services/services';
import { matchProjectRoute, matchRunProcessRoute } from '~/routes/routes';
import { ResourcePropertiesFormData } from '~/views-components/resource-properties-form/resource-properties-form';
+import { RouterState } from "react-router-redux";
export interface ProjectCreateFormDialogData {
ownerUuid: string;
export const PROJECT_CREATE_PROPERTIES_FORM_NAME = 'projectCreatePropertiesFormName';
export const PROJECT_CREATE_FORM_SELECTOR = formValueSelector(PROJECT_CREATE_FORM_NAME);
-export const isProjectOrRunProcessRoute = ({ router }: RootState) => {
+export const isProjectOrRunProcessRoute = (router: RouterState) => {
const pathname = router.location ? router.location.pathname : '';
const matchProject = matchProjectRoute(pathname);
const matchRunProcess = matchRunProcessRoute(pathname);
return Boolean(matchProject || matchRunProcess);
};
-export const isItemNotInProject = (properties: any) => {
- if (properties.breadcrumbs) {
- return Boolean(properties.breadcrumbs[0].label !== 'Projects');
- } else {
- return;
- }
-};
-
export const openProjectCreateDialog = (ownerUuid: string) =>
(dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- const router = getState();
- const properties = getState().properties;
- if (isItemNotInProject(properties) || !isProjectOrRunProcessRoute(router)) {
+ const { router } = getState();
+ if (!isProjectOrRunProcessRoute(router)) {
const userUuid = getUserUuid(getState());
if (!userUuid) { return; }
- dispatch(initialize(PROJECT_CREATE_FORM_NAME, { userUuid }));
+ dispatch(initialize(PROJECT_CREATE_FORM_NAME, { ownerUuid: userUuid }));
} else {
dispatch(initialize(PROJECT_CREATE_FORM_NAME, { ownerUuid }));
}
kind: SnackbarKind.SUCCESS
}));
await dispatch<any>(loadSidePanelTreeProjects(newProject.ownerUuid));
- dispatch<any>(reloadProjectMatchingUuid([newProject.ownerUuid]));
+ dispatch<any>(navigateTo(newProject.uuid));
}
};
kind: SnackbarKind.SUCCESS
}));
dispatch<any>(updateResources([collection]));
- dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
+ dispatch<any>(navigateTo(collection.uuid));
}
};
import { CollectionCreateFormDialogData } from '~/store/collections/collection-create-actions';
import { FormDialog } from '~/components/form-dialog/form-dialog';
import { CollectionNameField, CollectionDescriptionField } from '~/views-components/form-fields/collection-form-fields';
-import { require } from '~/validators/require';
import { FileUploaderField } from '../file-uploader/file-uploader';
-
+import { ResourceParentField } from '../form-fields/resource-form-fields';
type DialogCollectionProps = WithDialogProps<{}> & InjectedFormProps<CollectionCreateFormDialogData>;
/>;
const CollectionAddFields = () => <span>
+ <ResourceParentField />
<CollectionNameField />
<CollectionDescriptionField />
<Field
name='files'
- validate={[require]}
label='Files'
component={FileUploaderField} />
</span>;
import { ProjectNameField, ProjectDescriptionField } from '~/views-components/form-fields/project-form-fields';
import { CreateProjectPropertiesForm } from '~/views-components/project-properties/create-project-properties-form';
import { CreateProjectPropertiesList } from '~/views-components/project-properties/create-project-properties-list';
+import { ResourceParentField } from '../form-fields/resource-form-fields';
type DialogProjectProps = WithDialogProps<{}> & InjectedFormProps<ProjectCreateFormDialogData>;
/>;
const ProjectAddFields = () => <span>
+ <ResourceParentField />
<ProjectNameField />
<ProjectDescriptionField />
<CreateProjectPropertiesForm />
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from "react";
+import { connect } from "react-redux";
+import { RootState } from "~/store/store";
+import { Field } from "redux-form";
+import { ResourcesState, getResource } from "~/store/resources/resources";
+import { GroupResource } from "~/models/group";
+import { TextField } from "~/components/text-field/text-field";
+import { getUserUuid } from "~/common/getuser";
+
+interface ResourceParentFieldProps {
+ resources: ResourcesState;
+ userUuid: string|undefined;
+}
+
+export const ResourceParentField = connect(
+ (state: RootState) => {
+ return {
+ resources: state.resources,
+ userUuid: getUserUuid(state),
+ };
+ })
+ ((props: ResourceParentFieldProps) =>
+ <Field
+ name='ownerUuid'
+ disabled={true}
+ label='Parent project'
+ format={
+ (value, name) => {
+ if (value === props.userUuid) {
+ return 'Home project';
+ }
+ const rsc = getResource<GroupResource>(value)(props.resources);
+ if (rsc !== undefined) {
+ return `${rsc.name} (${rsc.uuid})`;
+ }
+ return value;
+ }
+ }
+ component={TextField} />
+ );
import * as React from 'react';
import { connect, DispatchProp } from 'react-redux';
import { RootState } from '~/store/store';
-import { getProperty } from '~/store/properties/properties';
-import { PROJECT_PANEL_CURRENT_UUID } from '~/store/project-panel/project-panel-action';
import { ArvadosTheme } from '~/common/custom-theme';
import { PopoverOrigin } from '@material-ui/core/Popover';
import { StyleRulesCallback, WithStyles, withStyles, Toolbar, Grid, Button, MenuItem, Menu } from '@material-ui/core';
import { openCollectionCreateDialog } from '~/store/collections/collection-create-actions';
import { navigateToRunProcess } from '~/store/navigation/navigation-action';
import { runProcessPanelActions } from '~/store/run-process-panel/run-process-panel-actions';
+import { getUserUuid } from '~/common/getuser';
+import { matchProjectRoute } from '~/routes/routes';
+import { GroupResource } from '~/models/group';
+import { ResourcesState, getResource } from '~/store/resources/resources';
+import { extractUuidKind, ResourceKind } from '~/models/resource';
type CssRules = 'button' | 'menuItem' | 'icon';
interface SidePanelDataProps {
location: any;
currentItemId: string;
+ resources: ResourcesState;
+ currentUserUUID: string | undefined;
}
interface SidePanelState {
horizontal: 0
};
+const isProjectTrashed = (proj: GroupResource, resources: ResourcesState): boolean => {
+ if (proj.isTrashed) { return true; }
+ if (extractUuidKind(proj.ownerUuid) === ResourceKind.USER) { return false; }
+ const parentProj = getResource<GroupResource>(proj.ownerUuid)(resources);
+ return isProjectTrashed(parentProj!, resources);
+};
+
export const SidePanelButton = withStyles(styles)(
connect((state: RootState) => ({
- currentItemId: getProperty(PROJECT_PANEL_CURRENT_UUID)(state.properties),
- location: state.router.location
+ currentItemId: state.router.location
+ ? state.router.location.pathname.split('/').slice(-1)[0]
+ : null,
+ location: state.router.location,
+ resources: state.resources,
+ currentUserUUID: getUserUuid(state),
}))(
class extends React.Component<SidePanelProps> {
};
render() {
- const { classes } = this.props;
+ const { classes, location, resources, currentUserUUID, currentItemId } = this.props;
const { anchorEl } = this.state;
+ let enabled = false;
+ if (currentItemId === currentUserUUID) {
+ enabled = true;
+ } else if (matchProjectRoute(location ? location.pathname : '')) {
+ const currentProject = getResource<GroupResource>(currentItemId)(resources);
+ if (currentProject &&
+ currentProject.writableBy.indexOf(currentUserUUID || '') >= 0 &&
+ !isProjectTrashed(currentProject, resources)) {
+ enabled = true;
+ }
+ }
return <Toolbar>
<Grid container>
<Grid container item xs alignItems="center" justify="flex-start">
- <Button variant="contained" color="primary" size="small" className={classes.button}
+ <Button variant="contained" disabled={!enabled}
+ color="primary" size="small" className={classes.button}
aria-owns={anchorEl ? 'aside-menu-list' : undefined}
aria-haspopup="true"
onClick={this.handleOpen}>
this.props.dispatch(runProcessPanelActions.RESET_RUN_PROCESS_PANEL());
this.props.dispatch(runProcessPanelActions.SET_PROCESS_PATHNAME(location.pathname));
this.props.dispatch(runProcessPanelActions.SET_PROCESS_OWNER_UUID(this.props.currentItemId));
-
+
this.props.dispatch<any>(navigateToRunProcess);
}