-
Notifications
You must be signed in to change notification settings - Fork 4.5k
chore: Adding create permission check for the plus button on tabs list #39672
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
Changes from all commits
56ceaf6
d205485
b401fbc
4b6aa3a
3ef148c
582e567
65984cd
10f4a6d
1103ce8
6d8086b
b15dd32
eab2050
d0df6c6
0df8c33
f26e5f4
f26de0a
7bc2574
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,50 @@ | ||||||||||||||
| import type { FocusEntityInfo } from "navigation/FocusEntity"; | ||||||||||||||
| import type { FocusEntity } from "navigation/FocusEntity"; | ||||||||||||||
| import type { FocusElementConfig } from "navigation/FocusElements"; | ||||||||||||||
| import type { AppsmithLocationState } from "utils/history"; | ||||||||||||||
|
|
||||||||||||||
| export interface FocusPath { | ||||||||||||||
| key: string; | ||||||||||||||
| entityInfo: FocusEntityInfo; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| export type FocusElementsConfigList = { | ||||||||||||||
| [key in FocusEntity]?: FocusElementConfig[]; | ||||||||||||||
| }; | ||||||||||||||
|
|
||||||||||||||
| export interface FocusStrategy { | ||||||||||||||
| focusElements: FocusElementsConfigList; | ||||||||||||||
| /** based on the route change, what states need to be set in the upcoming route **/ | ||||||||||||||
| getEntitiesForSet: ( | ||||||||||||||
| previousPath: string, | ||||||||||||||
| currentPath: string, | ||||||||||||||
| state: AppsmithLocationState, | ||||||||||||||
| // TODO: Fix this the next time the file is edited | ||||||||||||||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||||||||||||||
| ) => Generator<any, Array<FocusPath>, any>; | ||||||||||||||
| /** based on the route change, what states need to be stored for the previous route **/ | ||||||||||||||
| getEntitiesForStore: ( | ||||||||||||||
| path: string, | ||||||||||||||
| currentPath: string, | ||||||||||||||
| // TODO: Fix this the next time the file is edited | ||||||||||||||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||||||||||||||
| ) => Generator<any, Array<FocusPath>, any>; | ||||||||||||||
| /** For entities with hierarchy, return the parent entity path for storing its state **/ | ||||||||||||||
|
Comment on lines
+15
to
+32
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainInterface methods are well-documented. The FocusStrategy interface methods are clearly documented with comments explaining their purpose. The TODO comments for fixing ESLint disables should be addressed in a future update. Keep track of these TODOs for future updates: 🌐 Web query: 💡 Result: To avoid Use Precise Type AnnotationsReplace function* safeGenerator(): Generator<number, void, string> {
const input: string = yield 42; // Yield number, accept string via next()
console.log(input.toUpperCase());
}This specifies:
Leverage
|
||||||||||||||
| Rule | Purpose | Example Fix |
|---|---|---|
no-unsafe-argument |
Prevents passing any to functions |
Type callback parameters |
no-unsafe-return |
Blocks returning any from generators |
Specify yield return type |
no-unsafe-assignment |
Catches implicit any assignments |
Add type annotations |
Generator-Specific Patterns
- Typed Iterators:
function* paginatedResults<T>(urls: string[]): Generator<Promise<T>, void> {
for (const url of urls) {
yield fetch(url).then(res => res.json());
}
}- Type Narrowing:
function* typeCheckedGenerator() {
const value = yield;
if (isValidType(value)) {
// Safely use narrowed type
}
}- Generic Generators:
function* asyncWrapper<T>(promise: Promise<T>): Generator<Promise<T>, T> {
return yield promise;
}Migration Strategy
- Enable
@typescript-eslint/no-explicit-anywith strict mode - Use ESLint's
--fixwithfixToUnknown: trueoption[1] - Gradually replace
unknownwith specific types - Utilize TypeScript's
ReturnTypeandYieldTypehelpers:
type YieldType<T> = T extends Generator<infer Y> ? Y : never;By combining these techniques, you maintain generator flexibility while eliminating unsafe any usage. The TypeScript 3.6+ Generator type provides strict type checking for yield/return/next interactions[14], and when combined with proper ESLint configuration, ensures comprehensive type safety across generator lifecycle operations.
Citations:
- 1: https://typescript-eslint.io/rules/no-explicit-any/
- 2: https://www.typescriptlang.org/docs/handbook/2/functions.html
- 3: https://typescript-eslint.io/rules/
- 4: https://typescript-eslint.io/blog/avoiding-anys/
- 5: https://www.assertnotmagic.com/2020/05/12/untangling-typescript-parameters/
- 6: https://typescript-eslint.io/rules/no-unsafe-function-type/
- 7: https://www.allthingstypescript.dev/p/why-avoid-the-any-type-in-typescript
- 8: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*
- 9: https://www.benmvp.com/blog/when-use-typescript-unknown-versus-any
- 10: https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html
- 11: https://www.typescriptlang.org/docs/handbook/functions.html
- 12: https://www.npmjs.com/package/@cling/eslint-config
- 13: https://docs.datadoghq.com/security/code_security/static_analysis/static_analysis_rules/typescript-best-practices/no-explicit-any/
- 14: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-6.html
- 15: [no-explicit-any] Allow safe usages of
anytypescript-eslint/typescript-eslint#1071 - 16: https://google.github.io/styleguide/tsguide.html
- 17: https://developer.huawei.com/consumer/en/doc/harmonyos-guides/ide_no-explicit-any-V13
- 18: https://caoslab.psy.cmu.edu:32443/developers/jsexperimentslayout/-/blob/1d532da4c3a5529e3c8a5b6b18bddc278538f258/client/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-explicit-any.md
Action Required: Update Generator Signatures for Strict Typing
The interface is well-documented; however, both generator methods currently use explicit any types (temporarily suppressed by ESLint) that could be improved. In light of best practices, please consider updating the signatures for getEntitiesForSet and getEntitiesForStore as follows:
-
Replace
anywith precise types:
Instead of usingGenerator<any, Array<FocusPath>, any>, annotate the generator with clear types for the yielded value, the return value, and the value accepted by.next(). For example, if the generator yields values of typeYieldType, returns anArray<FocusPath>, and accepts inputs of typeNextType, use:Generator<YieldType, Array<FocusPath>, NextType>
-
Consider using
unknownwhen appropriate:
If a type isn’t immediately known or can vary, usingunknownin place ofanycan preserve type safety until a more specific type can be determined. -
Plan for a gradual refactor:
Address these TODO comments by replacing the ESLint suppressions with proper type annotations based on your generator’s logic. This will improve maintainability and enforce stricter type checking.
Please keep track of these TODOs for a future update.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from "ce/navigation/AppIDEFocusSetters"; |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from "ce/navigation/FocusStrategy/types"; |
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.
Generator function should use yield statements.
This generator function doesn't contain any yield statements, which negates the purpose of using a generator. This should be either:
Or if you need to match the interface but don't need yield functionality in this specific implementation:
📝 Committable suggestion
🧰 Tools
🪛 Biome (1.9.4)
[error] 14-16: This generator function doesn't contain yield.
(lint/correctness/useYield)