import { projectActions, getProjectList } from "../project/project-action";
import { push } from "react-router-redux";
import { TreeItemStatus } from "../../components/tree/tree";
-import { findTreeItem } from "../project/project-reducer";
+import { findTreeItem, getTreePath } from "../project/project-reducer";
import { dataExplorerActions } from "../data-explorer/data-explorer-action";
import { PROJECT_PANEL_ID } from "../../views/project-panel/project-panel";
import { RootState } from "../store";
import { Resource, ResourceKind } from "../../models/resource";
import { getCollectionUrl } from "../../models/collection";
-import { getProjectUrl } from "../../models/project";
+import { getProjectUrl, ProjectResource } from "../../models/project";
+import { projectService } from "../../services/services";
export const getResourceUrl = <T extends Resource>(resource: T): string => {
switch (resource.kind) {
const treeItem = findTreeItem(projects.items, itemId);
if (treeItem) {
+ console.log('treeItem', treeItem);
+ const treePath = getTreePath(projects.items, treeItem.data.uuid);
+
+ console.log('treePath', treePath);
const resourceUrl = getResourceUrl(treeItem.data);
+ console.log('resourceUrl', resourceUrl);
+ const ancestors = loadProjectAncestors(treeItem.data.uuid);
+ console.log('ancestors', ancestors);
+
if (itemMode === ItemMode.ACTIVE || itemMode === ItemMode.BOTH) {
if (router.location && !router.location.pathname.includes(resourceUrl)) {
dispatch(push(resourceUrl));
}
- dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_ACTIVE(treeItem.data.uuid));
+ dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_ACTIVE(treePath[treePath.length - 1].id));
}
const promise = treeItem.status === TreeItemStatus.LOADED
}
};
+ const USER_UUID_REGEX = /.*tpzed.*/;
+
+ export const loadProjectAncestors = async (uuid: string): Promise<Array<ProjectResource>> => {
+ if (USER_UUID_REGEX.test(uuid)) {
+ return [];
+ } else {
+ const currentProject = await projectService.get(uuid);
+ const ancestors = await loadProjectAncestors(currentProject.ownerUuid);
+ return [...ancestors, currentProject];
+ }
+ };
\ No newline at end of file
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { require } from '../require';
+import { maxLength } from '../max-length';
+
+export const COLLECTION_NAME_VALIDATION = [require, maxLength(255)];
+export const COLLECTION_DESCRIPTION_VALIDATION = [maxLength(255)];
\ No newline at end of file
export const PROJECT_NAME_VALIDATION = [require, maxLength(255)];
export const PROJECT_DESCRIPTION_VALIDATION = [maxLength(255)];
-export const COLLECTION_NAME_VALIDATION = [require, maxLength(255)];
-export const COLLECTION_DESCRIPTION_VALIDATION = [maxLength(255)];
const { ownerUuid } = getState().projects.creator;
return dispatch<any>(createProject(data)).then(() => {
dispatch(snackbarActions.OPEN_SNACKBAR({
- message: "Created a new project",
+ message: "Project has been successfully created.",
hideDuration: 2000
}));
dispatch(dataExplorerActions.REQUEST_ITEMS({ id: PROJECT_PANEL_ID }));
import DialogTitle from '@material-ui/core/DialogTitle';
import { Button, StyleRulesCallback, WithStyles, withStyles, CircularProgress } from '@material-ui/core';
-import { COLLECTION_NAME_VALIDATION, COLLECTION_DESCRIPTION_VALIDATION } from '../../validators/create-project/create-project-validator';
+import { COLLECTION_NAME_VALIDATION, COLLECTION_DESCRIPTION_VALIDATION } from '../../validators/create-collection/create-collection-validator';
type CssRules = "button" | "lastButton" | "formContainer" | "textField" | "dialog" | "dialogTitle" | "createProgress" | "dialogActions";
user?: User;
currentToken?: string;
sidePanelItems: SidePanelItem[];
+ router?: any;
}
interface WorkbenchActionProps {
currentProjectId: state.projects.currentItemId,
user: state.auth.user,
currentToken: state.auth.apiToken,
- sidePanelItems: state.sidePanel
+ sidePanelItems: state.sidePanel,
+ router: state.router.location
})
)(
class extends React.Component<WorkbenchProps, WorkbenchState> {
}
};
+ componentDidMount() {
+ if (this.props.router.pathname.includes("/projects")) {
+ this.props.dispatch(sidePanelActions.TOGGLE_SIDE_PANEL_ITEM_OPEN(SidePanelIdentifiers.PROJECTS));
+ this.props.dispatch(sidePanelActions.TOGGLE_SIDE_PANEL_ITEM_ACTIVE(SidePanelIdentifiers.PROJECTS));
+ }
+ }
+
render() {
const path = getTreePath(this.props.projects, this.props.currentProjectId);
const breadcrumbs = path.map(item => ({
itemId: item.data.uuid,
status: item.status
}));
+ console.log("breadcrumbs", breadcrumbs);
const { classes, user } = this.props;
return (
);
}
- renderCollectionPanel = (props: RouteComponentProps<{ id: string }>) => <CollectionPanel
+ renderCollectionPanel = (props: RouteComponentProps<{ id: string }>) => <CollectionPanel
onItemRouteChange={(collectionId) => this.props.dispatch<any>(loadCollection(collectionId, ResourceKind.COLLECTION))}
onContextMenu={(event, item) => {
this.openContextMenu(event, {
case ResourceKind.COLLECTION:
this.props.dispatch<any>(loadCollection(item.uuid, item.kind as ResourceKind));
this.props.dispatch(push(getCollectionUrl(item.uuid)));
- default:
+ default:
this.props.dispatch<any>(setProjectItem(item.uuid, ItemMode.ACTIVE));
this.props.dispatch<any>(loadDetails(item.uuid, item.kind as ResourceKind));
}