Skip to content

Conversation

klakhov
Copy link
Contributor

@klakhov klakhov commented Sep 16, 2025

Motivation and context

Provides a card inside 'security' of user profile with a table of API keys, and a form to create/edit them

Depends on #9680, #9835

How has this been tested?

Checklist

  • I submit my changes into the develop branch
  • I have created a changelog fragment
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • I have linked related issues (see GitHub docs)

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.

Comment on lines 8 to 12
export type APIApiTokenSaveFields = Partial<Pick<SerializedApiTokenData, 'name' | 'expiry_date' | 'read_only'>>;
export type ApiTokenSaveFields = CamelizedV2<APIApiTokenSaveFields>;

export type APIUserSaveFields = Partial<Pick<SerializedUser, 'first_name' | 'last_name'>>;
export type UserSaveFields = CamelizedV2<APIUserSaveFields>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of using Modifiable/Mutable/Updatable fields instead?
SaveFields does not exactly reflect the idea IMO

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to Modifiable

result.value = this.#value;
}

return result as SerializedApiTokenData;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From implementation I see it returns Partial<SerializedApiTokenData>, not SerializedApiTokenData.
Declaration is not correct

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated implementation and SerializedApiToken type so no conversion is needed

updateUserFailed: (error: unknown) => createAction(AuthActionTypes.UPDATE_USER_FAILED, { error }),
getApiTokens: () => createAction(AuthActionTypes.GET_API_TOKENS),
getApiTokensSuccess: (tokens: ApiToken[]) => createAction(AuthActionTypes.GET_API_TOKENS_SUCCESS, { tokens }),
getApiTokensFailed: (error: any) => createAction(AuthActionTypes.GET_API_TOKENS_FAILED, { error }),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everywhere (here and lines below) should be error: Error according to ErrorState interface and your code reason: action.payload.error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with typing error here as Error is that we get typescript error in actions in catch section: Catch clause variable type annotation must be 'any' or 'unknown' if specified. Should we catch any and convert it explicitly to Error?

return true;
}

async function getApiTokens(filter: APIApiTokensFilter = {}): Promise<PaginatedResource<SerializedRequest>> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The filter supports pagination and, nevertheless, always returns all results.
Do you see any reasons why we cannot paginate it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, we could paginate it. But to do that, we’d need to add support for server-side pagination in our cvat-table component, which currently expects the full dataset.

The question is: do we really need it? I’d assume the table will have, at most, tens of rows—not hundreds.

@bsekachev
Copy link
Member

@klakhov

Please, merge with develop and resolve conflicts

@zhiltsov-max
Copy link
Contributor

@klakhov, the server has the updated owner field representation in responses - now it's a standard basic user structure instead of just an id.

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
4 Security Hotspots

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants