Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add preferred_proxy to user account preferences#18916

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
blink-so wants to merge44 commits intomain
base:main
Choose a base branch
Loading
fromfeat/preferred-proxy-user-preferences
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
44 commits
Select commitHold shift + click to select a range
400250a
feat: add preferred_proxy to user account preferences
blink-so[bot]Jul 17, 2025
b6fc891
Fix formatting issues in ProxyContext.tsx
blink-so[bot]Jul 17, 2025
0513fb9
Fix additional formatting issues in ProxyContext.tsx
blink-so[bot]Jul 17, 2025
64c38b3
Fix final formatting issues in ProxyContext.tsx
blink-so[bot]Jul 17, 2025
c70efd8
Add database layer for user preferred proxy functionality
blink-so[bot]Jul 17, 2025
79a63e1
Fix temporal dead zone error in ProxyContext
blink-so[bot]Jul 17, 2025
f0f8349
Fix ProxyContext race condition in proxy state initialization
blink-so[bot]Jul 17, 2025
de8ac45
fix: resolve temporal dead zone in ProxyContext initialization
blink-so[bot]Jul 17, 2025
2cba5ea
fix: enable latency-based proxy selection in updateProxy
blink-so[bot]Jul 17, 2025
5fbc42d
fix: improve latency-based proxy selection logic
blink-so[bot]Jul 17, 2025
b63624f
fix: restore original proxy selection logic with auto-selection useEf…
blink-so[bot]Jul 17, 2025
34b40da
fix: add userSavedProxy to auto-selection useEffect dependencies
blink-so[bot]Jul 17, 2025
7ef638f
fix: revert userSavedProxy from auto-selection useEffect dependencies
blink-so[bot]Jul 17, 2025
1e4e116
revert: restore original working ProxyContext from c70efd8e6
blink-so[bot]Jul 17, 2025
d4bab5e
fix: temporarily disable new proxy API calls until backend is impleme…
blink-so[bot]Jul 17, 2025
abcdccc
fix: simplify proxy state initialization to avoid temporal dead zone
blink-so[bot]Jul 17, 2025
85c61d6
fix: completely revert to localStorage-only proxy selection
blink-so[bot]Jul 17, 2025
15a7819
fix: remove extra blank line in ProxyContext.tsx
blink-so[bot]Jul 17, 2025
1697b42
fix: restore original proxy auto-selection logic
blink-so[bot]Jul 17, 2025
8c2b457
fix: remove unused import and fix proxy auto-selection race condition
blink-so[bot]Jul 17, 2025
ffbeed9
fix: use useState for userSavedProxy to make it reactive
blink-so[bot]Jul 17, 2025
4395209
fix: remove unused import in proxy_test.go
blink-so[bot]Jul 17, 2025
1901a54
fix: remove temporary Python files causing typo lint errors
blink-so[bot]Jul 17, 2025
1899405
fix: regenerate TypeScript types after adding UserProxySettings
blink-so[bot]Jul 17, 2025
d2b1075
fix: correct indentation in TypeScript types (use tabs instead of spa…
blink-so[bot]Jul 17, 2025
eec9a99
fix: format TypeScript types to match Biome expectations
blink-so[bot]Jul 17, 2025
15bc991
fix: convert all spaces to tabs in TypeScript types file
blink-so[bot]Jul 17, 2025
9b8e7a5
fix: adjust TypeScript formatting to match Biome expectations
blink-so[bot]Jul 17, 2025
f059b37
fix: ensure consistent tab indentation and fix specific Biome formatt…
blink-so[bot]Jul 17, 2025
0543dc7
fix: comprehensive Biome formatting fixes for TypeScript types
blink-so[bot]Jul 17, 2025
4f8f7aa
Fix failing tests for user proxy preferences
blink-so[bot]Jul 17, 2025
5a1f953
Fix TypeScript formatting - convert spaces to tabs in generated file
blink-so[bot]Jul 17, 2025
67f5e53
Fix TypeScript formatting in generated types file
blink-so[bot]Jul 17, 2025
f6b459a
Fix comprehensive TypeScript formatting issues
blink-so[bot]Jul 17, 2025
0ed5a1f
Fix final TypeScript formatting issues
blink-so[bot]Jul 17, 2025
a66ff90
Fix TypeScript formatting with precise rules
blink-so[bot]Jul 17, 2025
0cc531a
Fix TypeScript formatting with simple indentation rules
blink-so[bot]Jul 17, 2025
ae58313
Attempt to fix TypeScript line break issues
blink-so[bot]Jul 17, 2025
c436679
fix: repair corrupted SerpentOption interface value property
blink-so[bot]Jul 17, 2025
ebd53ed
fix: format TypeScript generated file to match Biome rules
blink-so[bot]Jul 17, 2025
b7cad3c
fix: apply targeted TypeScript formatting for Biome compliance
blink-so[bot]Jul 17, 2025
f702a84
fix: convert spaces to tabs in TypeScript generated file
blink-so[bot]Jul 17, 2025
b67e1ca
fix: apply specific Biome formatting requirements
blink-so[bot]Jul 17, 2025
fb52913
fix: apply Biome formatting to TypeScript generated file
blink-so[bot]Jul 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletionscoderd/coderd.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1267,6 +1267,9 @@ func New(options *Options) *API {
})
r.Get("/appearance", api.userAppearanceSettings)
r.Put("/appearance", api.putUserAppearanceSettings)
r.Get("/proxy", api.userProxySettings)
r.Put("/proxy", api.putUserProxySettings)
r.Delete("/proxy", api.deleteUserProxySettings)
r.Route("/password", func(r chi.Router) {
r.Use(httpmw.RateLimit(options.LoginRateLimit, time.Minute))
r.Put("/", api.putUserPassword)
Expand Down
33 changes: 33 additions & 0 deletionscoderd/database/dbauthz/dbauthz.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4884,6 +4884,39 @@ func (q *querier) UpdateUserThemePreference(ctx context.Context, arg database.Up
return q.db.UpdateUserThemePreference(ctx, arg)
}

func (q *querier) GetUserPreferredProxy(ctx context.Context, userID uuid.UUID) (string, error) {
u, err := q.db.GetUserByID(ctx, userID)
if err != nil {
return "", err
}
if err := q.authorizeContext(ctx, policy.ActionRead, u); err != nil {
return "", err
}
return q.db.GetUserPreferredProxy(ctx, userID)
}

func (q *querier) UpdateUserPreferredProxy(ctx context.Context, arg database.UpdateUserPreferredProxyParams) (database.UserConfig, error) {
u, err := q.db.GetUserByID(ctx, arg.UserID)
if err != nil {
return database.UserConfig{}, err
}
if err := q.authorizeContext(ctx, policy.ActionUpdatePersonal, u); err != nil {
return database.UserConfig{}, err
}
return q.db.UpdateUserPreferredProxy(ctx, arg)
}

func (q *querier) DeleteUserPreferredProxy(ctx context.Context, userID uuid.UUID) error {
u, err := q.db.GetUserByID(ctx, userID)
if err != nil {
return err
}
if err := q.authorizeContext(ctx, policy.ActionUpdatePersonal, u); err != nil {
return err
}
return q.db.DeleteUserPreferredProxy(ctx, userID)
}

func (q *querier) UpdateVolumeResourceMonitor(ctx context.Context, arg database.UpdateVolumeResourceMonitorParams) error {
if err := q.authorizeContext(ctx, policy.ActionUpdate, rbac.ResourceWorkspaceAgentResourceMonitor); err != nil {
return err
Expand Down
18 changes: 18 additions & 0 deletionscoderd/database/dbauthz/dbauthz_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4896,6 +4896,24 @@ func (s *MethodTestSuite) TestNotifications() {
}).Asserts(rbac.ResourceNotificationPreference.WithOwner(user.ID.String()), policy.ActionUpdate)
}))

