Skip to content

NonApproved Catalog Items #1183

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

Closed
wants to merge 1 commit into from
Closed

NonApproved Catalog Items #1183

wants to merge 1 commit into from

Conversation

ammb-123
Copy link
Contributor

Description

DTTL Approved catalog items

Changes Made

DT AI Core admins should be able to access AI Core services as outlined in the attached document.
Only DTTL approved resources, as specified in the attached sheet will be visible in DT AI Core and granted access.
Users should not be able to see any catalog items.

How to Test

DTTL approved resources, as specified in the attached sheet will be visible in DT AI Core and granted access.
Users should not be able to see any catalog items.
NonApprovedProductCatalog.docx
Uploading Connectors Details.xlsx…

Notes

Copy link

@CodiumAI-Agent /describe

@CodiumAI-Agent
Copy link

Title

NonApproved Catalog Items


User description

Description

DTTL Approved catalog items

Changes Made

DT AI Core admins should be able to access AI Core services as outlined in the attached document.
Only DTTL approved resources, as specified in the attached sheet will be visible in DT AI Core and granted access.
Users should not be able to see any catalog items.

How to Test

DTTL approved resources, as specified in the attached sheet will be visible in DT AI Core and granted access.
Users should not be able to see any catalog items.
NonApprovedProductCatalog.docx
Uploading Connectors Details.xlsx…

Notes


PR Type

Enhancement


Description

Introduce adminOnlyNonApprovedFlag in global config
Use flag to switch connection options on ImportPage
Add new CONNECTION_OPTIONS_CORE_AI for CoreAI resources


Changes walkthrough 📝

Relevant files
Enhancement
ImportPage.tsx
Dynamically set import options by config flag                       

