这是indexloc提供的服务,不要输入任何密码
Skip to content

Added entityName property #762

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

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from

Conversation

A-Vamshi
Copy link

@A-Vamshi A-Vamshi commented Jul 12, 2025

This PR adds the entityName prop to the following components/pages as requested in #655

selected-team-switcher
account-settings
team-creation
team-invitation


Important

Add entityName prop to customize entity name display in team-related components using pluralize.

  • Behavior:
    • Adds entityName prop to AccountSettings, TeamCreation, TeamInvitation, and SelectedTeamSwitcher components to customize entity name display.
    • Uses pluralize library in account-settings.tsx and selected-team-switcher.tsx to handle plural forms of entityName.
  • Components:
    • AccountSettings: Uses entityName to customize team-related titles and IDs.
    • TeamCreation: Uses entityName for form validation messages and UI text.
    • TeamInvitation: Uses entityName for invitation messages and error handling.
    • SelectedTeamSwitcher: Uses entityName for dropdown labels and error messages.
  • Dependencies:
    • Adds pluralize to package.json for handling pluralization.

This description was created by Ellipsis for 4ba52c3. You can customize this summary. It will automatically update as commits are pushed.

Copy link

vercel bot commented Jul 12, 2025

@A-Vamshi is attempting to deploy a commit to the Stack Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Added configurable entity naming across team-related components, allowing customization of team terminology (e.g., 'Team' to 'Course') throughout the UI.

  • Added entityName prop to key components (TeamCreation, SelectedTeamSwitcher, TeamInvitation, AccountSettings) with pluralization support
  • Uses a new pluralize package dependency for handling entity name pluralization consistently
  • Inconsistent casing and type handling for entityName prop across components needs standardization
  • Potential prop type mismatches in packages/template/src/components-page/team-invitation.tsx require attention
  • Consider using a Map instead of plain objects for dynamic string templating to prevent prototype pollution

5 files reviewed, 6 comments
Edit PR Review Bot Settings | Greptile

Comment on lines +84 to +85
const entityName = props.entityName ?? "Team";
const pluralEntity = pluralize(entityName)
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider caching pluralized value in useMemo to prevent unnecessary recalculations on re-renders

