Skip to content

Commit

Permalink
dismissed cue (#4211)
Browse files Browse the repository at this point in the history
  • Loading branch information
markxiong0122 authored Aug 7, 2024
1 parent 796b60b commit 59a78a8
Show file tree
Hide file tree
Showing 18 changed files with 842 additions and 5 deletions.
14 changes: 9 additions & 5 deletions api/cues_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from chromestatus_openapi.models import (DismissCueRequest)

import logging

from framework import basehandlers
Expand All @@ -33,12 +35,14 @@ class CuesAPI(basehandlers.APIHandler):

def do_post(self, **kwargs):
"""Dismisses a cue card for the signed in user."""
cue = self.get_param('cue', allowed=ALLOWED_CUES)
unused_user = self.get_current_user(required=True)

user_models.UserPref.dismiss_cue(cue)
try:
request = DismissCueRequest.from_dict(self.request.json)
user_models.UserPref.dismiss_cue(request.cue)
return {'message': 'Done'}
except ValueError as e:
self.abort(400, str(e))
# Callers don't use the JSON response for this API call.
return {'message': 'Done'}


def do_get(self, **kwargs):
"""Return a list of the dismissed cue cards"""
Expand Down
4 changes: 4 additions & 0 deletions gen/js/chromestatus-openapi/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ src/models/ComponentsUser.ts
src/models/ComponentsUsersResponse.ts
src/models/CreateAccountRequest.ts
src/models/DeleteAccount200Response.ts
src/models/DismissCueRequest.ts
src/models/ErrorMessage.ts
src/models/ExternalReviewsResponse.ts
src/models/FeatureLatency.ts
src/models/FeatureLink.ts
src/models/GateLatency.ts
src/models/GetDismissedCues400Response.ts
src/models/GetIntentResponse.ts
src/models/LinkPreview.ts
src/models/LinkPreviewBase.ts
Expand All @@ -37,6 +40,7 @@ src/models/OwnersAndSubscribersOfComponent.ts
src/models/PostIntentRequest.ts
src/models/ReviewLatency.ts
src/models/SpecMentor.ts
src/models/SuccessMessage.ts
src/models/index.ts
src/runtime.ts
tsconfig.esm.json
Expand Down
104 changes: 104 additions & 0 deletions gen/js/chromestatus-openapi/src/apis/DefaultApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ import type {
ComponentsUsersResponse,
CreateAccountRequest,
DeleteAccount200Response,
DismissCueRequest,
ExternalReviewsResponse,
FeatureLatency,
GetDismissedCues400Response,
GetIntentResponse,
MessageResponse,
PostIntentRequest,
ReviewLatency,
SpecMentor,
SuccessMessage,
} from '../models/index';
import {
AccountResponseFromJSON,
Expand All @@ -39,10 +42,14 @@ import {
CreateAccountRequestToJSON,
DeleteAccount200ResponseFromJSON,
DeleteAccount200ResponseToJSON,
DismissCueRequestFromJSON,
DismissCueRequestToJSON,
ExternalReviewsResponseFromJSON,
ExternalReviewsResponseToJSON,
FeatureLatencyFromJSON,
FeatureLatencyToJSON,
GetDismissedCues400ResponseFromJSON,
GetDismissedCues400ResponseToJSON,
GetIntentResponseFromJSON,
GetIntentResponseToJSON,
MessageResponseFromJSON,
Expand All @@ -53,6 +60,8 @@ import {
ReviewLatencyToJSON,
SpecMentorFromJSON,
SpecMentorToJSON,
SuccessMessageFromJSON,
SuccessMessageToJSON,
} from '../models/index';

export interface AddUserToComponentRequest {
Expand All @@ -69,6 +78,10 @@ export interface DeleteAccountRequest {
accountId: number;
}

export interface DismissCueOperationRequest {
dismissCueRequest: DismissCueRequest;
}

export interface GetIntentBodyRequest {
featureId: number;
stageId: number;
Expand Down Expand Up @@ -155,6 +168,35 @@ export interface DefaultApiInterface {
*/
deleteAccount(requestParameters: DeleteAccountRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<DeleteAccount200Response>;

/**
*
* @summary Dismiss a cue card for the signed-in user
* @param {DismissCueRequest} dismissCueRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof DefaultApiInterface
*/
dismissCueRaw(requestParameters: DismissCueOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<SuccessMessage>>;

/**
* Dismiss a cue card for the signed-in user
*/
dismissCue(requestParameters: DismissCueOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SuccessMessage>;

/**
*
* @summary Get dismissed cues for the current user
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof DefaultApiInterface
*/
getDismissedCuesRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<string>>>;

/**
* Get dismissed cues for the current user
*/
getDismissedCues(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<string>>;

/**
*
* @summary Get the HTML body of an intent draft
Expand Down Expand Up @@ -396,6 +438,68 @@ export class DefaultApi extends runtime.BaseAPI implements DefaultApiInterface {
return await response.value();
}

/**
* Dismiss a cue card for the signed-in user
*/
async dismissCueRaw(requestParameters: DismissCueOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<SuccessMessage>> {
if (requestParameters['dismissCueRequest'] == null) {
throw new runtime.RequiredError(
'dismissCueRequest',
'Required parameter "dismissCueRequest" was null or undefined when calling dismissCue().'
);
}

const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

headerParameters['Content-Type'] = 'application/json';

const response = await this.request({
path: `/currentuser/cues`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: DismissCueRequestToJSON(requestParameters['dismissCueRequest']),
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => SuccessMessageFromJSON(jsonValue));
}

/**
* Dismiss a cue card for the signed-in user
*/
async dismissCue(requestParameters: DismissCueOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SuccessMessage> {
const response = await this.dismissCueRaw(requestParameters, initOverrides);
return await response.value();
}

/**
* Get dismissed cues for the current user
*/
async getDismissedCuesRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<string>>> {
const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

const response = await this.request({
path: `/currentuser/cues`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);

return new runtime.JSONApiResponse<any>(response);
}

/**
* Get dismissed cues for the current user
*/
async getDismissedCues(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<string>> {
const response = await this.getDismissedCuesRaw(initOverrides);
return await response.value();
}

/**
* Get the HTML body of an intent draft
*/
Expand Down
71 changes: 71 additions & 0 deletions gen/js/chromestatus-openapi/src/models/DismissCueRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* tslint:disable */
/* eslint-disable */
/**
* chomestatus API
* The API for chromestatus.com. chromestatus.com is the official tool used for tracking feature launches in Blink (the browser engine that powers Chrome and many other web browsers). This tool guides feature owners through our launch process and serves as a primary source for developer information that then ripples throughout the web developer ecosystem. More details at: https://github.com/GoogleChrome/chromium-dashboard
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

import { mapValues } from '../runtime';
/**
*
* @export
* @interface DismissCueRequest
*/
export interface DismissCueRequest {
/**
*
* @type {string}
* @memberof DismissCueRequest
*/
cue: DismissCueRequestCueEnum;
}


/**
* @export
*/
export const DismissCueRequestCueEnum = {
progress_checkmarks: 'progress-checkmarks'
} as const;
export type DismissCueRequestCueEnum = typeof DismissCueRequestCueEnum[keyof typeof DismissCueRequestCueEnum];


/**
* Check if a given object implements the DismissCueRequest interface.
*/
export function instanceOfDismissCueRequest(value: object): value is DismissCueRequest {
if (!('cue' in value) || value['cue'] === undefined) return false;
return true;
}

export function DismissCueRequestFromJSON(json: any): DismissCueRequest {
return DismissCueRequestFromJSONTyped(json, false);
}

export function DismissCueRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): DismissCueRequest {
if (json == null) {
return json;
}
return {

'cue': json['cue'],
};
}

export function DismissCueRequestToJSON(value?: DismissCueRequest | null): any {
if (value == null) {
return value;
}
return {

'cue': value['cue'],
};
}

60 changes: 60 additions & 0 deletions gen/js/chromestatus-openapi/src/models/ErrorMessage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* tslint:disable */
/* eslint-disable */
/**
* chomestatus API
* The API for chromestatus.com. chromestatus.com is the official tool used for tracking feature launches in Blink (the browser engine that powers Chrome and many other web browsers). This tool guides feature owners through our launch process and serves as a primary source for developer information that then ripples throughout the web developer ecosystem. More details at: https://github.com/GoogleChrome/chromium-dashboard
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

import { mapValues } from '../runtime';
/**
*
* @export
* @interface ErrorMessage
*/
export interface ErrorMessage {
/**
*
* @type {string}
* @memberof ErrorMessage
*/
error?: string;
}

/**
* Check if a given object implements the ErrorMessage interface.
*/
export function instanceOfErrorMessage(value: object): value is ErrorMessage {
return true;
}

export function ErrorMessageFromJSON(json: any): ErrorMessage {
return ErrorMessageFromJSONTyped(json, false);
}

export function ErrorMessageFromJSONTyped(json: any, ignoreDiscriminator: boolean): ErrorMessage {
if (json == null) {
return json;
}
return {

'error': json['error'] == null ? undefined : json['error'],
};
}

export function ErrorMessageToJSON(value?: ErrorMessage | null): any {
if (value == null) {
return value;
}
return {

'error': value['error'],
};
}

Loading

0 comments on commit 59a78a8

Please sign in to comment.