-
Notifications
You must be signed in to change notification settings - Fork 18
feat(settings): simplify hook, split meta and LS cases #3111
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 7 commits
e9bd6a1
c25b134
a4ab272
c9989ef
d7dd85e
71b2224
dfa745a
7ff81e2
5d48c26
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 |
|---|---|---|
|
|
@@ -2,7 +2,6 @@ import type {AxiosWrapperOptions} from '@gravity-ui/axios-wrapper'; | |
| import type {AxiosRequestConfig} from 'axios'; | ||
|
|
||
| import {codeAssistBackend} from '../../store'; | ||
| import {uiFactory} from '../../uiFactory/uiFactory'; | ||
|
|
||
| import {AuthAPI} from './auth'; | ||
| import {CodeAssistAPI} from './codeAssist'; | ||
|
|
@@ -27,6 +26,7 @@ interface YdbEmbeddedAPIProps { | |
| proxyMeta: undefined | boolean; | ||
| // this setting allows to use schema object path relative to database in api requests | ||
| useRelativePath: undefined | boolean; | ||
| useMetaSettings: undefined | boolean; | ||
|
Member
Author
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. Moved So this help to reduce it to only one setting without any additional requirements |
||
| csrfTokenGetter: undefined | (() => string | undefined); | ||
| defaults: undefined | AxiosRequestConfig; | ||
| } | ||
|
|
@@ -54,6 +54,7 @@ export class YdbEmbeddedAPI { | |
| csrfTokenGetter = () => undefined, | ||
| defaults = {}, | ||
| useRelativePath = false, | ||
| useMetaSettings = false, | ||
| }: YdbEmbeddedAPIProps) { | ||
| const axiosParams: AxiosWrapperOptions = {config: {withCredentials, ...defaults}}; | ||
| const baseApiParams = {singleClusterMode, proxyMeta, useRelativePath}; | ||
|
|
@@ -62,7 +63,7 @@ export class YdbEmbeddedAPI { | |
| if (webVersion) { | ||
| this.meta = new MetaAPI(axiosParams, baseApiParams); | ||
| } | ||
| if (uiFactory.useMetaSettings) { | ||
| if (useMetaSettings) { | ||
|
Collaborator
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. previosly we had this in uiFactory - so this value could be overriden
Member
Author
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. Now it can be configured in In internal version we configure two entities - Code with bug: Correct code: It's not obvious at all and should not be that way. So I moved this setting to I don't consider this major, because this feature is not finished yet and does not work anywhere |
||
| this.metaSettings = new MetaSettingsAPI(axiosParams, baseApiParams); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ const initialState: AuthenticationState = { | |
| isAuthenticated: true, | ||
| user: undefined, | ||
| id: undefined, | ||
| metaUser: undefined, | ||
|
Member
Author
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. I did not figured out how to properly receive What are the problems with
|
||
| }; | ||
|
|
||
| export const slice = createSlice({ | ||
|
|
@@ -45,13 +46,13 @@ export const slice = createSlice({ | |
| selectIsUserAllowedToMakeChanges: (state) => state.isUserAllowedToMakeChanges, | ||
| selectIsViewerUser: (state) => state.isViewerUser, | ||
| selectUser: (state) => state.user, | ||
| selectID: (state) => state.id, | ||
| selectMetaUser: (state) => state.metaUser ?? state.id, | ||
| }, | ||
| }); | ||
|
|
||
| export default slice.reducer; | ||
| export const {setIsAuthenticated, setUser} = slice.actions; | ||
| export const {selectIsUserAllowedToMakeChanges, selectIsViewerUser, selectUser, selectID} = | ||
| export const {selectIsUserAllowedToMakeChanges, selectIsViewerUser, selectUser, selectMetaUser} = | ||
| slice.selectors; | ||
|
|
||
| export const authenticationApi = api.injectEndpoints({ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,4 +5,6 @@ export interface AuthenticationState { | |
|
|
||
| user: string | undefined; | ||
| id: string | undefined; | ||
|
|
||
|
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. logic: Prompt To Fix With AIThis is a comment left during a code review.
Path: src/store/reducers/authentication/types.ts
Line: 8:8
Comment:
**logic:** `metaUser` field is never set anywhere in the codebase - no reducer action populates this field. Since `selectMetaUser` returns `metaUser ?? id`, this will always fall back to `id`.
How can I resolve this? If you propose a fix, please make it concise.
Member
Author
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. It's intentional, user will be added with another PR |
||
| metaUser: string | undefined; | ||
artemmufazalov marked this conversation as resolved.
Show resolved
Hide resolved
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. style: Prompt To Fix With AIThis is a comment left during a code review.
Path: src/store/reducers/authentication/types.ts
Line: 9:9
Comment:
**style:** `metaUser` field is never populated anywhere in the codebase - no reducer action sets this value. Since `selectMetaUser` returns `metaUser ?? id`, it will always fall back to `id`. If this field is intended for future use, consider adding a comment explaining its purpose.
How can I resolve this? If you propose a fix, please make it concise. |
||
| } | ||
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.
Table loading changes are needed to synchronize settings and data loading states, without it tests somehow fail to find table container