Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programmatic Creation of Roles and Teams #4303

Merged
merged 23 commits into from
Oct 4, 2024
Merged

Conversation

adrians5j
Copy link
Member

@adrians5j adrians5j commented Oct 1, 2024

Changes

This PR enables users to create roles and teams programatically. For example:

// extensions/customRolesTeams/src/index.ts
import { createSecurityRolePlugin, createSecurityTeamPlugin } from "@webiny/api-serverless-cms";

export const createExtension = () => {
    return [
        createSecurityRolePlugin({
            id: "test-role",
            name: "Test Role",
            description: "Test role defined via an extension.",
            permissions: [{ name: "cms.*" }]
        }),
        createSecurityTeamPlugin({
            id: "test-team",
            name: "Test Team",
            description: "Test team defined via an extension.",
            roles: ["test-role"]
        })
    ];
};

With the above code in place, In the UI, users can see the following:
image

Additional Changes

1. Copy Permissions Button

This PR also adds the "Copy Permissions as JSON" button to all users. Previously this feature was hidden behind a feature flag:

image

With this feature, users will be able to define permissions property in the createSecurityRolePlugin function much easier, because they'll just be able to select the desired permissions, copy them as JSON, and then paste them into their plugin.

2. Added createTestWcpLicense Testing Utility

The createTestWcpLicense utility was added in the @webiny/wcp package, so that it can be used in Jest tests.

3. Added Teams-related Tests

I've added basic tests for Teams functionality. They did not exist before. 🤯

How Has This Been Tested?

Manually / Jest.

Documentation

Changelog.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@adrians5j adrians5j added this to the 5.41.0 milestone Oct 1, 2024
@adrians5j adrians5j requested a review from Pavel910 October 2, 2024 07:54
@adrians5j adrians5j marked this pull request as ready for review October 2, 2024 08:48
Copy link
Collaborator

@Pavel910 Pavel910 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adrians5j I did a review, and posted some thoughts. We can talk this over via a call, if you'd like to discuss the suggestions.

Copy link
Collaborator

@Pavel910 Pavel910 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adrians5j I'm approving this now, because the feature works. I'll submit a separate PR with improvements to the code itself, so we can do it in parallel with the release preparations.

@adrians5j adrians5j merged commit 80f00cb into next Oct 4, 2024
96 of 97 checks passed
@adrians5j adrians5j deleted the feat/programmatic-teams-roles branch November 12, 2024 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants