Skip to content

Commit

Permalink
Add enterprise product category field to features
Browse files Browse the repository at this point in the history
  • Loading branch information
yanndago committed Dec 18, 2024
1 parent 2eea2bd commit dda0f9e
Show file tree
Hide file tree
Showing 18 changed files with 87 additions and 23 deletions.
1 change: 1 addition & 0 deletions api/api_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
('doc_links', 'links'),
('editor_emails', 'emails'),
('enterprise_feature_categories', 'split_str'),
('enterprise_product_category', 'int'),
('ergonomics_risks', 'str'),
('explainer_links', 'links'),
('feature_notes', 'str'),
Expand Down
3 changes: 3 additions & 0 deletions api/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ def feature_entry_to_json_verbose(
'category_int': fe.category,
'feature_notes': fe.feature_notes,
'enterprise_feature_categories': fe.enterprise_feature_categories or [],
'enterprise_product_category': fe.enterprise_product_category or ENTERPRISE_PRODUCT_CATEGORY_CHROME_BROWSER_UPDATE,
'stages': stage_info['all_stages'],
'accurate_as_of': _date_to_str(fe.accurate_as_of),
'creator_email': fe.creator_email,
Expand Down Expand Up @@ -491,6 +492,7 @@ def feature_entry_to_json_verbose(
},
},
'enterprise_feature_categories': fe.enterprise_feature_categories or [],
'enterprise_product_category': fe.enterprise_product_category or ENTERPRISE_PRODUCT_CATEGORY_CHROME_BROWSER_UPDATE,
'standards': {
'spec': fe.spec_link,
'maturity': {
Expand Down Expand Up @@ -532,6 +534,7 @@ def feature_entry_to_json_basic(fe: FeatureEntry,
'summary': fe.summary,
'unlisted': fe.unlisted,
'enterprise_impact': fe.enterprise_impact,
'enterprise_product_category': fe.enterprise_product_category or ENTERPRISE_PRODUCT_CATEGORY_CHROME_BROWSER_UPDATE,
'breaking_change': fe.breaking_change,
'first_enterprise_notification_milestone': fe.first_enterprise_notification_milestone,
'blink_components': fe.blink_components or [],
Expand Down
3 changes: 3 additions & 0 deletions api/converters_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def test_feature_entry_to_json_basic__normal(self):
'blink_components': ['Blink'],
'first_enterprise_notification_milestone': 100,
'enterprise_impact': ENTERPRISE_IMPACT_NONE,
'enterprise_product_category': 0,
'breaking_change': False,
'is_released': True,
'milestone': None,
Expand Down Expand Up @@ -192,6 +193,7 @@ def test_feature_entry_to_json_basic__feature_release(self):
'blink_components': ['Blink'],
'first_enterprise_notification_milestone': 100,
'enterprise_impact': ENTERPRISE_IMPACT_NONE,
'enterprise_product_category': 0,
'breaking_change': False,
'is_released': True,
'milestone': True,
Expand Down Expand Up @@ -295,6 +297,7 @@ def test_feature_entry_to_json_verbose__normal(self):
'unlisted': False,
'api_spec': False,
'enterprise_impact': ENTERPRISE_IMPACT_NONE,
'enterprise_product_category': 0,
'shipping_year': 2024,
'breaking_change': False,
'is_released': True,
Expand Down
1 change: 1 addition & 0 deletions api/legacy_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def feature_to_legacy_json(f: Feature) -> dict[str, Any]:
d['id'] = None
d['category'] = FEATURE_CATEGORIES[f.category]
d['enterprise_feature_categories'] = f.enterprise_feature_categories
d['enterprise_product_category'] = f.enterprise_product_category
d['category_int'] = f.category
if f.feature_type is not None:
d['feature_type'] = FEATURE_TYPES[f.feature_type]
Expand Down
10 changes: 10 additions & 0 deletions client-src/css/forms-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,14 @@ export const FORM_STYLES = [
width: 30%;
height: 1.5em;
}
.choices label {
font-weight: bold;
}
.choices div {
margin-top: 1em;
}
.choices p {
margin: 0.5em 1.5em 1em;
}
`];
2 changes: 1 addition & 1 deletion client-src/elements/chromedash-form-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ export class ChromedashFormField extends LitElement {
id="id_${this.name}_${value}"
name="${fieldName}"
value="${value}"
.checked="${value === fieldValue}"
.checked="${value === Number(fieldValue)}"
type="radio"
required
@change=${this.handleFieldUpdated}
Expand Down
1 change: 1 addition & 0 deletions client-src/elements/chromedash-guide-metadata-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export class ChromedashGuideMetadataPage extends LitElement {
.feature=${formattedFeature}
?forEnterprise=${formattedFeature.is_enterprise_feature}
@form-field-update="${this.handleFormFieldUpdate}"
class="${field === 'enterprise_product_category' ? 'choices' : ''}"
>
</chromedash-form-field>
`;
Expand Down
18 changes: 6 additions & 12 deletions client-src/elements/chromedash-guide-new-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,6 @@ export class ChromedashGuideNewPage extends LitElement {
box-shadow: 0 0 0 var(--sl-focus-ring-width)
var(--sl-input-focus-ring-color);
}
.choices label {
font-weight: bold;
}
.choices div {
margin-top: 1em;
}
.choices p {
margin: 0.5em 1.5em 1em;
}
.process-notice {
margin: var(--content-padding-half) 0;
padding: var(--content-padding-half);
Expand Down Expand Up @@ -211,7 +200,12 @@ export class ChromedashGuideNewPage extends LitElement {
${!this.isEnterpriseFeature
? renderFormField('feature_type_radio_group', 'choices')
: nothing}
${formFields.map(field => renderFormField(field))}
${formFields.map(field =>
renderFormField(
field,
field === 'enterprise_product_category' ? 'choices' : null
)
)}
</chromedash-form-table>
<input
type="submit"
Expand Down
10 changes: 0 additions & 10 deletions client-src/elements/chromedash-ot-creation-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,6 @@ export class ChromedashOTCreationPage extends LitElement {
...SHARED_STYLES,
...FORM_STYLES,
css`
.choices label {
font-weight: bold;
}
.choices div {
margin-top: 1em;
}
.choices p {
margin: 0.5em 1.5em 1em;
}
#overlay {
position: fixed;
width: 100%;
Expand Down
5 changes: 5 additions & 0 deletions client-src/elements/form-definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as enums from './form-field-enums';
export interface FormattedFeature {
category: number;
enterprise_feature_categories: string[];
enterprise_product_category: number;
feature_type: number;
intent_stage: number;
accurate_as_of: boolean;
Expand Down Expand Up @@ -81,6 +82,7 @@ export function formatFeatureForEdit(feature: Feature): FormattedFeature {
enterprise_feature_categories: Array.from(
new Set(feature.enterprise_feature_categories || [])
).map(x => parseInt(x).toString()),
enterprise_product_category: feature.enterprise_product_category,
feature_type: feature.feature_type_int,
intent_stage: feature.intent_stage_int,

Expand Down Expand Up @@ -177,6 +179,7 @@ export const ENTERPRISE_NEW_FEATURE_FORM_FIELDS = [
'owner',
'editors',
'enterprise_feature_categories',
'enterprise_product_category',
'first_enterprise_notification_milestone',
'enterprise_impact',
];
Expand All @@ -192,6 +195,7 @@ export const FLAT_METADATA_FIELDS: MetadataFields = {
'name',
'summary',
'unlisted',
'enterprise_product_category',
'enterprise_impact',
'shipping_year',
'owner',
Expand Down Expand Up @@ -232,6 +236,7 @@ export const FLAT_ENTERPRISE_METADATA_FIELDS: MetadataFields = {
'owner',
'editors',
'enterprise_feature_categories',
'enterprise_product_category',
'enterprise_impact',
'first_enterprise_notification_milestone',
'screenshot_links',
Expand Down
27 changes: 27 additions & 0 deletions client-src/elements/form-field-enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,33 @@ export const FEATURE_TYPES: Record<
],
};

export const ENTERPRISE_PRODUCT_CATEGORY: Record<
string,
[number, string, string | HTMLTemplateResult]
> = {
ENTERPRISE_PRODUCT_CATEGORY_CHROME_BROWSER_UPDATE: [
0,
'Chrome Browser update',
'New features, performance improvements, security fixes and minor updates addressing security vulnerabilities and bugs. These features apply to both consumers and enterprises.',
],
ENTERPRISE_PRODUCT_CATEGORY_CHROME_ENTERPRISE_CORE: [
1,
'Chrome Enterprise Core (CEC)',
'These features allow IT administrators to manage Chrome browser settings, policies, apps and extensions across an organization from a central location (Admin Console).',
],
ENTERPRISE_PRODUCT_CATEGORY_CHROME_ENTERPRISE_PREMIUM: [
2,
'Chrome Enterprise Premium (CEP, paid SKU)',
'These features add advanced security and enhanced controls for organizations with more demanding needs e.g. data masking functionality.',
],
};

export const ENTERPRISE_PRODUCT_CATEGORY_DISPLAYNAME: Record<number, string> = {
0: 'Chrome Browser update', // ENTERPRISE_PRODUCT_CATEGORY_CHROME_BROWSER_UPDATE
1: 'Chrome Enterprise Core (CEC)', // ENTERPRISE_PRODUCT_CATEGORY_CHROME_ENTERPRISE_CORE
2: 'Chrome Enterprise Premium (CEP, paid SKU)', // ENTERPRISE_PRODUCT_CATEGORY_CHROME_ENTERPRISE_PREMIUM
};

// ***********************************************************************
// Stage type values for each process. Even though some of the stages
// in these processes are similar to each other, they have distinct enum
Expand Down
10 changes: 10 additions & 0 deletions client-src/elements/form-field-specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
DT_MILESTONE_FIELDS,
ENTERPRISE_FEATURE_CATEGORIES,
ENTERPRISE_IMPACT,
ENTERPRISE_PRODUCT_CATEGORY,
FEATURE_CATEGORIES,
FEATURE_TYPES,
FEATURE_TYPES_WITHOUT_ENTERPRISE,
Expand Down Expand Up @@ -491,6 +492,15 @@ export const ALL_FIELDS: Record<string, Field> = {
"Miscellaneous".`,
},

enterprise_product_category: {
type: 'radios',
name: 'enterprise_product_category',
choices: ENTERPRISE_PRODUCT_CATEGORY,
label: 'Enterprise product category',
help_text: html` Select the product that this feature affect.`,
check: (_value, getFieldValue) => checkFeatureNameAndType(getFieldValue),
},

feature_type: {
type: 'select',
disabled: true,
Expand Down
7 changes: 7 additions & 0 deletions client-src/elements/queriable-fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import {type HTMLTemplateResult} from 'lit';
import {
ENTERPRISE_PRODUCT_CATEGORY,
FEATURE_CATEGORIES,
FEATURE_TYPES,
IMPLEMENTATION_STATUS,
Expand Down Expand Up @@ -193,6 +194,12 @@ export const QUERIABLE_FIELDS: QueryField[] = [
doc: 'Feature category',
choices: FEATURE_CATEGORIES,
},
{
name: 'enterprise_product_category',
kind: ENUM_KIND,
doc: 'Enterprise product category',
choices: ENTERPRISE_PRODUCT_CATEGORY,
},
{
name: 'feature_type',
kind: ENUM_KIND,
Expand Down
4 changes: 4 additions & 0 deletions client-src/elements/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {FORMS_BY_STAGE_TYPE, FormattedFeature} from './form-definition.js';
import {
ENTERPRISE_FEATURE_CATEGORIES_DISPLAYNAME,
ENTERPRISE_IMPACT_DISPLAYNAME,
ENTERPRISE_PRODUCT_CATEGORY_DISPLAYNAME,
OT_MILESTONE_END_FIELDS,
OT_SETUP_STATUS_OPTIONS,
PLATFORMS_DISPLAYNAME,
Expand Down Expand Up @@ -278,6 +279,9 @@ export function getFieldValueFromFeature(
value = feature[fieldName];
}

if (fieldName === 'enterprise_product_category' && value !== undefined) {
return ENTERPRISE_PRODUCT_CATEGORY_DISPLAYNAME[value];
}
if (fieldName === 'enterprise_feature_categories' && value) {
return value.map(
categoryId => ENTERPRISE_FEATURE_CATEGORIES_DISPLAYNAME[categoryId]
Expand Down
1 change: 1 addition & 0 deletions client-src/js-src/cs-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@
* @property {string[]} search_tags
* @property {string} [feature_notes]
* @property {string[]} enterprise_feature_categories
* @property {number} enterprise_product_category
* Metadata: Process information
* @property {string} feature_type
* @property {number} feature_type_int
Expand Down
5 changes: 5 additions & 0 deletions internals/core_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@
IWA: 'Isolated Web Apps-specific API',
}


ENTERPRISE_PRODUCT_CATEGORY_CHROME_BROWSER_UPDATE = 0
ENTERPRISE_PRODUCT_CATEGORY_CHROME_ENTERPRISE_CORE = 1
ENTERPRISE_PRODUCT_CATEGORY_CHROME_ENTERPRISE_PREMIUM = 2

FEATURE_TYPE_INCUBATE_ID = 0
FEATURE_TYPE_EXISTING_ID = 1
FEATURE_TYPE_CODE_CHANGE_ID = 2
Expand Down
1 change: 1 addition & 0 deletions internals/core_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class FeatureEntry(ndb.Model): # Copy from Feature
name = ndb.StringProperty(required=True)
summary = ndb.TextProperty(required=True)
category = ndb.IntegerProperty(required=True)
enterprise_product_category = ndb.IntegerProperty(required=True, default=ENTERPRISE_PRODUCT_CATEGORY_CHROME_BROWSER_UPDATE)
enterprise_feature_categories = ndb.StringProperty(repeated=True)
blink_components = ndb.StringProperty(repeated=True)
star_count = ndb.IntegerProperty(default=0)
Expand Down
1 change: 1 addition & 0 deletions internals/data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ class VerboseFeatureDict(TypedDict):
search_tags: list[str]
feature_notes: str | None
enterprise_feature_categories: list[str]
enterprise_product_category: int

# Metadata: Process information
feature_type: str
Expand Down

0 comments on commit dda0f9e

Please sign in to comment.