--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+const USER_UUID_REGEX = /.*tpzed.*/;
+const GROUP_UUID_REGEX = /.*-j7d0g-.*/;
+
+export enum ObjectTypes {
+ USER,
+ GROUP,
+ UNKNOWN
+}
+
+export const getUuidObjectType = (uuid: string) => {
+ switch(true) {
+ case USER_UUID_REGEX.test(uuid):
+ return ObjectTypes.USER;
+ case GROUP_UUID_REGEX.test(uuid):
+ return ObjectTypes.GROUP;
+ default:
+ return ObjectTypes.UNKNOWN;
+ }
+ };
\ No newline at end of file
import { ServiceRepository } from "../../services/services";
import { sidePanelActions } from "../side-panel/side-panel-action";
import { SidePanelIdentifiers } from "../side-panel/side-panel-reducer";
+import { getUuidObjectType, ObjectTypes } from "../../models/object-types";
export const getResourceUrl = <T extends Resource>(resource: T): string => {
switch (resource.kind) {
});
};
-const USER_UUID_REGEX = /.*tpzed.*/;
-
export const loadProjectAncestors = async (uuid: string, projectService: ProjectService): Promise<Array<ProjectResource>> => {
- if (USER_UUID_REGEX.test(uuid)) {
+ if (getUuidObjectType(uuid) === ObjectTypes.USER) {
return [];
} else {
const currentProject = await projectService.get(uuid);
import { resourceLabel } from '../../common/labels';
import { ArvadosTheme } from '../../common/custom-theme';
import { renderName, renderStatus, renderType, renderOwner, renderFileSize, renderDate } from '../../views-components/data-explorer/renderers';
+import { restoreBranch } from '../../store/navigation/navigation-action';
type CssRules = "toolbar" | "button";
interface ProjectPanelDataProps {
currentItemId: string;
+ isSidePanelOpen: boolean;
}
interface ProjectPanelActionProps {
& WithStyles<CssRules> & RouteComponentProps<{ id: string }>;
export const ProjectPanel = withStyles(styles)(
- connect((state: RootState) => ({ currentItemId: state.projects.currentItemId }))(
+ connect((state: RootState) => ({ currentItemId: state.projects.currentItemId, isSidePanelOpen: state.sidePanel[0].open }))(
class extends React.Component<ProjectPanelProps> {
render() {
const { classes } = this.props;
handleNewCollectionClick = () => {
this.props.onCollectionCreationDialogOpen(this.props.currentItemId);
}
+
componentWillReceiveProps({ match, currentItemId, onItemRouteChange }: ProjectPanelProps) {
if (match.params.id !== currentItemId) {
onItemRouteChange(match.params.id);
}
}
+
+ componentDidMount() {
+ if (this.props.match.params.id && !this.props.isSidePanelOpen) {
+ this.props.dispatch<any>(restoreBranch(this.props.match.params.id));
+ }
+ }
}
)
);
user?: User;
currentToken?: string;
sidePanelItems: SidePanelItem[];
- router?: any;
}
interface WorkbenchServiceProps {
currentProjectId: state.projects.currentItemId,
user: state.auth.user,
currentToken: state.auth.apiToken,
- sidePanelItems: state.sidePanel,
- router: state.router.location
+ sidePanelItems: state.sidePanel
})
)(
class extends React.Component<WorkbenchProps, WorkbenchState> {
}
};
- componentDidMount() {
- const PROJECT_URL_REGEX = /\/projects\/(.*)/;
- const getProjectIdFromUrl = (url: string) => {
- const match = PROJECT_URL_REGEX.exec(url);
- return match ? match[1] : match;
- };
-
- const id = getProjectIdFromUrl(this.props.router.pathname);
- if (id) {
- this.props.dispatch<any>(restoreBranch(id));
- }
- }
-
render() {
const path = getTreePath(this.props.projects, this.props.currentProjectId);
const breadcrumbs = path.map(item => ({