packages/client/src/pages/import/ImportPage.tsx

  • Imported CONNECTION_OPTIONS_CORE_AI
  • Updated connectionOptions state initializer
  • Switched options based on config adminOnlyNonApprovedFlag
  • +5/-3     
    Configuration changes
    config.store.ts
    Add adminOnlyNonApprovedFlag to config                                     

    packages/client/src/stores/config/config.store.ts

  • Added adminOnlyNonApprovedFlag to ConfigStoreInterface
  • Initialized default flag in ConfigStore constructor
  • +6/-0     
    import.constants.ts
    Add CoreAI connection options constant                                     

    packages/client/src/pages/import/import.constants.ts

  • Defined new CONNECTION_OPTIONS_CORE_AI constant
  • Exported CoreAI-specific connection options
  • +8298/-0

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • Copy link

    @CodiumAI-Agent /review

    @CodiumAI-Agent
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    State Sync

    The connectionOptions state is initialized based on adminOnlyNonApprovedFlag but never updated if the flag changes. Consider adding a useEffect to re-sync connectionOptions when configStore.config.adminOnlyNonApprovedFlag updates.

    const [connectionOptions, setConnectionOptions] =
         React.useState(configStore.config.adminOnlyNonApprovedFlag === true ? CONNECTION_OPTIONS_CORE_AI : CONNECTION_OPTIONS);
    
    Import Formatting

    The import line for CONNECTION_OPTIONS and CONNECTION_OPTIONS_CORE_AI has inconsistent spacing. It should be formatted as:

    import { CONNECTION_OPTIONS, CONNECTION_OPTIONS_CORE_AI } from './import.constants';
    
    import { CONNECTION_OPTIONS ,CONNECTION_OPTIONS_CORE_AI} from './import.constants';
    Flag Naming

    The name adminOnlyNonApprovedFlag is ambiguous. It’s unclear if it means “admin only non-approved” or “non-approved for admins”. Consider renaming for clarity (e.g., showCoreAiOptionsFlag).

    /*
    * CoreAI Non Approved flag 
    */
    adminOnlyNonApprovedFlag: boolean;

    Copy link

    @CodiumAI-Agent /improve

    @CodiumAI-Agent
    Copy link

    CodiumAI-Agent commented May 20, 2025

    PR Code Suggestions ✨

    Latest suggestions up to 9c90fe6

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Memoize options based on flag

    The state will not react to changes in the flag after initial render. Replace this
    with useMemo so that connectionOptions updates automatically whenever
    adminOnlyNonApprovedFlag changes.

    packages/client/src/pages/import/ImportPage.tsx [193-194]

    -const [connectionOptions, setConnectionOptions] =
    -     React.useState(configStore.config.adminOnlyNonApprovedFlag === true ? CONNECTION_OPTIONS_CORE_AI : CONNECTION_OPTIONS);
    +const connectionOptions = React.useMemo(
    +  () =>
    +    configStore.config.adminOnlyNonApprovedFlag
    +      ? CONNECTION_OPTIONS_CORE_AI
    +      : CONNECTION_OPTIONS,
    +  [configStore.config.adminOnlyNonApprovedFlag]
    +);
    Suggestion importance[1-10]: 7

    __

    Why: Using useState means connectionOptions won’t update when adminOnlyNonApprovedFlag changes, so switching to useMemo ensures the options stay in sync.

    Medium
    General
    Add type annotation

    Add an explicit type annotation to CONNECTION_OPTIONS_CORE_AI to ensure it matches
    the expected shape of CONNECTION_OPTIONS and avoid implicit any.

    packages/client/src/pages/import/import.constants.ts [155]

    -export const CONNECTION_OPTIONS_CORE_AI = {
    +export const CONNECTION_OPTIONS_CORE_AI: ConnectionOptionsType = {
    Suggestion importance[1-10]: 5

    __

    Why: Explicitly typing CONNECTION_OPTIONS_CORE_AI guards against mismatches and eliminates implicit any, aiding maintainability.

    Low
    Fix import spacing

    Fix spacing around the comma and keep your imports consistent for readability and
    linting.

    packages/client/src/pages/import/ImportPage.tsx [46]

    -import { CONNECTION_OPTIONS ,CONNECTION_OPTIONS_CORE_AI} from './import.constants';
    +import { CONNECTION_OPTIONS, CONNECTION_OPTIONS_CORE_AI } from './import.constants';
    Suggestion importance[1-10]: 3

    __

    Why: This is purely a formatting change with low impact, improving readability but not the functionality.

    Low

    Previous suggestions

    Suggestions up to commit 9c90fe6
    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Derive options via useMemo

    Derive connectionOptions dynamically so that it updates when
    adminOnlyNonApprovedFlag changes. You can replace the state with a useMemo hook and
    remove the setter to avoid stale values.

    packages/client/src/pages/import/ImportPage.tsx [193-194]

    -const [connectionOptions, setConnectionOptions] =
    -     React.useState(configStore.config.adminOnlyNonApprovedFlag === true ? CONNECTION_OPTIONS_CORE_AI : CONNECTION_OPTIONS);
    +const connectionOptions = React.useMemo(
    +  () => configStore.config.adminOnlyNonApprovedFlag 
    +    ? CONNECTION_OPTIONS_CORE_AI 
    +    : CONNECTION_OPTIONS, 
    +  [configStore.config.adminOnlyNonApprovedFlag]
    +);
    Suggestion importance[1-10]: 6

    __

    Why: Replacing the static useState with useMemo ensures connectionOptions updates when adminOnlyNonApprovedFlag changes, avoiding stale state.

    Low
    General
    Add type assertion for constant

    Ensure CONNECTION_OPTIONS_CORE_AI matches the same shape as CONNECTION_OPTIONS by
    adding a type annotation or assertion. This will catch mismatches at compile time
    and maintain consistency in your stepper logic.

    packages/client/src/pages/import/import.constants.ts [155]

    -export const CONNECTION_OPTIONS_CORE_AI = { ... };
    +export const CONNECTION_OPTIONS_CORE_AI = { ... } as typeof CONNECTION_OPTIONS;
    Suggestion importance[1-10]: 6

    __

    Why: Applying as typeof CONNECTION_OPTIONS enforces the shape of CONNECTION_OPTIONS_CORE_AI at compile time, preventing mismatches with CONNECTION_OPTIONS.

    Low
    Fix import spacing consistency

    Clean up the import statement by removing the extra space before the comma and
    adding a space after it for consistency with your code style.

    packages/client/src/pages/import/ImportPage.tsx [46]

    -import { CONNECTION_OPTIONS ,CONNECTION_OPTIONS_CORE_AI} from './import.constants';
    +import { CONNECTION_OPTIONS, CONNECTION_OPTIONS_CORE_AI } from './import.constants';
    Suggestion importance[1-10]: 2

    __

    Why: This style change improves readability by aligning with the project's import formatting conventions without changing behavior.

    Low

    @anurag91jain
    Copy link
    Contributor

    This is not required.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    3 participants