Skip to content

Commit

Permalink
fix(webserver): allow setting only display name when updating provide…
Browse files Browse the repository at this point in the history
…rs (#2077)

* fix(webserver): allow setting only display name when updating providers

* [autofix.ci] apply automated fixes

* Update ee/tabby-db/src/gitlab_repository_provider.rs

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
boxbeam and autofix-ci[bot] authored May 9, 2024
1 parent 4793c82 commit e62d2ad
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 8 deletions.
7 changes: 6 additions & 1 deletion ee/tabby-db/src/github_repository_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ impl DbConn {
&self,
id: i64,
display_name: String,
access_token: String,
access_token: Option<String>,
) -> Result<()> {
let access_token = match access_token {
Some(access_token) => Some(access_token),
None => self.get_github_provider(id).await?.access_token,
};

let res = query!(
"UPDATE github_repository_provider SET display_name = ?, access_token=? WHERE id = ?;",
display_name,
Expand Down
7 changes: 6 additions & 1 deletion ee/tabby-db/src/gitlab_repository_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ impl DbConn {
&self,
id: i64,
display_name: String,
access_token: String,
access_token: Option<String>,
) -> Result<()> {
let access_token = match access_token {
Some(access_token) => Some(access_token),
None => self.get_gitlab_provider(id).await?.access_token,
};

let res = query!(
"UPDATE gitlab_repository_provider SET display_name = ?, access_token=? WHERE id = ?;",
display_name,
Expand Down
2 changes: 1 addition & 1 deletion ee/tabby-schema/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ input UpdateOAuthCredentialInput {
input UpdateRepositoryProviderInput {
id: ID!
displayName: String!
accessToken: String!
accessToken: String
}

"""
Expand Down
2 changes: 1 addition & 1 deletion ee/tabby-schema/src/schema/repository/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub trait GithubRepositoryService: Send + Sync + RepositoryProvider {
&self,
id: ID,
display_name: String,
access_token: String,
access_token: Option<String>,
) -> Result<()>;

async fn list_providers(
Expand Down
2 changes: 1 addition & 1 deletion ee/tabby-schema/src/schema/repository/gitlab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub trait GitlabRepositoryService: Send + Sync + RepositoryProvider {
&self,
id: ID,
display_name: String,
access_token: String,
access_token: Option<String>,
) -> Result<()>;

async fn list_providers(
Expand Down
2 changes: 1 addition & 1 deletion ee/tabby-schema/src/schema/repository/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct UpdateRepositoryProviderInput {
))]
pub display_name: String,
#[validate(length(code = "accessToken", min = 10, message = "Invalid access token"))]
pub access_token: String,
pub access_token: Option<String>,
}

#[derive(GraphQLEnum, Debug, PartialEq)]
Expand Down
2 changes: 1 addition & 1 deletion ee/tabby-webserver/src/service/repository/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl GithubRepositoryService for GithubRepositoryProviderServiceImpl {
&self,
id: ID,
display_name: String,
access_token: String,
access_token: Option<String>,
) -> Result<()> {
let id = id.as_rowid()?;
self.db
Expand Down
2 changes: 1 addition & 1 deletion ee/tabby-webserver/src/service/repository/gitlab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl GitlabRepositoryService for GitlabRepositoryProviderServiceImpl {
&self,
id: ID,
display_name: String,
access_token: String,
access_token: Option<String>,
) -> Result<()> {
let id = id.as_rowid()?;
self.db
Expand Down

0 comments on commit e62d2ad

Please sign in to comment.