s.Run("GetUserPreferredProxy", s.Subtest(func(db database.Store, check *expects) {
user := dbgen.User(s.T(), db, database.User{})
check.Args(user.ID).
Asserts(rbac.ResourceUser.WithOwner(user.ID.String()), policy.ActionReadPersonal)
}))
s.Run("UpdateUserPreferredProxy", s.Subtest(func(db database.Store, check *expects) {
user := dbgen.User(s.T(), db, database.User{})
check.Args(database.UpdateUserPreferredProxyParams{
UserID: user.ID,
PreferredProxy: "proxy1",
}).Asserts(rbac.ResourceUser.WithOwner(user.ID.String()), policy.ActionUpdatePersonal)
}))
s.Run("DeleteUserPreferredProxy", s.Subtest(func(db database.Store, check *expects) {
user := dbgen.User(s.T(), db, database.User{})
check.Args(user.ID).
Asserts(rbac.ResourceUser.WithOwner(user.ID.String()), policy.ActionUpdatePersonal)
}))

s.Run("GetInboxNotificationsByUserID", s.Subtest(func(db database.Store, check *expects) {
u := dbgen.User(s.T(), db, database.User{})

Expand Down
21 changes: 21 additions & 0 deletionscoderd/database/dbmetrics/querymetrics.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

44 changes: 44 additions & 0 deletionscoderd/database/dbmock/dbmock.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

3 changes: 3 additions & 0 deletionscoderd/database/querier.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

55 changes: 55 additions & 0 deletionscoderd/database/queries.sql.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

28 changes: 28 additions & 0 deletionscoderd/database/queries/users.sql
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -148,6 +148,34 @@ WHERE user_configs.user_id = @user_id
AND user_configs.key = 'terminal_font'
RETURNING *;

-- name: GetUserPreferredProxy :one
SELECT
value as preferred_proxy
FROM
user_configs
WHERE
user_id = @user_id
AND key = 'preferred_proxy';

-- name: UpdateUserPreferredProxy :one
INSERT INTO
user_configs (user_id, key, value)
VALUES
(@user_id, 'preferred_proxy', @preferred_proxy)
ON CONFLICT
ON CONSTRAINT user_configs_pkey
DO UPDATE
SET
value = @preferred_proxy
WHERE user_configs.user_id = @user_id
AND user_configs.key = 'preferred_proxy'
RETURNING *;

-- name: DeleteUserPreferredProxy :exec
DELETE FROM user_configs
WHERE user_id = @user_id
AND key = 'preferred_proxy';

-- name: UpdateUserRoles :one
UPDATE
users
Expand Down
98 changes: 98 additions & 0 deletionscoderd/users.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1066,6 +1066,104 @@ func (api *API) putUserAppearanceSettings(rw http.ResponseWriter, r *http.Reques
})
}

// @Summary Get user proxy settings
// @ID get-user-proxy-settings
// @Security CoderSessionToken
// @Produce json
// @Tags Users
// @Param user path string true "User ID, name, or me"
// @Success 200 {object} codersdk.UserProxySettings
// @Router /users/{user}/proxy [get]
func (api *API) userProxySettings(rw http.ResponseWriter, r *http.Request) {
var (
ctx = r.Context()
user = httpmw.UserParam(r)
)

preferredProxy, err := api.Database.GetUserPreferredProxy(ctx, user.ID)
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
httpapi.Write(ctx, rw, http.StatusNotFound, codersdk.Response{
Message: "User proxy settings not found.",
})
return
}

httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
Message: "Error reading user proxy settings.",
Detail: err.Error(),
})
return
}

