Skip to content

Commit

Permalink
Fix setting form values; fix user tags check; set default tag's view_…
Browse files Browse the repository at this point in the history
…order to 1
  • Loading branch information
pijng committed Mar 17, 2024
1 parent c71c29b commit 7aaa574
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion internal/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ''
Expand Down
4 changes: 4 additions & 0 deletions internal/usecases/schema_usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions internal/usecases/tag_usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion web/src/features/api-token-edit/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const editApiTokenFx = createEffect((apiToken: ApiTokenToUpdate) => {

sample({
source: apiTokenModel.$currentApiToken,
target: apiTokenForm.setInitialForm,
target: apiTokenForm.setForm,
});

sample({
Expand Down
2 changes: 1 addition & 1 deletion web/src/features/schema-edit/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export const editSchemaFx = createEffect((schema: SchemaToUpdate) => {

sample({
source: schemaModel.$currentSchema,
target: schemaForm.setInitialForm,
target: [schemaForm.setForm],
});

sample({
Expand Down
2 changes: 1 addition & 1 deletion web/src/features/tag-edit/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const editTagFx = createEffect((tag: TagToUpdate) => {

sample({
source: tagModel.$currentTag,
target: tagForm.setInitialForm,
target: tagForm.setForm,
});

sample({
Expand Down
2 changes: 1 addition & 1 deletion web/src/features/user-edit/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const editUserFx = createEffect((user: UserToUpdate) => {

sample({
source: userModel.$currentUser,
target: memberForm.setInitialForm,
target: memberForm.setForm,
});

sample({
Expand Down
2 changes: 1 addition & 1 deletion web/src/shared/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down
2 changes: 1 addition & 1 deletion web/src/shared/routing/middlewares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const chainAuthorized = (route: RouteInstance<any>) => {
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,
});

Expand Down

0 comments on commit 7aaa574

Please sign in to comment.