import { Dispatch } from "redux";
import { ResourceKind } from "models/resource";
import { ProjectDetails } from "./project-details";
+import { RootProjectDetails } from './root-project-details';
import { CollectionDetails } from "./collection-details";
import { ProcessDetails } from "./process-details";
import { EmptyDetails } from "./empty-details";
import { FileDetails } from 'views-components/details-panel/file-details';
import { getNode } from 'models/tree';
import { resourceIsFrozen } from 'common/frozen-resources';
+import { CLOSE_DRAWER } from 'store/details-panel/details-panel-action';
type CssRules = 'root' | 'container' | 'opened' | 'headerContainer' | 'headerIcon' | 'tabContainer';
const EMPTY_RESOURCE: EmptyResource = { kind: undefined, name: 'Projects' };
-const getItem = (res: DetailsResource): DetailsData => {
+const getItem = (res: DetailsResource, pathName: string): DetailsData => {
if ('kind' in res) {
switch (res.kind) {
case ResourceKind.PROJECT:
return new ProcessDetails(res);
case ResourceKind.WORKFLOW:
return new WorkflowDetails(res);
+ case ResourceKind.USER:
+ if(pathName.includes('projects')) {
+ return new RootProjectDetails(res);
+ }
default:
- return new EmptyDetails(res);
+ return new EmptyDetails(res as EmptyResource);
}
} else {
return new FileDetails(res);
}
};
-const mapStateToProps = ({ auth, detailsPanel, resources, collectionPanelFiles, multiselect, router }: RootState) => {
- const isDetailsResourceChecked = multiselect.checkedList[detailsPanel.resourceUuid]
- const currentRoute = router.location ? router.location.pathname : "";
- const currentItemUuid = isDetailsResourceChecked || currentRoute.includes('collections') ? detailsPanel.resourceUuid : multiselect.selectedUuid ? multiselect.selectedUuid : currentRoute.split('/')[2];
- const resource = getResource(currentItemUuid)(resources) as DetailsResource | undefined;
+const mapStateToProps = ({ auth, detailsPanel, resources, collectionPanelFiles, selectedResourceUuid, properties, router }: RootState) => {
+ const resource = getResource(selectedResourceUuid ?? properties.currentRouteUuid)(resources) as DetailsResource | undefined;
const file = resource
? undefined
: getNode(detailsPanel.resourceUuid)(collectionPanelFiles);
isOpened: detailsPanel.isOpened,
tabNr: detailsPanel.tabNr,
res: resource || (file && file.value) || EMPTY_RESOURCE,
+ pathname: router.location ? router.location.pathname : "",
};
};
const mapDispatchToProps = (dispatch: Dispatch) => ({
- onCloseDrawer: () => {
- dispatch<any>(toggleDetailsPanel());
+ onCloseDrawer: (currentItemId) => {
+ dispatch<any>(toggleDetailsPanel(currentItemId));
},
setActiveTab: (tabNr: number) => {
dispatch<any>(openDetailsPanel(undefined, tabNr));
});
export interface DetailsPanelDataProps {
- onCloseDrawer: () => void;
+ onCloseDrawer: (currentItemId) => void;
setActiveTab: (tabNr: number) => void;
authConfig: Config;
isOpened: boolean;
tabNr: number;
res: DetailsResource;
isFrozen: boolean;
+ pathname: string;
}
type DetailsPanelProps = DetailsPanelDataProps & WithStyles<CssRules>;
}
renderContent() {
- const { classes, onCloseDrawer, res, tabNr, authConfig } = this.props;
-
+ const { classes, onCloseDrawer, res, tabNr, authConfig, pathname } = this.props;
let shouldShowInlinePreview = false;
if (!('kind' in res)) {
shouldShowInlinePreview = isInlineFileUrlSafe(
) || authConfig.clusterConfig.Collections.TrustAllContent;
}
- const item = getItem(res);
+ const item = getItem(res, pathname);
return <Grid
data-cy='details-panel'
container
</Tooltip>
</Grid>
<Grid item>
- <IconButton color="inherit" onClick={onCloseDrawer}>
+ <IconButton color="inherit" onClick={()=>onCloseDrawer(CLOSE_DRAWER)}>
<CloseIcon />
</IconButton>
</Grid>