p13n: set up routing for Sea Pen Freeform
Set up new Sea Pen path for freeform and route to the path when selecting the Sea Pen freeform tile in Wallpaper subpage. Freeform page is currently showing both recent images and images elements. This will be split by adding tab selection in followed up CL. Bug: b/347323749 Test: browser_tests --gtest_filter="*SeaPen*" Change-Id: I665b1aefe8bdadf0ab828b6f9513cc15989982bb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5649112 Reviewed-by: Jason Thai <jasontt@chromium.org> Commit-Queue: Thuong Phan <thuongphan@chromium.org> Cr-Commit-Position: refs/heads/main@{#1321061}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
7f85eed525
commit
761eae0db8
ash/webui
common
resources
personalization_app
chrome/test/data/webui/chromeos
personalization_app
vc_background_ui
@@ -95,7 +95,7 @@
|
|||||||
</style>
|
</style>
|
||||||
<div id="topContainer">
|
<div id="topContainer">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
<template is="dom-if" if="[[shouldShowTextInputQuery_(relativePath_, queryParams_.seaPenTemplateId)]]" restamp>
|
<template is="dom-if" if="[[shouldShowSeaPenFreeform_(relativePath_)]]" restamp>
|
||||||
<sea-pen-input-query></sea-pen-input-query>
|
<sea-pen-input-query></sea-pen-input-query>
|
||||||
</template>
|
</template>
|
||||||
<template is="dom-if" if="[[shouldShowTemplateQuery_(relativePath_, queryParams_.seaPenTemplateId)]]" restamp>
|
<template is="dom-if" if="[[shouldShowTemplateQuery_(relativePath_, queryParams_.seaPenTemplateId)]]" restamp>
|
||||||
@@ -111,16 +111,22 @@
|
|||||||
<!-- Prevent left margin from collapsing on narrow window in RTL -->
|
<!-- Prevent left margin from collapsing on narrow window in RTL -->
|
||||||
<div class="leftspacerbottom"></div>
|
<div class="leftspacerbottom"></div>
|
||||||
<div id="bottomInnerContainer">
|
<div id="bottomInnerContainer">
|
||||||
<template is="dom-if" if="[[shouldShowSeaPenRoot_(relativePath_)]]" restamp>
|
<template is="dom-if" if="[[shouldShowSeaPenTemplates_(relativePath_)]]" restamp>
|
||||||
<sea-pen-templates></sea-pen-templates>
|
<sea-pen-templates></sea-pen-templates>
|
||||||
<sea-pen-recent-wallpapers
|
<sea-pen-recent-wallpapers
|
||||||
on-sea-pen-recent-image-delete="onRecentImageDelete_">
|
on-sea-pen-recent-image-delete="onRecentImageDelete_">
|
||||||
</sea-pen-recent-wallpapers>
|
</sea-pen-recent-wallpapers>
|
||||||
</template>
|
</template>
|
||||||
<template is="dom-if" if="[[shouldShowSeaPenImages_(relativePath_)]]" restamp>
|
<template is="dom-if" if="[[shouldShowSeaPenTemplateImages_(relativePath_)]]" restamp>
|
||||||
<sea-pen-images template-id="[[getTemplateIdFromQueryParams_(queryParams_.seaPenTemplateId)]]">
|
<sea-pen-images template-id="[[getTemplateIdFromQueryParams_(queryParams_.seaPenTemplateId)]]">
|
||||||
</sea-pen-images>
|
</sea-pen-images>
|
||||||
</template>
|
</template>
|
||||||
|
<template is="dom-if" if="[[shouldShowSeaPenFreeform_(relativePath_)]]" restamp>
|
||||||
|
<sea-pen-recent-wallpapers
|
||||||
|
on-sea-pen-recent-image-delete="onRecentFreeformImageDelete_">
|
||||||
|
</sea-pen-recent-wallpapers>
|
||||||
|
<sea-pen-images template-id="Query"></sea-pen-images>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<template is="dom-if" if="[[showSeaPenIntroductionDialog_]]" restamp>
|
<template is="dom-if" if="[[showSeaPenIntroductionDialog_]]" restamp>
|
||||||
<sea-pen-introduction-dialog
|
<sea-pen-introduction-dialog
|
||||||
|
@@ -28,8 +28,9 @@ import {getTemplateIdFromString} from './sea_pen_utils.js';
|
|||||||
import {maybeDoPageTransition} from './transition.js';
|
import {maybeDoPageTransition} from './transition.js';
|
||||||
|
|
||||||
export enum SeaPenPaths {
|
export enum SeaPenPaths {
|
||||||
ROOT = '',
|
TEMPLATES = '',
|
||||||
RESULTS = '/results',
|
RESULTS = '/results',
|
||||||
|
FREEFORM = '/freeform',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SeaPenQueryParams {
|
export interface SeaPenQueryParams {
|
||||||
@@ -103,6 +104,12 @@ export class SeaPenRouterElement extends WithSeaPenStore {
|
|||||||
// switching template; otherwise, states from the last query search will
|
// switching template; otherwise, states from the last query search will
|
||||||
// remain in sea-pen-images element.
|
// remain in sea-pen-images element.
|
||||||
cleanUpSwitchingTemplate(this.getStore());
|
cleanUpSwitchingTemplate(this.getStore());
|
||||||
|
// TODO(b/347323691): remove the QUERY case when Freeform is removed from
|
||||||
|
// template list.
|
||||||
|
if (templateId === QUERY) {
|
||||||
|
this.goToRoute(SeaPenPaths.FREEFORM);
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.goToRoute(
|
this.goToRoute(
|
||||||
SeaPenPaths.RESULTS, {seaPenTemplateId: templateId.toString()});
|
SeaPenPaths.RESULTS, {seaPenTemplateId: templateId.toString()});
|
||||||
}
|
}
|
||||||
@@ -152,36 +159,34 @@ export class SeaPenRouterElement extends WithSeaPenStore {
|
|||||||
if (!Object.values(SeaPenPaths).includes(relativePath as SeaPenPaths)) {
|
if (!Object.values(SeaPenPaths).includes(relativePath as SeaPenPaths)) {
|
||||||
// If arriving at an unknown path, go back to the root path.
|
// If arriving at an unknown path, go back to the root path.
|
||||||
console.warn('SeaPenRouter unknown path', relativePath);
|
console.warn('SeaPenRouter unknown path', relativePath);
|
||||||
this.goToRoute(SeaPenPaths.ROOT);
|
this.goToRoute(SeaPenPaths.TEMPLATES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private shouldShowTextInputQuery_(
|
|
||||||
relativePath: string|null, templateId: string|null): boolean {
|
|
||||||
return isSeaPenTextInputEnabled() && relativePath === SeaPenPaths.RESULTS &&
|
|
||||||
templateId === QUERY;
|
|
||||||
}
|
|
||||||
|
|
||||||
private shouldShowTemplateQuery_(
|
private shouldShowTemplateQuery_(
|
||||||
relativePath: string|null, templateId: string|null): boolean {
|
relativePath: string|null, templateId: string|null): boolean {
|
||||||
return relativePath === SeaPenPaths.RESULTS &&
|
return relativePath === SeaPenPaths.RESULTS &&
|
||||||
(!!templateId && templateId !== 'Query');
|
(!!templateId && templateId !== 'Query');
|
||||||
}
|
}
|
||||||
|
|
||||||
private shouldShowSeaPenRoot_(relativePath: string|null): boolean {
|
private shouldShowSeaPenTemplates_(relativePath: string|null): boolean {
|
||||||
if (typeof relativePath !== 'string') {
|
if (typeof relativePath !== 'string') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return relativePath === SeaPenPaths.ROOT;
|
return relativePath === SeaPenPaths.TEMPLATES;
|
||||||
}
|
}
|
||||||
|
|
||||||
private shouldShowSeaPenImages_(relativePath: string|null): boolean {
|
private shouldShowSeaPenTemplateImages_(relativePath: string|null): boolean {
|
||||||
if (typeof relativePath !== 'string') {
|
if (typeof relativePath !== 'string') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return relativePath === SeaPenPaths.RESULTS;
|
return relativePath === SeaPenPaths.RESULTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private shouldShowSeaPenFreeform_(relativePath: string|null): boolean {
|
||||||
|
return isSeaPenTextInputEnabled() && relativePath === SeaPenPaths.FREEFORM;
|
||||||
|
}
|
||||||
|
|
||||||
private onBottomContainerClicked_(): void {
|
private onBottomContainerClicked_(): void {
|
||||||
// close the chip option selection if it is open (or selected chip state is
|
// close the chip option selection if it is open (or selected chip state is
|
||||||
// set).
|
// set).
|
||||||
@@ -211,6 +216,10 @@ export class SeaPenRouterElement extends WithSeaPenStore {
|
|||||||
this.focusOnFirstTemplate_();
|
this.focusOnFirstTemplate_();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private onRecentFreeformImageDelete_() {
|
||||||
|
// TODO(b/347328001): add the function implementation.
|
||||||
|
}
|
||||||
|
|
||||||
private focusOnFirstTemplate_() {
|
private focusOnFirstTemplate_() {
|
||||||
const seaPenTemplates =
|
const seaPenTemplates =
|
||||||
this.shadowRoot!.querySelector<HTMLElement>('sea-pen-templates');
|
this.shadowRoot!.querySelector<HTMLElement>('sea-pen-templates');
|
||||||
|
@@ -23,8 +23,9 @@ const enum MetricsPath {
|
|||||||
USER = 7,
|
USER = 7,
|
||||||
WALLPAPER_SEA_PEN_COLLECTION = 8,
|
WALLPAPER_SEA_PEN_COLLECTION = 8,
|
||||||
WALLPAPER_SEA_PEN_RESULTS = 9,
|
WALLPAPER_SEA_PEN_RESULTS = 9,
|
||||||
|
WALLPAPER_SEA_PEN_FREEFORM = 10,
|
||||||
|
|
||||||
MAX_VALUE = WALLPAPER_SEA_PEN_RESULTS,
|
MAX_VALUE = WALLPAPER_SEA_PEN_FREEFORM,
|
||||||
}
|
}
|
||||||
|
|
||||||
const enum HistogramName {
|
const enum HistogramName {
|
||||||
@@ -66,6 +67,8 @@ function toMetricsEnum(path: Paths) {
|
|||||||
return MetricsPath.WALLPAPER_SEA_PEN_COLLECTION;
|
return MetricsPath.WALLPAPER_SEA_PEN_COLLECTION;
|
||||||
case Paths.SEA_PEN_RESULTS:
|
case Paths.SEA_PEN_RESULTS:
|
||||||
return MetricsPath.WALLPAPER_SEA_PEN_RESULTS;
|
return MetricsPath.WALLPAPER_SEA_PEN_RESULTS;
|
||||||
|
case Paths.SEA_PEN_FREEFORM:
|
||||||
|
return MetricsPath.WALLPAPER_SEA_PEN_FREEFORM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -80,7 +80,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<template is="dom-if" if="[[shouldShowSeaPen_(path_)]]" restamp>
|
<template is="dom-if" if="[[shouldShowSeaPen_(path_)]]" restamp>
|
||||||
<sea-pen-router base-path="[[seaPenBasePath_]]" class="always-show-top">
|
<sea-pen-router base-path="[[seaPenBasePath_]]" class="always-show-top">
|
||||||
<template is="dom-if" if="[[shouldShowWallpaperSelected_(queryParams_.seaPenTemplateId)]]" restamp>
|
<template is="dom-if" if="[[shouldShowWallpaperSelected_(path_)]]" restamp>
|
||||||
<wallpaper-selected id="wallpaperSelected"></wallpaper-selected>
|
<wallpaper-selected id="wallpaperSelected"></wallpaper-selected>
|
||||||
</template>
|
</template>
|
||||||
</sea-pen-router>
|
</sea-pen-router>
|
||||||
|
@@ -34,6 +34,7 @@ export enum Paths {
|
|||||||
ROOT = '/',
|
ROOT = '/',
|
||||||
SEA_PEN_COLLECTION = '/wallpaper/sea-pen',
|
SEA_PEN_COLLECTION = '/wallpaper/sea-pen',
|
||||||
SEA_PEN_RESULTS = '/wallpaper/sea-pen/results',
|
SEA_PEN_RESULTS = '/wallpaper/sea-pen/results',
|
||||||
|
SEA_PEN_FREEFORM = '/wallpaper/sea-pen/freeform',
|
||||||
USER = '/user',
|
USER = '/user',
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,8 +205,8 @@ export class PersonalizationRouterElement extends PolymerElement {
|
|||||||
return isSeaPenAllowed() && isSeaPenPath(path);
|
return isSeaPenAllowed() && isSeaPenPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private shouldShowWallpaperSelected_(templateId: string|null): boolean {
|
private shouldShowWallpaperSelected_(path: string|null): boolean {
|
||||||
return !templateId;
|
return path === Paths.SEA_PEN_COLLECTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
private shouldShowBreadcrumb_(path: string|null): boolean {
|
private shouldShowBreadcrumb_(path: string|null): boolean {
|
||||||
|
@@ -745,7 +745,8 @@ export class WallpaperCollectionsElement extends WithPersonalizationStore {
|
|||||||
Paths.SEA_PEN_COLLECTION);
|
Paths.SEA_PEN_COLLECTION);
|
||||||
return;
|
return;
|
||||||
case kSeaPenPromptingId:
|
case kSeaPenPromptingId:
|
||||||
// TODO(b/347323749): add the correct routing path.
|
PersonalizationRouterElement.instance().goToRoute(
|
||||||
|
Paths.SEA_PEN_FREEFORM);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
assert(
|
assert(
|
||||||
|
@@ -753,7 +753,7 @@ suite('sea pen', () => {
|
|||||||
.trim();
|
.trim();
|
||||||
|
|
||||||
// Goes back to sea pen root page.
|
// Goes back to sea pen root page.
|
||||||
seaPenRouter.goToRoute(SeaPenPaths.ROOT);
|
seaPenRouter.goToRoute(SeaPenPaths.TEMPLATES);
|
||||||
|
|
||||||
{
|
{
|
||||||
// Verifies the image is set properly.
|
// Verifies the image is set properly.
|
||||||
|
@@ -228,12 +228,13 @@ suite('PersonalizationRouterElementTest', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('hides wallpaper selected on non root path sea pen', async () => {
|
test('hides wallpaper selected on non root path sea pen', async () => {
|
||||||
loadTimeData.overrideValues({isSeaPenEnabled: true});
|
loadTimeData.overrideValues(
|
||||||
|
{isSeaPenEnabled: true, isSeaPenTextInputEnabled: true});
|
||||||
|
|
||||||
const routerElement = initElement(PersonalizationRouterElement);
|
const routerElement = initElement(PersonalizationRouterElement);
|
||||||
await waitAfterNextRender(routerElement);
|
await waitAfterNextRender(routerElement);
|
||||||
|
|
||||||
routerElement.goToRoute(Paths.SEA_PEN_COLLECTION, {
|
routerElement.goToRoute(Paths.SEA_PEN_RESULTS, {
|
||||||
seaPenTemplateId: SeaPenTemplateId.kFlower.toString(),
|
seaPenTemplateId: SeaPenTemplateId.kFlower.toString(),
|
||||||
});
|
});
|
||||||
await waitAfterNextRender(routerElement);
|
await waitAfterNextRender(routerElement);
|
||||||
@@ -245,10 +246,17 @@ suite('PersonalizationRouterElementTest', function() {
|
|||||||
getComputedStyle(seaPenRouterElement).display, 'none',
|
getComputedStyle(seaPenRouterElement).display, 'none',
|
||||||
'sea-pen-router is shown');
|
'sea-pen-router is shown');
|
||||||
|
|
||||||
const wallpaperSelected =
|
// No wallpaper-selected in Template results page.
|
||||||
routerElement.shadowRoot!.getElementById('wallpaperSelected');
|
|
||||||
assertFalse(
|
assertFalse(
|
||||||
!!wallpaperSelected, 'wallpaper-selected should not be displayed');
|
!!routerElement.shadowRoot!.getElementById('wallpaperSelected'),
|
||||||
|
'wallpaper-selected should not be displayed in template results page');
|
||||||
|
|
||||||
|
// No wallpaper-selected in Freeform subpage.
|
||||||
|
routerElement.goToRoute(Paths.SEA_PEN_FREEFORM);
|
||||||
|
await waitAfterNextRender(routerElement);
|
||||||
|
assertFalse(
|
||||||
|
!!routerElement.shadowRoot!.getElementById('wallpaperSelected'),
|
||||||
|
'wallpaper-selected should not be displayed in freeform page');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('supports transition animation', async () => {
|
test('supports transition animation', async () => {
|
||||||
|
@@ -49,7 +49,7 @@ suite('SeaPenRouterElementTest', function() {
|
|||||||
|
|
||||||
test('shows templates and recent elements', async () => {
|
test('shows templates and recent elements', async () => {
|
||||||
routerElement = initElement(SeaPenRouterElement, {basePath: '/base'});
|
routerElement = initElement(SeaPenRouterElement, {basePath: '/base'});
|
||||||
routerElement.goToRoute(SeaPenPaths.ROOT);
|
routerElement.goToRoute(SeaPenPaths.TEMPLATES);
|
||||||
await waitAfterNextRender(routerElement);
|
await waitAfterNextRender(routerElement);
|
||||||
|
|
||||||
assertTrue(
|
assertTrue(
|
||||||
@@ -78,14 +78,13 @@ suite('SeaPenRouterElementTest', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'shows input query element if text input enabled and free form template is selected',
|
'shows freeform page with input query, recent images and images elements',
|
||||||
async () => {
|
async () => {
|
||||||
loadTimeData.overrideValues({isSeaPenTextInputEnabled: true});
|
loadTimeData.overrideValues({isSeaPenTextInputEnabled: true});
|
||||||
routerElement = initElement(SeaPenRouterElement, {
|
routerElement = initElement(SeaPenRouterElement, {
|
||||||
basePath: '/base',
|
basePath: '/base',
|
||||||
});
|
});
|
||||||
routerElement.goToRoute(
|
routerElement.goToRoute(SeaPenPaths.FREEFORM);
|
||||||
SeaPenPaths.RESULTS, {seaPenTemplateId: 'Query'});
|
|
||||||
await waitAfterNextRender(routerElement);
|
await waitAfterNextRender(routerElement);
|
||||||
|
|
||||||
assertTrue(
|
assertTrue(
|
||||||
@@ -93,15 +92,14 @@ suite('SeaPenRouterElementTest', function() {
|
|||||||
SeaPenInputQueryElement.is),
|
SeaPenInputQueryElement.is),
|
||||||
'input query element shown on root');
|
'input query element shown on root');
|
||||||
|
|
||||||
const seaPenImagesElement =
|
|
||||||
routerElement.shadowRoot!.querySelector(SeaPenImagesElement.is);
|
|
||||||
assertTrue(
|
assertTrue(
|
||||||
!!seaPenImagesElement, 'sea-pen-images shown on result page');
|
!!routerElement.shadowRoot!.querySelector(
|
||||||
|
SeaPenRecentWallpapersElement.is),
|
||||||
|
'sea-pen-recent-wallpapers shown on freeform page');
|
||||||
|
|
||||||
assertTrue(
|
assertTrue(
|
||||||
!!seaPenImagesElement.shadowRoot!.querySelector(
|
!!routerElement.shadowRoot!.querySelector(SeaPenImagesElement.is),
|
||||||
SeaPenZeroStateSvgElement.is),
|
'sea-pen-images shown on freeform page');
|
||||||
'zero state svg is shown after selecting free form template from root');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
@@ -110,7 +108,7 @@ suite('SeaPenRouterElementTest', function() {
|
|||||||
routerElement = initElement(SeaPenRouterElement, {
|
routerElement = initElement(SeaPenRouterElement, {
|
||||||
basePath: '/base',
|
basePath: '/base',
|
||||||
});
|
});
|
||||||
routerElement.goToRoute(SeaPenPaths.ROOT);
|
routerElement.goToRoute(SeaPenPaths.TEMPLATES);
|
||||||
await waitAfterNextRender(routerElement);
|
await waitAfterNextRender(routerElement);
|
||||||
|
|
||||||
const seaPenTemplatesElement =
|
const seaPenTemplatesElement =
|
||||||
|
@@ -123,7 +123,7 @@ suite('VcBackgroundUITest', () => {
|
|||||||
|
|
||||||
test('verifies breadcrumbs when create button clicked', async () => {
|
test('verifies breadcrumbs when create button clicked', async () => {
|
||||||
const seaPenRouter = getSeaPenRouter();
|
const seaPenRouter = getSeaPenRouter();
|
||||||
seaPenRouter.goToRoute(SeaPenPaths.ROOT);
|
seaPenRouter.goToRoute(SeaPenPaths.TEMPLATES);
|
||||||
await waitAfterNextRender(seaPenRouter);
|
await waitAfterNextRender(seaPenRouter);
|
||||||
|
|
||||||
const seaPenTemplateElements = getSeaPenTemplateElements();
|
const seaPenTemplateElements = getSeaPenTemplateElements();
|
||||||
|
Reference in New Issue
Block a user