Comment on lines 73 to 77
export function TeamInvitation(props: {
fullPage?: boolean,
searchParams: Record<string, string>
entityName: string,
}) {
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Type mismatch between TeamInvitation and TeamInvitationInner components. entityName is required here but optional in TeamInvitationInner.

Suggested change
export function TeamInvitation(props: {
fullPage?: boolean,
searchParams: Record<string, string>
entityName: string,
}) {
export function TeamInvitation(props: {
fullPage?: boolean,
searchParams: Record<string, string>
entityName?: string,
}) {

Comment on lines 92 to 94
<MessageCard title={t('Expired {entity} Invitation Link', {entity: entityName})} fullPage={fullPage}>
<Typography>{t('Your team invitation link has expired. Please request a new {entity} invitation link ', {entity: entityName.toLowerCase()})}</Typography>
</MessageCard>
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Inconsistent string: 'team' is hardcoded here while entityName is used for the title

Suggested change
<MessageCard title={t('Expired {entity} Invitation Link', {entity: entityName})} fullPage={fullPage}>
<Typography>{t('Your team invitation link has expired. Please request a new {entity} invitation link ', {entity: entityName.toLowerCase()})}</Typography>
</MessageCard>
<MessageCard title={t('Expired {entity} Invitation Link', {entity: entityName})} fullPage={fullPage}>
<Typography>{t('Your {entity} invitation link has expired. Please request a new {entity} invitation link ', {entity: entityName.toLowerCase()})}</Typography>
</MessageCard>

@@ -160,13 +164,13 @@ export function AccountSettings(props: {
<Typography className="max-w-[320px] md:w-[90%] truncate">{team.displayName}</Typography>
</div>,
type: 'item',
id: `team-${team.id}`,
id: `${entityName.toLowerCase()}-${team.id}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Keep team-related IDs consistent. Other IDs like 'team-creation' still use hardcoded 'team-' prefix while this line uses dynamic entityName

export function TeamInvitation(props: {
fullPage?: boolean,
searchParams: Record<string, string>
entityName: string,
Copy link

Choose a reason for hiding this comment

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

Breaking change in TeamInvitation component's props interface - 'entityName' is marked as required but existing usages in stack-handler.tsx and potentially other places don't provide this prop. This will cause TypeScript compilation errors and potential runtime issues if not provided. The props should maintain backward compatibility by making entityName optional with a default value of 'Team'.


React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)

Copy link

recurseml bot commented Jul 12, 2025

😱 Found 1 issue. Time to roll up your sleeves! 😱

🗒️ View all ignored comments in this repo
  • The constraint 'TokenStoreType extends string' is too restrictive. It should likely be 'TokenStoreType extends string | object' to match the condition check in line 113 where TokenStoreType is checked against {}
  • Return type mismatch - the interface declares useUsers() returning ServerUser[] but the Team interface that this extends declares useUsers() returning TeamUser[]
  • There is a syntax error in the super constructor call due to the ellipsis operator used incorrectly. Objects aren't being merged correctly. This syntax usage can lead to runtime errors when trying to pass the merged object to 'super()'. Verify that the intended alterations to the object occur before or outside of the super() call if needed.
  • Throwing an error when no active span is found is too aggressive. The log function should gracefully fallback to console.log or another logging mechanism when there's no active span, since not all execution contexts will have an active span. This makes the code less resilient and could break functionality in non-traced environments.

📚 Relevant Docs

  • Function sets backendContext with a new configuration but doesn't pass 'defaultProjectKeys'. Since defaultProjectKeys is required in the type definition and cannot be updated (throws error if tried to set), this will cause a type error.
  • The schema is using array syntax for pick() which is incorrect for Yup schemas. The pick() method in Yup expects individual arguments, not an array. Should be changed to: emailConfigSchema.pick('type', 'host', 'port', 'username', 'sender_name', 'sender_email')

📚 Relevant Docs

  • Creating a refresh token with current timestamp as expiration means it expires immediately. Should set a future date for token expiration.
  • The 'tools' object is initialized as an empty object, even though 'tools' is presumably expected to contain tool definitions. This could cause the server capabilities to lack necessary tool configurations, thus potentially impacting functionalities that depend on certain tool setups.

📚 Relevant Docs

  • 'STACK_SECRET_SERVER_KEY' is potentially being included in every request header without checking its existence again here. Although it's checked during initialization, this could lead to security issues as it's exposed in all communications where the header is logged or captured.

📚 Relevant Docs

  • When adding 'use client' directive at the beginning, it doesn't check if file.text already contains the 'use client' directive. This could lead to duplicate 'use client' directives if the file already has one.

📚 Relevant Docs

Need help? Join our Discord for support!
https://discord.gg/qEjHQk64Z9

@@ -94,7 +99,7 @@ function Inner<AllowNull extends boolean>(props: SelectedTeamSwitcherProps<Allow
if (value !== 'null-sentinel') {
team = teams?.find(team => team.id === value) || null;
if (!team) {
throw new StackAssertionError('Team not found, this should not happen');
throw new StackAssertionError('{entity} not found, this should not happen', {entity: entityName});
Copy link
Contributor

Choose a reason for hiding this comment

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

The error message in the StackAssertionError contains spaces and is not machine‐readable. Consider using a unique, identifier-like string (e.g. "selected-team-not-found") as the first argument.

Suggested change
throw new StackAssertionError('{entity} not found, this should not happen', {entity: entityName});
throw new StackAssertionError('selected-team-not-found', {entity: entityName});

This comment was generated because it violated a code review rule: mrule_dFi2eJA7OgSpYeiv.

Copy link

patched-codes bot commented Jul 12, 2025

Documentation Changes Required

1. docs/templates/components/account-settings.mdx

  1. Add new entityName prop to the PropTable section with description and default value.
  2. Update example code to demonstrate usage of the new entityName prop to show how Organizations would appear instead of Teams.

2. docs/templates/sdk/types/project.mdx

Update the description of clientTeamCreationEnabled property:

  • Old: "Determines if client-side team creation is permitted within the project."
  • New: "Determines if client-side entity creation (teams or custom entities) is permitted within the project."

3. docs/templates/components/selected-team-switcher.mdx

  1. Add new props to the PropTable:

    • entityName (string, optional, default: "Team")
    • allowNull (boolean, optional, default: false)
    • nullLabel (string, optional, default: "No [entity]")
    • onChange (function, optional)
  2. Update the example to demonstrate usage of the new entityName prop:

<SelectedTeamSwitcher
  urlMap={(team) => `/team/${team.id}`}
  selectedTeam={currentTeam}
  noUpdateSelectedTeam={false}
  entityName="Organization"
/>

Please ensure these changes are reflected in the relevant documentation files.

@N2D4 N2D4 changed the title Added entiyName property Added entityName property Jul 21, 2025
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.

3 participants