Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3484 from vikram-raj/odc-1791
Bug 1779493: Disabled edit actions if the user has no permission
- Loading branch information
Showing
12 changed files
with
148 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
frontend/packages/dev-console/src/components/topology2/withEditReviewAccess.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import * as React from 'react'; | ||
import { observer } from 'mobx-react'; | ||
import { modelFor, referenceFor } from '@console/internal/module/k8s'; | ||
import { useAccessReview } from '@console/internal/components/utils'; | ||
import { Node } from '@console/topology'; | ||
import { getTopologyResourceObject } from '../topology/topology-utils'; | ||
|
||
type ComponentProps = { | ||
element: Node; | ||
}; | ||
|
||
export const withEditReviewAccess = () => (WrappedComponent: React.ComponentType) => { | ||
const Component: React.FC<ComponentProps> = (props) => { | ||
const resourceObj = getTopologyResourceObject(props.element.getData()); | ||
const resourceModel = modelFor(referenceFor(resourceObj)); | ||
const editAccess = useAccessReview({ | ||
group: resourceModel.apiGroup, | ||
verb: 'patch', | ||
resource: resourceModel.plural, | ||
name: resourceObj.metadata.name, | ||
namespace: resourceObj.metadata.namespace, | ||
}); | ||
return <WrappedComponent {...props as any} canEdit={editAccess} />; | ||
}; | ||
return observer(Component); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.