-
Notifications
You must be signed in to change notification settings - Fork 32
Project context and customizable product types #1332
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
base: develop
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This pull request refactors how productTypes
are handled across multiple components by replacing the usage of static productTypes
object with dynamic data sourced from the ProjectContext
. The change ensures that product types are project-specific and improves flexibility through the introduction of a ProjectContextProvider
that provides project-specific data and helper functions.
Key changes:
- Introduction of
ProjectContextProvider
to centralize project-specific data access - Replacement of static
productTypes
imports with dynamic project context consumption - Addition of utility functions for retrieving product type icons and colors from project configuration
Reviewed Changes
Copilot reviewed 22 out of 23 changed files in this pull request and generated 7 comments.
Show a summary per file
File | Description |
---|---|
src/pages/ProjectPage/ProjectPage.tsx |
Wraps main project page with ProjectContextProvider |
src/pages/ProjectDashboard/ProjectDashboard.jsx |
Adds ProjectContextProvider wrapper to dashboard |
src/pages/BrowserPage/Products/ProductsGrid.jsx |
Replaces static productTypes with project context methods |
shared/src/context/ProjectContext.tsx |
New context provider for project-specific data and helper functions |
shared/src/containers/ProjectTreeTable/utils/getTableFieldOptions.ts |
Updates table field options to use dynamic product types |
shared/src/components/VersionUploader/components/UploadVersionForm.tsx |
Migrates to use project context for product type options |
arrayProps[prop].push(projectInfo.config.productTypes.default as any) | ||
} | ||
} | ||
else if (Array.isArray(projectInfo[prop])) { | ||
arrayProps[prop].push(projectInfo[prop] as any) |
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.
Using 'as any' type assertion bypasses TypeScript's type safety. Consider using proper type assertions or defining the expected type structure.
arrayProps[prop].push(projectInfo.config.productTypes.default as any) | |
} | |
} | |
else if (Array.isArray(projectInfo[prop])) { | |
arrayProps[prop].push(projectInfo[prop] as any) | |
const productTypesDefault = projectInfo.config.productTypes.default; | |
if (Array.isArray(productTypesDefault) && productTypesDefault.every(item => typeof item === 'object')) { | |
arrayProps[prop].push(productTypesDefault as ProductTypeOverride[]); | |
} | |
} | |
} | |
else if (Array.isArray(projectInfo[prop])) { | |
const propValue = projectInfo[prop]; | |
if (Array.isArray(propValue)) { | |
arrayProps[prop].push(propValue as typeof arrayProps[typeof prop]); | |
} |
Copilot uses AI. Check for mistakes.
(result as any)[prop] = mergeArraysByKey(arrayProps[prop] as ProductTypeOverride[][]) | ||
} | ||
|
||
else if (arrayProps[prop].length > 0) { | ||
;(result as any)[prop] = mergeArraysByKey(arrayProps[prop]) |
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.
Using 'as any' type assertion bypasses TypeScript's type safety. Consider properly typing the result object or using more specific type assertions.
(result as any)[prop] = mergeArraysByKey(arrayProps[prop] as ProductTypeOverride[][]) | |
} | |
else if (arrayProps[prop].length > 0) { | |
;(result as any)[prop] = mergeArraysByKey(arrayProps[prop]) | |
result[prop] = mergeArraysByKey(arrayProps[prop] as ProductTypeOverride[][]) | |
} | |
else if (arrayProps[prop].length > 0) { | |
result[prop] = mergeArraysByKey(arrayProps[prop] as typeof result[typeof prop]) |
Copilot uses AI. Check for mistakes.
This pull request refactors how
productTypes
are handled across multiple components and contexts. The changes replace the usage of a staticproductTypes
object with dynamic data sourced from theProjectContext
or project configuration. This improves flexibility and ensuresproductTypes
are project-specific. Additionally, several utility functions and components were updated to accommodate this change.Refactoring of
productTypes
Replaced the static
productTypes
object with dynamic data retrieved fromProjectContext
or project configuration. This ensuresproductTypes
are project-specific.This requires ynput/ayon-backend#622
ProjectContextProvider
Introduced
ProjectContextProvider
to provide project-specific data, includingproductTypes
and various project-specific helper functions. This could be further expanded and eventually could replace project data in redux and allow consolidation of project specific logic.