-
Notifications
You must be signed in to change notification settings - Fork 6
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
Administration ORG/User/Packs UI update + Org Verification #6866
Conversation
WalkthroughThe changes introduce enhancements to the GraphQL schema, including new mutations for managing license plans and improvements to queries for organization and user data. A new section for verification notifications has been added to the translation files. UI components have been updated to include an Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant VirtualContributorWizard
participant PrivilegeCheck
participant InfoDialog
User->>VirtualContributorWizard: Start wizard
VirtualContributorWizard->>PrivilegeCheck: Check user privileges
PrivilegeCheck-->>VirtualContributorWizard: Return privileges
alt Insufficient Privileges
VirtualContributorWizard->>InfoDialog: Show insufficient privileges message
else Sufficient Privileges
VirtualContributorWizard->>User: Proceed with creation
end
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (7)
Files not reviewed due to no reviewable changes (1)
Files skipped from review due to trivial changes (1)
Files skipped from review as they are similar to previous changes (2)
Additional context usedBiome
Additional comments not posted (18)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range and nitpick comments (1)
src/domain/community/contributor/organization/adminOrganizations/AdminOrganizationsPage.tsx (1)
44-60
: LGTM, but add a TODO comment for the settings button click handler.The
orgActions
function correctly defines the action buttons for each organization item and handles the click events.However, the
onSettingsClick
function is currently empty. Please add a TODO comment to implement the assign license functionality.const onSettingsClick = (item: SearchableListItem) => { setSelectedItem(item); + // TODO: Implement assign license functionality };
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (11)
- src/core/apollo/generated/apollo-hooks.ts (2 hunks)
- src/core/apollo/generated/graphql-schema.ts (2 hunks)
- src/core/i18n/en/translation.en.json (1 hunks)
- src/domain/community/contributor/organization/adminOrganizations/AdminOrganizationsPage.tsx (1 hunks)
- src/domain/community/contributor/organization/adminOrganizations/adminGlobalOrganizationsList.graphql (1 hunks)
- src/domain/community/contributor/organization/adminOrganizations/useAdminGlobalOrganizationsList.ts (3 hunks)
- src/domain/innovationHub/InnovationHubsAdmin/AdminInnovationHubsPage.tsx (2 hunks)
- src/domain/platform/admin/templates/InnovationPacks/admin/AdminInnovationPacksPage.tsx (2 hunks)
- src/domain/shared/components/SearchableList/SimpleSearchableTable.tsx (6 hunks)
- src/main/admin/authorizationPolicies/AuthorizationPrivilegesForUser.tsx (1 hunks)
- src/main/admin/users/adminUsers/AdminUsersPage.tsx (1 hunks)
Files skipped from review due to trivial changes (1)
- src/main/admin/authorizationPolicies/AuthorizationPrivilegesForUser.tsx
Additional comments not posted (29)
src/domain/community/contributor/organization/adminOrganizations/adminGlobalOrganizationsList.graphql (2)
10-16
: LGTM!The addition of the
verification
field to theadminGlobalOrganizationsList
query is a valuable enhancement. It allows clients to access verification-related information for organizations in a structured and organized manner.
24-33
: LGTM!The introduction of the
adminOrganizationVerify
mutation is a great addition to the GraphQL API. It enables clients to perform verification actions on organizations and receive relevant lifecycle information in response.The mutation is well-structured, accepting an input of type
OrganizationVerificationEventInput
and returning an object with the organization'sid
andlifecycle
details. This design provides a clear and intuitive way for clients to interact with the verification functionality.src/main/admin/users/adminUsers/AdminUsersPage.tsx (2)
6-6
: LGTM!The import change is approved as it is consistent with the component change in the file.
14-14
: LGTM!The component change is approved for the following reasons:
- The component change is consistent with the import change.
- The
data
prop and the rest of the props are correctly passed to theSimpleSearchableTable
component.- The change suggests a shift from a list-based representation to a table format for displaying user data, which likely enhances the user interface by providing a more structured and potentially sortable view of the user information.
src/domain/innovationHub/InnovationHubsAdmin/AdminInnovationHubsPage.tsx (2)
11-11
: LGTM!The import change is approved.
Line range hint
48-56
: LGTM, but verify the component behavior.The component change is approved.
However, ensure that the
SimpleSearchableTable
component has been thoroughly tested to confirm that it behaves as expected and provides the desired enhancements over the previousSimpleSearchableList
component.Run the following script to verify the component behavior:
src/domain/platform/admin/templates/InnovationPacks/admin/AdminInnovationPacksPage.tsx (2)
12-12
: LGTM!The import statement change is approved. Using a shared component for the searchable table is a good practice for reusability.
Line range hint
49-57
: LGTM!The component usage change is approved. Replacing
SimpleSearchableList
withSimpleSearchableTable
while keeping the same props suggests thatSimpleSearchableTable
is a drop-in replacement that enhances the UI/UX by using a table format for displaying innovation packs.src/domain/community/contributor/organization/adminOrganizations/useAdminGlobalOrganizationsList.ts (5)
17-25
: LGTM!The added enums
OrgVerificationLifecycleStates
andOrgVerificationLifecycleEvents
are used to manage the verification states and events. The naming and values are appropriate.
56-98
: LGTM!The added
handleVerification
function correctly processes organization verification. It checks if the organization is already manually verified and triggers a reset event if so. If not, it attempts to initiate a verification request and handles any potential errors gracefully. It then proceeds to manually verify the organization if the verification request fails. The error handling and fallback to manual verification ensure a robust implementation.
106-106
: LGTM!The addition of the
verified
property to theorganizations
array enhances the data structure returned by the hook, providing more context for each organization.
116-116
: LGTM!Adding the
handleVerification
function to the return object of the hook exposes it to the consumers of the hook, allowing them to trigger organization verification.
5-5
: LGTM!The import of the
useAdminOrganizationVerifyMutation
hook is necessary for thehandleVerification
function to verify organizations.src/domain/community/contributor/organization/adminOrganizations/AdminOrganizationsPage.tsx (6)
1-13
: LGTM!The new imports are necessary for the updated functionality and UI changes.
16-23
: LGTM!The new state variables are necessary for managing the confirmation dialog and verification loading state in the organization verification flow.
25-42
: LGTM!The new functions correctly handle the verification flow by managing the confirmation dialog state and executing the verification process.
62-78
: LGTM!The
getStatusTranslation
andgetActionTranslation
functions correctly provide the appropriate translation based on the verification status of the selected organization.
83-83
: LGTM!The change to use
SimpleSearchableTable
aligns with the new table layout requirement and theitemActions
prop is correctly populated with theorgActions
function.
85-107
: LGTM!The
ConfirmationDialog
component is correctly configured to handle the organization verification confirmation and uses the appropriate translations and state variables.src/domain/shared/components/SearchableList/SimpleSearchableTable.tsx (5)
1-22
: LGTM!The code changes are approved.
43-43
: LGTM!The code changes are approved.
57-57
: LGTM!The code changes are approved.
94-94
: LGTM!The code changes are approved.
Line range hint
108-161
: LGTM!The code changes are approved.
src/core/i18n/en/translation.en.json (1)
1887-1899
: LGTM!The newly added "verification" section under "organization" looks good. It provides the necessary translations for confirmation dialogs when verifying/unverifying organizations.
src/core/apollo/generated/apollo-hooks.ts (2)
12268-12274
: LGTM!The changes to the
AdminGlobalOrganizationsListDocument
query are approved. The addition of theverification
field and its nested properties will provide access to verification-related information for organizations.
12342-12394
: LGTM!The introduction of the
AdminOrganizationVerifyDocument
mutation and associated types and hooks is approved. These changes will facilitate the verification process for organizations and simplify the execution of the mutation within React components.The custom hook
useAdminOrganizationVerifyMutation
is a nice addition that will make it easier for developers to use the mutation in their components.src/core/apollo/generated/graphql-schema.ts (2)
17736-17740
: LGTM!The new
verification
field has been correctly added to theAdminGlobalOrganizationsListQuery
type. The structure of the field matches the description provided in the AI-generated summary.
17751-17767
: LGTM!The new types
AdminOrganizationVerifyMutationVariables
andAdminOrganizationVerifyMutation
have been correctly added to the GraphQL schema. The structure of the types matches the description provided in the AI-generated summary.
Add/Remove License on Account - User/Organization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range and nitpick comments (1)
src/domain/community/contributor/organization/adminOrganizations/useAdminGlobalOrganizationsList.ts (1)
65-107
: ThehandleVerification
function looks good overall, but there are a few areas that could be improved:
Consider providing more specific error messages or handling different error scenarios when the
VERIFICATION_REQUEST
event fails. This will make it easier to diagnose and fix issues.The function is quite long and could benefit from being refactored into smaller, more focused functions. This will improve readability and maintainability.
Here's an example of how the function could be refactored:
const resetVerification = async (orgFullData: any) => { await verifyOrg({ variables: { input: { eventName: OrgVerificationLifecycleEvents.RESET, organizationVerificationID: orgFullData.verification.id, }, }, }); }; const requestVerification = async (orgFullData: any) => { try { await verifyOrg({ variables: { input: { eventName: OrgVerificationLifecycleEvents.VERIFICATION_REQUEST, organizationVerificationID: orgFullData.verification.id, }, }, }); } catch (e) { console.log('VERIFICATION_REQUEST event failed: ', e); } }; const manuallyVerifyOrg = async (orgFullData: any) => { await verifyOrg({ variables: { input: { eventName: OrgVerificationLifecycleEvents.MANUALLY_VERIFY, organizationVerificationID: orgFullData.verification.id, }, }, }); }; const handleVerification = async (item: SearchableListItem) => { const orgFullData = data?.organizationsPaginated?.organization?.find(org => org.id === item.id); if (!orgFullData) { return; } if (orgFullData.verification.lifecycle.state === OrgVerificationLifecycleStates.manuallyVerified) { await resetVerification(orgFullData); } else { await requestVerification(orgFullData); await manuallyVerifyOrg(orgFullData); } };
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (27)
- src/core/apollo/generated/apollo-helpers.ts (5 hunks)
- src/core/apollo/generated/apollo-hooks.ts (4 hunks)
- src/core/apollo/generated/graphql-schema.ts (8 hunks)
- src/core/i18n/en/translation.en.json (2 hunks)
- src/domain/InnovationPack/admin/AdminInnovationPacksPage.tsx (2 hunks)
- src/domain/community/contributor/organization/adminOrganizations/AdminOrganizationsPage.tsx (1 hunks)
- src/domain/community/contributor/organization/adminOrganizations/LicensePlanDialog.tsx (1 hunks)
- src/domain/community/contributor/organization/adminOrganizations/ManageLicensePlanAccount.graphql (1 hunks)
- src/domain/community/contributor/organization/adminOrganizations/adminGlobalOrganizationsList.graphql (1 hunks)
- src/domain/community/contributor/organization/adminOrganizations/useAdminGlobalOrganizationsList.ts (2 hunks)
- src/domain/community/user/adminUsers/useAdminGlobalUserList.tsx (5 hunks)
- src/domain/community/user/adminUsers/userList.graphql (2 hunks)
- src/domain/platform/admin/components/Organization/OrganizationForm.tsx (1 hunks)
- src/domain/platform/admin/opportunity/pages/OpportunityProfile/OpportunityProfileView.tsx (1 hunks)
- src/domain/shared/components/SearchableList/SearchableListLayout.tsx (2 hunks)
- src/domain/shared/components/SearchableList/SimpleSearchableTable.tsx (1 hunks)
- src/domain/templates/components/Dialogs/CreateEditTemplateDialog/CreateEditTemplateDialogBase.tsx (1 hunks)
- src/domain/templates/components/Forms/TemplateForm.tsx (2 hunks)
- src/domain/templates/components/Previews/CommunityGuidelinesTemplatePreview.tsx (1 hunks)
- src/domain/templates/components/Previews/InnovationFlowTemplatePreview.tsx (1 hunks)
- src/domain/templates/components/Previews/WhiteboardTemplatePreview.tsx (2 hunks)
- src/domain/templates/components/cards/TemplateCard.tsx (1 hunks)
- src/domain/templates/hooks/useCreateCalloutTemplate.ts (1 hunks)
- src/domain/templates/models/CollaborationTemplate.ts (1 hunks)
- src/domain/templates/models/CommunityGuidelinesTemplate.tsx (1 hunks)
- src/domain/templates/readme.md (0 hunks)
- src/main/admin/users/adminUsers/AdminUsersPage.tsx (1 hunks)
Files not reviewed due to no reviewable changes (1)
- src/domain/templates/readme.md
Files skipped from review due to trivial changes (10)
- src/domain/platform/admin/opportunity/pages/OpportunityProfile/OpportunityProfileView.tsx
- src/domain/templates/components/Dialogs/CreateEditTemplateDialog/CreateEditTemplateDialogBase.tsx
- src/domain/templates/components/Forms/TemplateForm.tsx
- src/domain/templates/components/Previews/CommunityGuidelinesTemplatePreview.tsx
- src/domain/templates/components/Previews/InnovationFlowTemplatePreview.tsx
- src/domain/templates/components/Previews/WhiteboardTemplatePreview.tsx
- src/domain/templates/components/cards/TemplateCard.tsx
- src/domain/templates/hooks/useCreateCalloutTemplate.ts
- src/domain/templates/models/CollaborationTemplate.ts
- src/domain/templates/models/CommunityGuidelinesTemplate.tsx
Files skipped from review as they are similar to previous changes (1)
- src/core/i18n/en/translation.en.json
Additional comments not posted (61)
src/domain/community/contributor/organization/adminOrganizations/ManageLicensePlanAccount.graphql (2)
1-9
: LGTM!The
AssignLicensePlanToAccount
mutation is well-defined with the appropriate arguments and return type. The mutation logic is correct, and the implementation is accurate.
11-19
: LGTM!The
RevokeLicensePlanFromAccount
mutation is well-defined with the appropriate arguments and return type, similar to theAssignLicensePlanToAccount
mutation. The mutation logic is correct, and the implementation is accurate.src/domain/community/user/adminUsers/userList.graphql (2)
5-10
: LGTM!The addition of the
account
field withid
andsubscriptions
enhances the data returned by theuserList
query, providing more context about users and their accounts. The GraphQL schema and syntax are correct.
23-34
: Looks good!The addition of the
platform
field withid
andlicensing
(containingid
andplans
withid
,name
,type
, andlicenseCredential
) provides a broader context regarding the platform's licensing details and available plans. The GraphQL schema and syntax are correct, and the nested structure of thelicensing
object allows for a clear organization of the licensing-related data.src/domain/community/contributor/organization/adminOrganizations/adminGlobalOrganizationsList.graphql (2)
Line range hint
1-39
: LGTM!The changes to the
adminGlobalOrganizationsList
query look good. The addition of theverification
field enhances the query to provide more comprehensive data about organizations' verification status. The inclusion of theplatform
field allows for retrieving relevant licensing information. The paginated structure of the query ensures efficient retrieval of organizations.
42-51
: LGTM!The addition of the
adminOrganizationVerify
mutation is a valuable enhancement. It enables administrative actions related to organization verification. The input parameter allows for passing necessary data to initiate the verification event. The returned fields, especially thelifecycle
field, provide insights into the current state and possible next events in the verification process. This mutation expands the capabilities of the GraphQL API for managing organization verification.src/domain/shared/components/SearchableList/SearchableListLayout.tsx (3)
1-7
: LGTM!The new imports align with the objective of updating the component to use Material-UI components and icons. The
RouterLink
andgutters
imports also suggest improvements to navigation and layout spacing.
20-20
: LGTM!The addition of the
paddingX
prop using thegutters
utility function improves the layout spacing and consistency.
25-29
: LGTM!The replacement of the custom
WrapperButton
with the Material-UIButton
component, along with the use ofAddOutlinedIcon
,RouterLink
, and the updated button text, aligns with the objectives of updating the component to use Material-UI components, enhancing the visual representation, maintaining routing functionality, and improving internationalization.src/domain/community/contributor/organization/adminOrganizations/LicensePlanDialog.tsx (4)
1-23
: LGTM!The imports and interface declaration are well-structured and clearly define the dependencies and props of the component.
25-33
: LGTM!The component declaration and props destructuring are correctly implemented, following the defined interface.
36-54
: LGTM!The component's return statement and the usage of
PlansTable
andAssignPlan
components are properly implemented. The conditional rendering and the passing of necessary props and callbacks are handled correctly.
58-58
: LGTM!The component is correctly exported as the default export.
src/domain/InnovationPack/admin/AdminInnovationPacksPage.tsx (2)
9-9
: LGTM!The import statement change is consistent with the component usage change in the JSX.
Line range hint
49-57
: Looks good!The component usage change aligns with the import statement change and aims to improve the data presentation and user interaction capabilities, as suggested by the AI-generated summary.
src/main/admin/users/adminUsers/AdminUsersPage.tsx (8)
1-11
: LGTM!The import changes are consistent with the summary and align with the new functionality being introduced.
14-14
: LGTM!The addition of
licensePlans
to the destructured hook is consistent with the summary and supports the new license management functionality.
16-17
: LGTM!The new state variables,
licenseDialogOpen
andselectedItem
, are consistent with the summary and support the license management functionality.
19-22
: LGTM!The
onSettingsClick
function is consistent with the summary and handles the opening of the license dialog when a settings button is clicked for a specific user.
24-32
: LGTM!The
assignLicense
andrevokeLicense
functions are consistent with the summary and handle the respective actions when a license is assigned or revoked.
34-40
: LGTM!The
getActions
function is consistent with the summary and generates the actions for each user item in the table, including the settings button with the appropriate click handler.
45-45
: LGTM!The usage of the
SimpleSearchableTable
component with the appropriate props is consistent with the summary and reflects the transition to a table format for displaying user data.
47-57
: LGTM!The conditional rendering of the
LicensePlanDialog
component with the appropriate props is consistent with the summary and enables the interaction with license plans for the selected user.src/domain/community/contributor/organization/adminOrganizations/AdminOrganizationsPage.tsx (5)
1-16
: LGTM!The imports are properly organized and necessary for the component's functionality. The component declaration follows the expected syntax for a functional component.
22-59
: State variables and handlers look good!The state variables are appropriately named and initialized with sensible default values. The handlers are well-structured and perform the expected actions based on user interactions, properly updating the state and invoking necessary functions.
61-90
: Helper functions are well-implemented!The
getActions
,getStatusTranslation
, andgetActionTranslation
functions are properly structured and return the expected JSX or translated text based on the provided item. They handle different cases based on the item's verification status and utilize theuseTranslation
hook for internationalization support.
93-130
: Component rendering looks great!The component's rendering structure is clear and follows the expected hierarchy of layout components. The
SimpleSearchableTable
is properly configured with the required data and props. TheConfirmationDialog
andLicensePlanDialog
are rendered with the appropriate props and translations based on the selected item's verification status and presence.
133-133
: Export statement is correct!The component is correctly exported as the default export using the
export default
syntax, allowing it to be easily imported and used in other parts of the application.src/domain/community/user/adminUsers/useAdminGlobalUserList.tsx (5)
4-10
: LGTM!The new imports for
useAssignLicensePlanToAccountMutation
,useRevokeLicensePlanFromAccountMutation
, andrefetchUserListQuery
have been added correctly to support the license plan management functionality.
13-17
: LGTM!The new imports for
LicensePlanType
,UserListQuery
, andUserListQueryVariables
have been added correctly from the GraphQL schema to support the license plan management functionality.
34-36
: LGTM!The new properties
licensePlans
,assignLicensePlan
, andrevokeLicensePlan
have been added correctly to theProvided
interface to support the license plan management functionality.
80-89
: LGTM!The
userList
mapping has been updated correctly to include theaccountId
andactiveLicensePlanIds
properties for each user. The logic for filtering the license plans based on the user's account subscriptions is implemented correctly.
109-154
: LGTM!The
assignLicensePlan
andrevokeLicensePlan
functions are implemented correctly using the respective mutations. The logic for refetching the user list and notifying the user after the mutation is completed is also correct.The
licensePlans
constant is correctly filtering the license plans to only include account plans.src/domain/community/contributor/organization/adminOrganizations/useAdminGlobalOrganizationsList.ts (6)
21-29
: LGTM!The enums are well-defined and follow the naming conventions. The purpose is clear from the naming.
31-34
: LGTM!The interface has a clear name and defines the necessary properties for a contributor license plan object.
109-125
: LGTM!The
assignLicensePlan
function is implemented correctly:
- It uses the
useAssignLicensePlanToAccountMutation
hook to perform the mutation.- It refetches the
AdminGlobalOrganizationsList
query after the mutation is completed to ensure data consistency.- It shows a success notification to provide feedback to the user.
127-143
: LGTM!The
revokeLicensePlan
function is implemented correctly and follows the same pattern as theassignLicensePlan
function:
- It uses the
useRevokeLicensePlanFromAccountMutation
hook to perform the mutation.- It refetches the
AdminGlobalOrganizationsList
query after the mutation is completed to ensure data consistency.- It shows a success notification to provide feedback to the user.
149-157
: LGTM!The updates to the
organizations
array look good:
- The additional properties (
accountId
,verified
,activeLicensePlanIds
) provide useful information about each organization.- The code uses optional chaining (
?.
) to safely access nested properties and avoid potential null or undefined errors.- The
verified
property is determined based on the verification lifecycle state, which is a reliable source of information.
162-171
: LGTM!The
licensePlans
constant is well-defined:
- It uses
useMemo
to memoize the computed value and avoid unnecessary re-computations.- It filters the plans based on the
LicensePlanType.AccountPlan
type to include only relevant plans.- It maps the filtered plans to a simplified
ContributorLicensePlan
structure with only the necessary properties.- The
|| []
fallback ensures a safe return value even ifdata?.platform.licensing.plans
is undefined.src/domain/shared/components/SearchableList/SimpleSearchableTable.tsx (5)
1-25
: LGTM!The imports are well-organized, follow a consistent naming convention, and are relevant to the component's functionality.
26-48
: Interface updates improve flexibility and context.The changes to the
SearchableListProps
andSearchableListItem
interfaces are beneficial:
- Making
itemActions
prop accept either a function or a ReactNode improves flexibility for defining custom item actions.- Adding the optional
verified
property toSearchableListItem
provides more context to the displayed items.These updates enhance the component's usability and align with the AI-generated summary.
50-107
: Well-structured component with effective use of hooks and utility functions.The
SimpleSearchableList
component is well-organized and follows best practices:
- The use of hooks and utility functions, such as
useMemo
,useLazyLoading
, anduseState
, enhances code readability and maintainability.- The
openModal
function update improves type safety by specifying the event type more clearly.The component's structure and logic are clean and easy to understand.
111-180
: Effective use of Material-UI components and loading state.The
SimpleSearchableList
component's UI is well-designed and user-friendly:
- The use of Material-UI components, such as
Table
,TableBody
,TableRow
, andTableCell
, enhances the visual organization and accessibility of the data presented.- The loading state, which displays placeholder items while data is being fetched, improves the user experience during asynchronous operations.
The table layout and styling are consistent and visually appealing, making it easy for users to navigate and understand the presented data.
181-191
: RemoveModal enhances user interaction and prevents accidental deletions.The inclusion of the
RemoveModal
component is a valuable addition to theSimpleSearchableList
:
- It improves user interaction by requiring confirmation before deleting an item, preventing accidental deletions.
- The component is correctly exported as the default export, making it easy to import and use in other parts of the application.
This feature enhances the overall user experience and safety of the application.
src/domain/platform/admin/components/Organization/OrganizationForm.tsx (1)
47-47
: Reinstatement of theaccount
property inEmptyOrganization
.The change adds the
account
property back to theEmptyOrganization
constant, setting its value toundefined
. This indicates that theaccount
property is expected to be present in instances ofOrganization
but doesn't have a default value.Consider the following impact:
- Code that relies on the presence of the
account
property will now work as expected.- However, code that assumes the absence of the
account
property may need to be updated to handle theundefined
value gracefully.To verify the impact of this change, run the following script:
Verification successful
Approval of
account
property reinstatement inEmptyOrganization
The addition of the
account
property set toundefined
in theEmptyOrganization
constant is consistent with its usage throughout the codebase. Our analysis reveals:
The
account
property is accessed using optional chaining (?.
) in multiple files, indicating that the code is already prepared to handle cases whereaccount
might be undefined.There are no explicit checks for
account
being undefined or null, which aligns with the use of optional chaining and the new default value ofundefined
.The
Organization
type is widely used across the codebase, confirming its importance as a core entity in the application.This change ensures that the
EmptyOrganization
constant accurately represents the structure of theOrganization
type, including the possibility of an undefinedaccount
property. The existing code's use of optional chaining when accessingaccount
suggests that this change will not introduce any new issues and may actually improve type consistency.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the `account` property in the codebase. # Test 1: Search for code that accesses the `account` property. # Expect: Only valid usages that handle `undefined` values. rg --type typescript $'\\.(account|account\\?\\.)' -g '!EmptyOrganization' # Test 2: Search for code that checks for the existence of the `account` property. # Expect: No occurrences of checks for `undefined` or `null` values. rg --type typescript $'account\\s*(===|==|!==|!=)\\s*(undefined|null)' -g '!EmptyOrganization'Length of output: 236
Script:
#!/bin/bash # Description: Verify the usage of the `account` property in the codebase. # Test 1: Search for code that accesses the `account` property. echo "Test 1: Accessing 'account' property" rg -g '*.{ts,tsx}' '\b(organization|org)\.account\b' -g '!**/EmptyOrganization.ts*' # Test 2: Search for code that checks for the existence of the `account` property. echo "Test 2: Checking existence of 'account' property" rg -g '*.{ts,tsx}' 'account\s*(===|==|!==|!=)\s*(undefined|null)' -g '!**/EmptyOrganization.ts*' # Test 3: Search for imports of the Organization type echo "Test 3: Imports of Organization type" rg -g '*.{ts,tsx}' 'import.*Organization.*from' # Test 4: Search for usage of Organization type in type annotations echo "Test 4: Usage of Organization type in annotations" rg -g '*.{ts,tsx}' ':\s*Organization\b'Length of output: 19524
src/core/apollo/generated/apollo-helpers.ts (4)
17-17
: LGTM!The addition of the
subscriptions
field to theAccountKeySpecifier
type is valid and consistent with the existing fields.
33-33
: Looks good!Adding the
subscriptions
field to theAccountFieldPolicy
type is a valid change and aligns with the existing fields in the type.
38-42
: New types look good!The introduction of the
AccountSubscriptionKeySpecifier
andAccountSubscriptionFieldPolicy
types is a valid addition. The types are well-structured and follow the conventions used in the file. Theexpires
andname
fields are appropriate for representing an account subscription.
1408-1408
: New field additions are valid.The
temporaryLocation
field has been appropriately added to both theDocumentKeySpecifier
andDocumentFieldPolicy
types. The field name is descriptive and suggests it holds relevant metadata for a document. The changes maintain consistency with the existing fields in the types.Also applies to: 1423-1423
src/core/apollo/generated/apollo-hooks.ts (4)
11447-11499
: LGTM!The
AssignLicensePlanToAccount
mutation and associated types and hooks are implemented following the established patterns. The code is clear, well-documented, and ready to be used in React components.
11500-11552
: LGTM!The
RevokeLicensePlanFromAccount
mutation and associated types and hooks are implemented following the established patterns, similar to theAssignLicensePlanToAccount
mutation. The code is clear, well-documented, and ready to be used in React components.
11558-11592
: LGTM!The modifications to the
AdminGlobalOrganizationsListDocument
query are consistent with the GraphQL schema and provide more comprehensive data for each organization. The added fields, including account details, verification status, and licensing information, enhance the functionality of the admin interface for managing organizations.
11655-11707
: LGTM!The
adminOrganizationVerify
mutation and associated types and hooks are implemented following the established patterns and are well-documented. The modifications to theUserListDocument
query, including the addition of account and licensing information for each user, are consistent with the changes made to theAdminGlobalOrganizationsListDocument
query. These changes enhance the functionality of the admin interface for managing users and align with the overall requirements.Also applies to: 12906-12911, 12924-12935
src/core/apollo/generated/graphql-schema.ts (8)
57-58
: LGTM!The addition of the
subscriptions
field to theAccount
type is a valid enhancement to track active subscriptions associated with an account.
72-78
: Looks good!The
AccountSubscription
type definition is complete and accurately represents the structure of an account subscription with fields for expiry date and name.
2432-2433
: Looks good to me!The addition of the
temporaryLocation
field to theDocument
type is a valid enhancement to track whether a document is in its final location. The field type and description are accurate.
5583-5584
: Looks good!The addition of the optional
temporaryLocation
field to theStorageBucketUploadFileInput
type is a valid enhancement to specify whether an uploaded document is temporary. The field type and description are accurate, and making it optional is appropriate.
16261-16281
: Looks good to me!The addition of the
AssignLicensePlanToAccountMutationVariables
,RevokeLicensePlanFromAccountMutationVariables
,AssignLicensePlanToAccountMutation
, andRevokeLicensePlanFromAccountMutation
types is a valid enhancement to enable assigning and revoking license plans for accounts. The input and response structures are complete and match the provided description.
16296-16308
: LGTM!The enhancements to the
AdminGlobalOrganizationsListQuery
type, including the addition of theaccount
field with subscriptions and theverification
field, are valid and provide more comprehensive data retrieval capabilities for the admin interface. The structure of the added fields matches the provided description.
16317-16349
: Looks good!The further enhancements to the
AdminGlobalOrganizationsListQuery
type, including the addition of theplatform
field with licensing details, are valid and provide access to licensing plans available on the platform. The structure of the added fields matches the provided description.The addition of the
AdminOrganizationVerifyMutationVariables
andAdminOrganizationVerifyMutation
types is also a valid enhancement to enable verifying organizations through the admin interface.
17151-17176
: LGTM!The enhancements to the
UserListQuery
type, including the addition of theaccount
field with subscriptions and theplatform
field with licensing details, are valid and provide more comprehensive data retrieval capabilities for the user list interface. The structure of the added fields matches the provided description.
* Add InsufficientPrivileges step in the VC flow * set only used ids --------- Co-authored-by: Carlos Cano <carlos@alkem.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range and nitpick comments (1)
src/domain/community/contributor/organization/adminOrganizations/useAdminGlobalOrganizationsList.ts (1)
65-107
: Looks good, but consider improving error handling.The
handleVerification
function correctly handles the organization verification process based on the current state of the organization. It uses the appropriate mutation and event names defined in theOrgVerificationLifecycleStates
andOrgVerificationLifecycleEvents
enums.However, the error handling for the
VERIFICATION_REQUEST
event could be improved. Consider providing more specific error messages or handling different error scenarios to give better insights into why the event failed.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (7)
- src/core/apollo/generated/apollo-hooks.ts (7 hunks)
- src/core/apollo/generated/graphql-schema.ts (11 hunks)
- src/core/ui/dialogs/InfoDialog.tsx (1 hunks)
- src/domain/community/contributor/organization/adminOrganizations/ManageLicensePlanAccount.graphql (1 hunks)
- src/domain/community/contributor/organization/adminOrganizations/useAdminGlobalOrganizationsList.ts (2 hunks)
- src/domain/community/user/adminUsers/useAdminGlobalUserList.tsx (5 hunks)
- src/main/topLevelPages/myDashboard/newVirtualContributorWizard/useNewVirtualContributorWizard.tsx (11 hunks)
Files skipped from review as they are similar to previous changes (2)
- src/core/ui/dialogs/InfoDialog.tsx
- src/domain/community/contributor/organization/adminOrganizations/ManageLicensePlanAccount.graphql
Additional context used
Biome
src/main/topLevelPages/myDashboard/newVirtualContributorWizard/useNewVirtualContributorWizard.tsx
[error] 536-536: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
Additional comments not posted (36)
src/domain/community/user/adminUsers/useAdminGlobalUserList.tsx (5)
4-10
: LGTM!The new imports for the license plan management hooks are correctly added and follow the existing import style.
13-17
: LGTM!The new imports for the
LicensePlanType
enum andUserListQueryVariables
type are correctly added and follow the existing import style.
34-36
: LGTM!The new properties added to the
Provided
interface for license plan management are correctly defined and follow the existing code style.
80-89
: LGTM!The
userList
mapping now includesaccountId
andactiveLicensePlanIds
properties, providing more detailed information about each user and their associated license plans. The logic to deriveactiveLicensePlanIds
is correct and efficient.
109-154
: LGTM!The new
assignLicensePlan
andrevokeLicensePlan
functions correctly handle the assignment and revocation of license plans for user accounts. Refetching theuserList
query after each mutation ensures that the data is always up-to-date, and displaying a success notification provides a good user experience.The
licensePlans
constant efficiently filters and maps the relevant license plans, ensuring that only account plans are included.src/domain/community/contributor/organization/adminOrganizations/useAdminGlobalOrganizationsList.ts (5)
21-29
: LGTM!The new enums
OrgVerificationLifecycleStates
andOrgVerificationLifecycleEvents
are well-defined and follow the naming conventions. The enum values clearly represent the different states and events in the organization verification lifecycle.
31-34
: LGTM!The new interface
ContributorLicensePlan
is well-defined and follows the naming conventions. The interface propertiesid
andname
are appropriately typed asstring
.
109-125
: LGTM!The
assignLicensePlan
function correctly assigns a license plan to an account using theuseAssignLicensePlanToAccountMutation
hook. Refetching theAdminGlobalOrganizationsList
query after the mutation ensures that the data is up to date, and displaying a success notification provides good user feedback.
127-143
: LGTM!The
revokeLicensePlan
function correctly revokes a license plan from an account using theuseRevokeLicensePlanFromAccountMutation
hook. Refetching theAdminGlobalOrganizationsList
query after the mutation ensures that the data is up to date, and displaying a success notification provides good user feedback.
162-171
: LGTM!Using
useMemo
to memoize thelicensePlans
value is a good optimization technique. Filtering the plans based on theLicensePlanType.AccountPlan
type ensures that only relevant plans are included, and mapping the plans toContributorLicensePlan
objects provides a cleaner data structure for the UI.src/main/topLevelPages/myDashboard/newVirtualContributorWizard/useNewVirtualContributorWizard.tsx (8)
51-57
: LGTM!The addition of the
insufficientPrivileges
step to theStep
type is consistent with the rest of the code changes that introduce privilege checks. This allows the wizard to handle scenarios where the user lacks sufficient privileges to create a virtual contributor or subspace.
68-70
: LGTM!The addition of the optional
authorization
andmyPrivileges
properties to theUserAccountProps
interface is necessary to support the privilege checks introduced in the rest of the code changes. This allows the code to access the user's privileges for their spaces and communities.Also applies to: 76-78
191-196
: LGTM!The addition of the
spacePrivileges
object to the return value of theuseMemo
hook is necessary to support the privilege checks introduced in the rest of the code changes. This allows the code to access the user's privileges for their space and the associated community.
243-253
: LGTM!The
hasPrivilegesOnSpaceAndCommunity
function encapsulates the logic for checking user privileges. It checks for the necessary privileges required to create a virtual contributor or subspace. This function is used in multiple places to ensure that the user has the required privileges before proceeding with certain actions.
268-272
: LGTM!The addition of the privilege check using the
hasPrivilegesOnSpaceAndCommunity
function ensures that the user has the necessary permissions to create a subspace or virtual contributor. If the user lacks the required privileges, the wizard transitions to theinsufficientPrivileges
step, preventing unauthorized actions. This change enhances the user experience by providing clearer feedback regarding permission issues.
468-471
: LGTM!The addition of the privilege check using the
hasPrivilegesOnSpaceAndCommunity
function ensures that the user has the necessary permissions to create a virtual contributor. If the user lacks the required privileges, the function transitions to theinsufficientPrivileges
step and returnsfalse
, preventing unauthorized actions.The
try-catch
block helps handle errors gracefully and prevents the wizard from getting stuck in case of failures. This improves the overall robustness of the virtual contributor creation process.Also applies to: 473-531
582-592
: LGTM!The addition of the
InfoDialog
component for theinsufficientPrivileges
step provides a clear and informative message to the user when they lack the required privileges to create a virtual contributor or subspace. The dialog allows the user to acknowledge the message and close the wizard gracefully.This change enhances the user experience by providing clear feedback and guidance in case of insufficient privileges, making the wizard more user-friendly and intuitive.
536-536
: Skipping the static analysis hint.Upon examining the code at line 536, it appears that the property access is already safe and does not require an optional chain. The
selectedKnowledge
object is checked for truthiness before accessing its properties, ensuring that the code does not encounter a runtime error.The static analysis hint provided by Biome seems to be a false positive in this case, so it can be safely ignored.
Tools
Biome
[error] 536-536: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
src/core/apollo/generated/apollo-hooks.ts (9)
4494-4497
: LGTM!The added
authorization
fields for spaces provide more granular access control information, aligning with the overall theme of enhancing authorization capabilities.
4507-4510
: LGTM!The added
authorization
fields for the community provide more granular access control information, aligning with the overall theme of enhancing authorization capabilities.
11455-11507
: Excellent!The
AssignLicensePlanToAccount
mutation and its associated hooks are well-structured and align with the feature of assigning license plans to accounts. The generated hooks provide a convenient way to use the mutation in React components.
11508-11560
: Excellent!The
RevokeLicensePlanFromAccount
mutation and its associated hooks are well-structured and align with the feature of revoking license plans from accounts. The generated hooks provide a convenient way to use the mutation in React components.
11566-11600
: Great work!The added fields to the
adminGlobalOrganizationsList
query provide more comprehensive information about organizations, including account details, subscriptions, verification status, and licensing plans. These changes align with the improvements to organization queries and the addition of licensing information mentioned in the summary.
12914-12919
: LGTM!The added fields to the
usersPaginated
query provide more information about users, including their account details and subscriptions. These changes align with the improvements to user queries mentioned in the summary.
12932-12943
: Excellent!The added
platform
field to theusersPaginated
query provides licensing information for users, aligning with the improvements to user queries and the addition of licensing information mentioned in the summary.
22969-22972
: LGTM!The added
authorization
fields for the community and subspaces provide more granular access control information, aligning with the overall theme of enhancing authorization capabilities.Also applies to: 22979-22982
11663-11715
: New mutation for organization verification looks good!The
AdminOrganizationVerify
mutation and its associated hooks are well-structured. Although not explicitly mentioned in the summary, this mutation seems to be part of the overall enhancements to organization management.To ensure the mutation is being used correctly, please run the following script to search for its usage in the codebase:
Verification successful
AdminOrganizationVerify mutation is correctly implemented and used
The
AdminOrganizationVerify
mutation is properly implemented in the generated Apollo hooks file and is being used correctly in the codebase. Specifically:
- It's imported and utilized in the
useAdminGlobalOrganizationsList
hook (src/domain/community/contributor/organization/adminOrganizations/useAdminGlobalOrganizationsList.ts).- The mutation is used to create a
verifyOrg
function, following the correct pattern for Apollo mutation hooks.This usage aligns with the purpose of the mutation for organization verification in the admin context.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the `AdminOrganizationVerify` mutation. # Test: Search for the mutation usage. Expect: At least one occurrence in a React component. rg --type tsx -A 5 $'useAdminOrganizationVerifyMutation'Length of output: 83
Script:
#!/bin/bash # Description: Verify the usage of the `AdminOrganizationVerify` mutation in TypeScript and TypeScript React files. # Search for TypeScript and TypeScript React files containing the mutation usage fd -e ts -e tsx | xargs rg -n -A 5 'useAdminOrganizationVerifyMutation' # If the above command doesn't yield results, search for any reference to the mutation name fd -e ts -e tsx | xargs rg -n 'AdminOrganizationVerify'Length of output: 7436
src/core/apollo/generated/graphql-schema.ts (9)
57-58
: LGTM!The addition of the
subscriptions
field to theAccount
type is a valuable enhancement to the GraphQL schema. It allows for better tracking and management of active subscriptions associated with an account.
72-78
: Looks good!The
AccountSubscription
type is a well-structured representation of an account subscription. The inclusion of theexpires
andname
fields provides essential information for subscription management and licensing.
2432-2433
: Approved.The
temporaryLocation
field is a helpful addition to theDocument
type. It provides a clear indication of whether a document is in its final location or a temporary one, which can be valuable for document management and tracking purposes.
5583-5584
: Looks good to me!The inclusion of the
temporaryLocation
field in theStorageBucketUploadFileInput
type is a useful addition. It allows specifying whether an uploaded document is temporary, which can be helpful for handling temporary documents differently in terms of storage or retention policies.
7076-7078
: Approved.The inclusion of the
authorization
field in theSpace
type is a valuable addition to the GraphQL schema. It allows associating authorization information with a space and provides insights into the privileges the current user has for that space through themyPrivileges
field. This change enhances the schema's capabilities in terms of authorization management.
7089-7095
: LGTM!The inclusion of the
community
field in theSpace
type is a great addition to the GraphQL schema. It establishes a clear relationship between a space and its associated community, providing more contextual information. Theid
field allows identifying the specific community, while theauthorization
field provides community-specific authorization details, including the current user's privileges. This change enhances the schema's expressiveness and usefulness.
16270-16290
: Looks good!The addition of the
AssignLicensePlanToAccountMutation
andRevokeLicensePlanFromAccountMutation
mutation types is a valuable enhancement to the GraphQL schema. These mutations allow performing actions related to assigning and revoking license plans for accounts, providing important functionality for license management.The corresponding input types,
AssignLicensePlanToAccountMutationVariables
andRevokeLicensePlanFromAccountMutationVariables
, ensure that the necessary information is provided for each mutation, maintaining data integrity.The returned
Account
object allows accessing the updated account information after the mutation is performed, providing flexibility and convenience for clients.Overall, these mutations significantly improve the schema's capabilities in terms of license plan management for accounts.
16305-16317
: Approved.The modifications to the
AdminGlobalOrganizationsListQuery
type are valuable enhancements to the GraphQL schema. The addition of theaccount
field to theorganization
field allows accessing account-related information within the query, providing a more comprehensive view of organizations.The
subscriptions
field within theaccount
object is particularly useful as it provides information about the active subscriptions associated with the account, including the subscription name through thename
field of typeLicenseCredential
. This allows clients to retrieve important details about an organization's subscriptions.Furthermore, the inclusion of the
verification
field within theorganization
field is a great addition. It allows accessing verification-related information for the organization, including the verification lifecycle and current state through thelifecycle
field. This provides valuable insights into the verification process for each organization.Overall, these changes significantly enhance the
AdminGlobalOrganizationsListQuery
by providing a more comprehensive and informative response, enabling clients to retrieve essential details about organizations, their accounts, subscriptions, and verification status.
16326-16358
: LGTM!The addition of the
platform
field to theAdminGlobalOrganizationsListQuery
type is a great enhancement to the GraphQL schema. It allows accessing platform-related information within the query, providing a more comprehensive view of the platform and its licensing details.The
licensing
field within theplatform
object is particularly useful as it provides information about the licensing details for the platform, including the available license plans. Theplans
field within thelicensing
object is an array ofLicensePlan
objects, each representing a specific license plan with itsid
,name
,type
, andlicenseCredential
. This allows clients to retrieve important details about the available license plans on the platform.Furthermore, the introduction of the
AdminOrganizationVerifyMutation
mutation type is a valuable addition. It allows performing organization verification actions, providing a way to manage and update the verification status of organizations. TheAdminOrganizationVerifyMutationVariables
input type ensures that the necessary input is provided for the mutation, maintaining data integrity.The returned
OrganizationVerification
object provides insightful information about the verification process, including theid
andlifecycle
details. Thelifecycle
field within theOrganizationVerification
object includes theid
,nextEvents
, andstate
fields, offering a comprehensive view of the verification lifecycle and its current state.Overall, these changes significantly enhance the GraphQL schema by providing platform licensing information and organization verification capabilities, enabling clients to retrieve essential details about the platform, license plans, and perform verification actions on organizations.
Merged into this PR: #6844
The changes depend on these server changes: Active Subscriptions (license plans) exposed under Account server#4535
Summary by CodeRabbit
Release Notes
New Features
InfoDialog
component for displaying informational dialogs and handling user confirmations.Bug Fixes
Documentation
Style