Skip to content

Commit 9092b11

Browse files
jackfranklinDevtools-frontend LUCI CQ
authored andcommitted
Insights: don't show "Ask AI" if disabled by enterprise
Fixed: 404735118 Change-Id: Ia61407364cfe77571bd6d498d0ad9a918829bbbc Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6414391 Reviewed-by: Alina Varkki <[email protected]> Commit-Queue: Alina Varkki <[email protected]> Auto-Submit: Jack Franklin <[email protected]>
1 parent 661f41c commit 9092b11

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

front_end/panels/timeline/components/insights/BaseInsightComponent.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// found in the LICENSE file.
44

55
import type * as Common from '../../../../core/common/common.js';
6+
import * as Root from '../../../../core/root/root.js';
67
import * as Trace from '../../../../models/trace/trace.js';
78
import {dispatchClickEvent, renderElementIntoDOM} from '../../../../testing/DOMHelpers.js';
89
import {describeWithEnvironment, updateHostConfig} from '../../../../testing/EnvironmentHelpers.js';
@@ -137,6 +138,22 @@ describeWithEnvironment('BaseInsightComponent', () => {
137138
assert.isOk(button);
138139
});
139140

141+
it('does not render the "Ask AI" button if disabled by enterprise policy', async () => {
142+
updateHostConfig({
143+
devToolsAiAssistancePerformanceAgent: {
144+
enabled: true,
145+
insightsEnabled: true,
146+
},
147+
aidaAvailability: {
148+
enterprisePolicyValue: Root.Runtime.GenAiEnterprisePolicyValue.DISABLE,
149+
}
150+
});
151+
const component = await renderComponent({insightHasAISupport: true});
152+
assert.isOk(component.shadowRoot);
153+
const button = component.shadowRoot.querySelector('devtools-button[data-insights-ask-ai]');
154+
assert.isNull(button);
155+
});
156+
140157
it('does not show the button if the feature is enabled but the Insight does not support it', async () => {
141158
updateHostConfig({
142159
devToolsAiAssistancePerformanceAgent: {

front_end/panels/timeline/components/insights/BaseInsightComponent.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,10 @@ export abstract class BaseInsightComponent<T extends InsightModel> extends HTMLE
323323
}
324324

325325
#canShowAskAI(): boolean {
326-
return this.#insightsAskAiEnabled && this.hasAskAISupport;
326+
const aiDisabledByEnterprisePolicy = Root.Runtime.hostConfig.aidaAvailability?.enterprisePolicyValue ===
327+
Root.Runtime.GenAiEnterprisePolicyValue.DISABLE;
328+
329+
return !aiDisabledByEnterprisePolicy && this.#insightsAskAiEnabled && this.hasAskAISupport;
327330
}
328331

329332
#renderInsightContent(insightModel: T): Lit.LitTemplate {

0 commit comments

Comments
 (0)