httpapi.Write(ctx, rw, http.StatusOK, codersdk.UserProxySettings{
PreferredProxy: preferredProxy,
})
}

// @Summary Update user proxy settings
// @ID update-user-proxy-settings
// @Security CoderSessionToken
// @Accept json
// @Produce json
// @Tags Users
// @Param user path string true "User ID, name, or me"
// @Param request body codersdk.UpdateUserProxySettingsRequest true "New proxy settings"
// @Success 200 {object} codersdk.UserProxySettings
// @Router /users/{user}/proxy [put]
func (api *API) putUserProxySettings(rw http.ResponseWriter, r *http.Request) {
var (
ctx = r.Context()
user = httpmw.UserParam(r)
)

var params codersdk.UpdateUserProxySettingsRequest
if !httpapi.Read(ctx, rw, r, &params) {
return
}

updatedPreferredProxy, err := api.Database.UpdateUserPreferredProxy(ctx, database.UpdateUserPreferredProxyParams{
UserID: user.ID,
PreferredProxy: params.PreferredProxy,
})
if err != nil {
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
Message: "Internal error updating user proxy preference.",
Detail: err.Error(),
})
return
}

httpapi.Write(ctx, rw, http.StatusOK, codersdk.UserProxySettings{
PreferredProxy: updatedPreferredProxy.Value,
})
}

// @Summary Delete user proxy settings
// @ID delete-user-proxy-settings
// @Security CoderSessionToken
// @Tags Users
// @Param user path string true "User ID, name, or me"
// @Success 204
// @Router /users/{user}/proxy [delete]
func (api *API) deleteUserProxySettings(rw http.ResponseWriter, r *http.Request) {
var (
ctx = r.Context()
user = httpmw.UserParam(r)
)

err := api.Database.DeleteUserPreferredProxy(ctx, user.ID)
if err != nil {
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
Message: "Internal error deleting user proxy preference.",
Detail: err.Error(),
})
return
}

rw.WriteHeader(http.StatusNoContent)
}

func isValidFontName(font codersdk.TerminalFontName) bool {
return slices.Contains(codersdk.TerminalFontNames, font)
}
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp