@contiamo/resource-role-assigner
v0.4.3
Published
This project allows our UIs to assign roles for a given user, group or API token (called a _principal_) _on_ a given resource: like a Bundle in Labs or a Data Source in Pantheon.
Downloads
9
Readme
Resource Role Assigner
This project allows our UIs to assign roles for a given user, group or API token (called a principal) on a given resource: like a Bundle in Labs or a Data Source in Pantheon.
In essence, this tool (expressed as a Modal window), allows a user to "make Peter an Admin of Catalog 123" in a user-friendly way.
Getting Started
npm install @contiamo/resource-role-assigner
- Consider the following use-case from Pantheon
import React, { useState } from "react"
import ResourceRoleAssigner from "@contiamo/resource-role-assigner"
const MyComponent = ({ catalog, dataSource, me }) => {
const [modalState, setModalState] = useState(false);
const availableRoles: ["Reader", "Editor", "Viewer"] = ["Reader", "Editor", "Viewer];
return (<ResourceRoleAssigner
onClose={() => setModalState(false)}
defaultRole="Editor"
roles={availableRoles}
resource={{
name: catalog.name,
permissionsUrl: `${getConfig("pantheon.backend")}/catalogs/${catalog.id}/dataSources/${dataSource.id}/permissions`,
requestOptions: {
headers: {
"x-double-cookie": Cookies.get("double-cookie"),
},
credentials: "include",
},
}}
idp={{
url: `${getConfig("auth")}/v2/${me.tenant.id}`,
usersUrl: `${getConfig("auth")}/v2/tenants/${me.tenant.id}/users`,
groupsUrl: `${getConfig( "auth")}/v2/tenants/${me.tenant.id}/realms/${catalog.id}/groups`,
}}
/>)
}
Contributing
This project uses Operational Scripts and has a familiar tooling set up. To contribute to this project, simply:
git clone
this repo,cd resource-role-assigner
npm install
code .
orvim
or spin up your editor of choice.- Go to town.
As usual, issues and pull requests are enabled in case any help is needed or discussions are to be had.
Happy coding!