Skip to content

feat: add force refresh of license entitlements #9155

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Formatting
  • Loading branch information
Emyrk committed Aug 17, 2023
commit 535a80a216dbad7894eb7e58f82154821daf6644
2 changes: 1 addition & 1 deletion codersdk/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type Entitlements struct {
HasLicense bool `json:"has_license"`
Trial bool `json:"trial"`
RequireTelemetry bool `json:"require_telemetry"`
RefreshedAt time.Time `json:"refreshed_at"`
RefreshedAt time.Time `json:"refreshed_at"`
}

func (c *Client) Entitlements(ctx context.Context) (Entitlements, error) {
Expand Down
4 changes: 1 addition & 3 deletions enterprise/coderd/licenses.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,7 @@ func (api *API) postLicense(rw http.ResponseWriter, r *http.Request) {
// @Success 201 {object} codersdk.Response
// @Router /licenses/refresh-entitlements [post]
func (api *API) postRefreshEntitlements(rw http.ResponseWriter, r *http.Request) {
var (
ctx = r.Context()
)
ctx := r.Context()

// If the user cannot create a new license, then they cannot refresh entitlements.
// Refreshing entitlements is a way to force a refresh of the license, so it is
Expand Down
2 changes: 1 addition & 1 deletion site/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ export const getEntitlements = async (): Promise<TypesGen.Entitlements> => {
require_telemetry: false,
trial: false,
warnings: [],
refreshed_at:"",
refreshed_at: "",
}
}
throw ex
Expand Down
8 changes: 4 additions & 4 deletions site/src/testHelpers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,7 @@ export const MockEntitlements: TypesGen.Entitlements = {
features: withDefaultFeatures({}),
require_telemetry: false,
trial: false,
refreshed_at:"2022-05-20T16:45:57.122Z",
refreshed_at: "2022-05-20T16:45:57.122Z",
}

export const MockEntitlementsWithWarnings: TypesGen.Entitlements = {
Expand All @@ -1459,7 +1459,7 @@ export const MockEntitlementsWithWarnings: TypesGen.Entitlements = {
has_license: true,
trial: false,
require_telemetry: false,
refreshed_at:"2022-05-20T16:45:57.122Z",
refreshed_at: "2022-05-20T16:45:57.122Z",
features: withDefaultFeatures({
user_limit: {
enabled: true,
Expand All @@ -1484,7 +1484,7 @@ export const MockEntitlementsWithAuditLog: TypesGen.Entitlements = {
has_license: true,
require_telemetry: false,
trial: false,
refreshed_at:"2022-05-20T16:45:57.122Z",
refreshed_at: "2022-05-20T16:45:57.122Z",
features: withDefaultFeatures({
audit_log: {
enabled: true,
Expand All @@ -1499,7 +1499,7 @@ export const MockEntitlementsWithScheduling: TypesGen.Entitlements = {
has_license: true,
require_telemetry: false,
trial: false,
refreshed_at:"2022-05-20T16:45:57.122Z",
refreshed_at: "2022-05-20T16:45:57.122Z",
features: withDefaultFeatures({
advanced_template_scheduling: {
enabled: true,
Expand Down
8 changes: 4 additions & 4 deletions site/src/xServices/entitlements/entitlementsXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ export const entitlementsMachine = createMachine(
},
idle: {
on: {
REFRESH: "refresh"
}
REFRESH: "refresh",
},
},
success: {
type: "final",
},
error: {
on: {
REFRESH: "refresh"
}
REFRESH: "refresh",
},
},
},
},
Expand Down