From 7aaa574729499772ffafb5e3c816abf42d6159cd Mon Sep 17 00:00:00 2001 From: Mark Date: Sun, 17 Mar 2024 14:58:46 +0300 Subject: [PATCH] Fix setting form values; fix user tags check; set default tag's view_order to 1 --- internal/api/swagger.yaml | 2 +- internal/usecases/schema_usecase.go | 4 ++++ internal/usecases/tag_usecase.go | 4 ++++ web/src/features/api-token-edit/model.ts | 2 +- web/src/features/schema-edit/model.ts | 2 +- web/src/features/tag-edit/model.ts | 2 +- web/src/features/user-edit/model.ts | 2 +- web/src/shared/auth/index.ts | 2 +- web/src/shared/routing/middlewares.ts | 2 +- 9 files changed, 15 insertions(+), 7 deletions(-) diff --git a/internal/api/swagger.yaml b/internal/api/swagger.yaml index 1e5caa6..dda1304 100644 --- a/internal/api/swagger.yaml +++ b/internal/api/swagger.yaml @@ -9,7 +9,7 @@ info: license: name: Apache 2.0 url: http://www.apache.org/licenses/LICENSE-2.0.html - version: 1.6.2 + version: 1.6.3 externalDocs: description: Find out more about spec url: '' diff --git a/internal/usecases/schema_usecase.go b/internal/usecases/schema_usecase.go index bbb7ce9..0c8577a 100644 --- a/internal/usecases/schema_usecase.go +++ b/internal/usecases/schema_usecase.go @@ -102,6 +102,10 @@ func (uc *SchemaUseCase) GetAllSchemas(user *entities.User) ([]*entities.Schema, return nil, fmt.Errorf("failed querying all schemas") } + if user == nil { + return nil, fmt.Errorf("cannot get user for tag check") + } + if len(user.Tags) > 0 { var filteredSchemas []*entities.Schema for _, schema := range schemas { diff --git a/internal/usecases/tag_usecase.go b/internal/usecases/tag_usecase.go index 4898f64..68533e1 100644 --- a/internal/usecases/tag_usecase.go +++ b/internal/usecases/tag_usecase.go @@ -19,6 +19,10 @@ func (uc *TagUseCase) CreateTag(tag entities.Tag) (*entities.Tag, error) { return nil, fmt.Errorf("failed creating tag: `name` attribute is required") } + if tag.ViewOrder == 0 { + tag.ViewOrder = 1 + } + return uc.tagStorage.CreateTag(tag) } diff --git a/web/src/features/api-token-edit/model.ts b/web/src/features/api-token-edit/model.ts index 4508b9c..d9f424c 100644 --- a/web/src/features/api-token-edit/model.ts +++ b/web/src/features/api-token-edit/model.ts @@ -29,7 +29,7 @@ export const editApiTokenFx = createEffect((apiToken: ApiTokenToUpdate) => { sample({ source: apiTokenModel.$currentApiToken, - target: apiTokenForm.setInitialForm, + target: apiTokenForm.setForm, }); sample({ diff --git a/web/src/features/schema-edit/model.ts b/web/src/features/schema-edit/model.ts index 5aec964..ad415a2 100644 --- a/web/src/features/schema-edit/model.ts +++ b/web/src/features/schema-edit/model.ts @@ -143,7 +143,7 @@ export const editSchemaFx = createEffect((schema: SchemaToUpdate) => { sample({ source: schemaModel.$currentSchema, - target: schemaForm.setInitialForm, + target: [schemaForm.setForm], }); sample({ diff --git a/web/src/features/tag-edit/model.ts b/web/src/features/tag-edit/model.ts index 887ffad..acf7d69 100644 --- a/web/src/features/tag-edit/model.ts +++ b/web/src/features/tag-edit/model.ts @@ -29,7 +29,7 @@ export const editTagFx = createEffect((tag: TagToUpdate) => { sample({ source: tagModel.$currentTag, - target: tagForm.setInitialForm, + target: tagForm.setForm, }); sample({ diff --git a/web/src/features/user-edit/model.ts b/web/src/features/user-edit/model.ts index 8891c35..09cde4c 100644 --- a/web/src/features/user-edit/model.ts +++ b/web/src/features/user-edit/model.ts @@ -53,7 +53,7 @@ export const editUserFx = createEffect((user: UserToUpdate) => { sample({ source: userModel.$currentUser, - target: memberForm.setInitialForm, + target: memberForm.setForm, }); sample({ diff --git a/web/src/shared/auth/index.ts b/web/src/shared/auth/index.ts index a70382a..8c78493 100644 --- a/web/src/shared/auth/index.ts +++ b/web/src/shared/auth/index.ts @@ -39,7 +39,7 @@ export const createInitialAdmin = createEvent(); sample({ clock: getSessionFx.doneData, - filter: (sessionResponse) => sessionResponse.success && sessionResponse.data.should_create_initial_admin, + filter: (sessionResponse) => sessionResponse.success && sessionResponse.data?.should_create_initial_admin, target: createInitialAdmin, }); diff --git a/web/src/shared/routing/middlewares.ts b/web/src/shared/routing/middlewares.ts index 0d70290..ea09986 100644 --- a/web/src/shared/routing/middlewares.ts +++ b/web/src/shared/routing/middlewares.ts @@ -23,7 +23,7 @@ export const chainAuthorized = (route: RouteInstance) => { sample({ source: getSessionFx.doneData, filter: (sessionResponse) => - (!sessionResponse?.data?.token || !sessionResponse.success) && !sessionResponse.data.should_create_initial_admin, + (!sessionResponse?.data?.token || !sessionResponse.success) && !sessionResponse.data?.should_create_initial_admin, target: unauthorizedTriggered, });