feat: add 'hidden' option to 'coder_app' to hide app from UI (#14570)

Add 'hidden' property to 'coder_app' resource to allow hiding apps from the UI.
This commit is contained in:
Danielle Maywood
2024-09-09 14:39:32 +01:00
committed by GitHub
parent 918bea18c1
commit 25f1ddbf5e
36 changed files with 848 additions and 696 deletions
+1
View File
@@ -229,5 +229,6 @@ func dbAppToProto(dbApp database.WorkspaceApp, agent database.WorkspaceAgent, ow
Threshold: dbApp.HealthcheckThreshold,
},
Health: agentproto.WorkspaceApp_Health(healthRaw),
Hidden: dbApp.Hidden,
}, nil
}
+5
View File
@@ -87,6 +87,7 @@ func TestGetManifest(t *testing.T) {
Subdomain: false,
SharingLevel: database.AppSharingLevelPublic,
Health: database.WorkspaceAppHealthDisabled,
Hidden: false,
},
{
ID: uuid.New(),
@@ -102,6 +103,7 @@ func TestGetManifest(t *testing.T) {
HealthcheckUrl: "http://localhost:4321/health",
HealthcheckInterval: 20,
HealthcheckThreshold: 5,
Hidden: true,
},
}
scripts = []database.WorkspaceAgentScript{
@@ -182,6 +184,7 @@ func TestGetManifest(t *testing.T) {
Threshold: apps[0].HealthcheckThreshold,
},
Health: agentproto.WorkspaceApp_HEALTHY,
Hidden: false,
},
{
Id: apps[1].ID[:],
@@ -200,6 +203,7 @@ func TestGetManifest(t *testing.T) {
Threshold: 0,
},
Health: agentproto.WorkspaceApp_DISABLED,
Hidden: false,
},
{
Id: apps[2].ID[:],
@@ -218,6 +222,7 @@ func TestGetManifest(t *testing.T) {
Threshold: apps[2].HealthcheckThreshold,
},
Health: agentproto.WorkspaceApp_UNHEALTHY,
Hidden: true,
},
}
protoScripts = []*agentproto.WorkspaceAgentScript{
+3
View File
@@ -14006,6 +14006,9 @@ const docTemplate = `{
}
]
},
"hidden": {
"type": "boolean"
},
"icon": {
"description": "Icon is a relative path or external URL that specifies\nan icon to be displayed in the dashboard.",
"type": "string"
+3
View File
@@ -12748,6 +12748,9 @@
}
]
},
"hidden": {
"type": "boolean"
},
"icon": {
"description": "Icon is a relative path or external URL that specifies\nan icon to be displayed in the dashboard.",
"type": "string"
+1
View File
@@ -517,6 +517,7 @@ func Apps(dbApps []database.WorkspaceApp, agent database.WorkspaceAgent, ownerNa
Threshold: dbApp.HealthcheckThreshold,
},
Health: codersdk.WorkspaceAppHealth(dbApp.Health),
Hidden: dbApp.Hidden,
})
}
return apps
+1
View File
@@ -547,6 +547,7 @@ func WorkspaceApp(t testing.TB, db database.Store, orig database.WorkspaceApp) d
HealthcheckThreshold: takeFirst(orig.HealthcheckThreshold, 60),
Health: takeFirst(orig.Health, database.WorkspaceAppHealthHealthy),
DisplayOrder: takeFirst(orig.DisplayOrder, 1),
Hidden: orig.Hidden,
})
require.NoError(t, err, "insert app")
return resource
+1
View File
@@ -7291,6 +7291,7 @@ func (q *FakeQuerier) InsertWorkspaceApp(_ context.Context, arg database.InsertW
HealthcheckInterval: arg.HealthcheckInterval,
HealthcheckThreshold: arg.HealthcheckThreshold,
Health: arg.Health,
Hidden: arg.Hidden,
DisplayOrder: arg.DisplayOrder,
}
q.workspaceApps = append(q.workspaceApps, workspaceApp)
+4 -1
View File
@@ -1473,11 +1473,14 @@ CREATE TABLE workspace_apps (
sharing_level app_sharing_level DEFAULT 'owner'::app_sharing_level NOT NULL,
slug text NOT NULL,
external boolean DEFAULT false NOT NULL,
display_order integer DEFAULT 0 NOT NULL
display_order integer DEFAULT 0 NOT NULL,
hidden boolean DEFAULT false NOT NULL
);
COMMENT ON COLUMN workspace_apps.display_order IS 'Specifies the order in which to display agent app in user interfaces.';
COMMENT ON COLUMN workspace_apps.hidden IS 'Determines if the app is not shown in user interfaces.';
CREATE TABLE workspace_build_parameters (
workspace_build_id uuid NOT NULL,
name text NOT NULL,
@@ -0,0 +1 @@
ALTER TABLE workspace_apps DROP COLUMN hidden;
@@ -0,0 +1,4 @@
ALTER TABLE workspace_apps ADD COLUMN hidden boolean NOT NULL DEFAULT false;
COMMENT ON COLUMN workspace_apps.hidden
IS 'Determines if the app is not shown in user interfaces.'
+2
View File
@@ -2843,6 +2843,8 @@ type WorkspaceApp struct {
External bool `db:"external" json:"external"`
// Specifies the order in which to display agent app in user interfaces.
DisplayOrder int32 `db:"display_order" json:"display_order"`
// Determines if the app is not shown in user interfaces.
Hidden bool `db:"hidden" json:"hidden"`
}
// A record of workspace app usage statistics
+14 -6
View File
@@ -11956,7 +11956,7 @@ func (q *sqlQuerier) InsertWorkspaceAgentStats(ctx context.Context, arg InsertWo
}
const getWorkspaceAppByAgentIDAndSlug = `-- name: GetWorkspaceAppByAgentIDAndSlug :one
SELECT id, created_at, agent_id, display_name, icon, command, url, healthcheck_url, healthcheck_interval, healthcheck_threshold, health, subdomain, sharing_level, slug, external, display_order FROM workspace_apps WHERE agent_id = $1 AND slug = $2
SELECT id, created_at, agent_id, display_name, icon, command, url, healthcheck_url, healthcheck_interval, healthcheck_threshold, health, subdomain, sharing_level, slug, external, display_order, hidden FROM workspace_apps WHERE agent_id = $1 AND slug = $2
`
type GetWorkspaceAppByAgentIDAndSlugParams struct {
@@ -11984,12 +11984,13 @@ func (q *sqlQuerier) GetWorkspaceAppByAgentIDAndSlug(ctx context.Context, arg Ge
&i.Slug,
&i.External,
&i.DisplayOrder,
&i.Hidden,
)
return i, err
}
const getWorkspaceAppsByAgentID = `-- name: GetWorkspaceAppsByAgentID :many
SELECT id, created_at, agent_id, display_name, icon, command, url, healthcheck_url, healthcheck_interval, healthcheck_threshold, health, subdomain, sharing_level, slug, external, display_order FROM workspace_apps WHERE agent_id = $1 ORDER BY slug ASC
SELECT id, created_at, agent_id, display_name, icon, command, url, healthcheck_url, healthcheck_interval, healthcheck_threshold, health, subdomain, sharing_level, slug, external, display_order, hidden FROM workspace_apps WHERE agent_id = $1 ORDER BY slug ASC
`
func (q *sqlQuerier) GetWorkspaceAppsByAgentID(ctx context.Context, agentID uuid.UUID) ([]WorkspaceApp, error) {
@@ -12018,6 +12019,7 @@ func (q *sqlQuerier) GetWorkspaceAppsByAgentID(ctx context.Context, agentID uuid
&i.Slug,
&i.External,
&i.DisplayOrder,
&i.Hidden,
); err != nil {
return nil, err
}
@@ -12033,7 +12035,7 @@ func (q *sqlQuerier) GetWorkspaceAppsByAgentID(ctx context.Context, agentID uuid
}
const getWorkspaceAppsByAgentIDs = `-- name: GetWorkspaceAppsByAgentIDs :many
SELECT id, created_at, agent_id, display_name, icon, command, url, healthcheck_url, healthcheck_interval, healthcheck_threshold, health, subdomain, sharing_level, slug, external, display_order FROM workspace_apps WHERE agent_id = ANY($1 :: uuid [ ]) ORDER BY slug ASC
SELECT id, created_at, agent_id, display_name, icon, command, url, healthcheck_url, healthcheck_interval, healthcheck_threshold, health, subdomain, sharing_level, slug, external, display_order, hidden FROM workspace_apps WHERE agent_id = ANY($1 :: uuid [ ]) ORDER BY slug ASC
`
func (q *sqlQuerier) GetWorkspaceAppsByAgentIDs(ctx context.Context, ids []uuid.UUID) ([]WorkspaceApp, error) {
@@ -12062,6 +12064,7 @@ func (q *sqlQuerier) GetWorkspaceAppsByAgentIDs(ctx context.Context, ids []uuid.
&i.Slug,
&i.External,
&i.DisplayOrder,
&i.Hidden,
); err != nil {
return nil, err
}
@@ -12077,7 +12080,7 @@ func (q *sqlQuerier) GetWorkspaceAppsByAgentIDs(ctx context.Context, ids []uuid.
}
const getWorkspaceAppsCreatedAfter = `-- name: GetWorkspaceAppsCreatedAfter :many
SELECT id, created_at, agent_id, display_name, icon, command, url, healthcheck_url, healthcheck_interval, healthcheck_threshold, health, subdomain, sharing_level, slug, external, display_order FROM workspace_apps WHERE created_at > $1 ORDER BY slug ASC
SELECT id, created_at, agent_id, display_name, icon, command, url, healthcheck_url, healthcheck_interval, healthcheck_threshold, health, subdomain, sharing_level, slug, external, display_order, hidden FROM workspace_apps WHERE created_at > $1 ORDER BY slug ASC
`
func (q *sqlQuerier) GetWorkspaceAppsCreatedAfter(ctx context.Context, createdAt time.Time) ([]WorkspaceApp, error) {
@@ -12106,6 +12109,7 @@ func (q *sqlQuerier) GetWorkspaceAppsCreatedAfter(ctx context.Context, createdAt
&i.Slug,
&i.External,
&i.DisplayOrder,
&i.Hidden,
); err != nil {
return nil, err
}
@@ -12138,10 +12142,11 @@ INSERT INTO
healthcheck_interval,
healthcheck_threshold,
health,
display_order
display_order,
hidden
)
VALUES
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16) RETURNING id, created_at, agent_id, display_name, icon, command, url, healthcheck_url, healthcheck_interval, healthcheck_threshold, health, subdomain, sharing_level, slug, external, display_order
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17) RETURNING id, created_at, agent_id, display_name, icon, command, url, healthcheck_url, healthcheck_interval, healthcheck_threshold, health, subdomain, sharing_level, slug, external, display_order, hidden
`
type InsertWorkspaceAppParams struct {
@@ -12161,6 +12166,7 @@ type InsertWorkspaceAppParams struct {
HealthcheckThreshold int32 `db:"healthcheck_threshold" json:"healthcheck_threshold"`
Health WorkspaceAppHealth `db:"health" json:"health"`
DisplayOrder int32 `db:"display_order" json:"display_order"`
Hidden bool `db:"hidden" json:"hidden"`
}
func (q *sqlQuerier) InsertWorkspaceApp(ctx context.Context, arg InsertWorkspaceAppParams) (WorkspaceApp, error) {
@@ -12181,6 +12187,7 @@ func (q *sqlQuerier) InsertWorkspaceApp(ctx context.Context, arg InsertWorkspace
arg.HealthcheckThreshold,
arg.Health,
arg.DisplayOrder,
arg.Hidden,
)
var i WorkspaceApp
err := row.Scan(
@@ -12200,6 +12207,7 @@ func (q *sqlQuerier) InsertWorkspaceApp(ctx context.Context, arg InsertWorkspace
&i.Slug,
&i.External,
&i.DisplayOrder,
&i.Hidden,
)
return i, err
}
+3 -2
View File
@@ -28,10 +28,11 @@ INSERT INTO
healthcheck_interval,
healthcheck_threshold,
health,
display_order
display_order,
hidden
)
VALUES
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16) RETURNING *;
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17) RETURNING *;
-- name: UpdateWorkspaceAppHealthByID :exec
UPDATE
@@ -1918,6 +1918,7 @@ func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
HealthcheckThreshold: app.Healthcheck.Threshold,
Health: health,
DisplayOrder: int32(app.Order),
Hidden: app.Hidden,
})
if err != nil {
return xerrors.Errorf("insert app: %w", err)