'custom-configuration-test-group-form' should update test name when selected test...
[WebKit.git] / Websites / perf.webkit.org / public / v3 / components / custom-configuration-test-group-form.js
1
2 class CustomConfigurationTestGroupForm extends TestGroupForm {
3
4     constructor()
5     {
6         super('custom-configuration-test-group-form');
7         this._hasTask = false;
8         this._updateTestGroupNameLazily = new LazilyEvaluatedFunction(this._updateTestGroupName.bind(this));
9     }
10
11     setHasTask(hasTask)
12     {
13         this._hasTask = hasTask;
14         this.enqueueToRender();
15     }
16
17     hasCommitSets()
18     {
19         return !!this.part('configurator').commitSets();
20     }
21
22     setConfigurations(test, platform, repetitionCount, commitSets)
23     {
24         const configurator = this.part('configurator');
25         configurator.selectTests([test]);
26         configurator.selectPlatform(platform);
27         if (commitSets.length == 2)
28             configurator.setCommitSets(commitSets[0], commitSets[1]);
29         this.setRepetitionCount(repetitionCount);
30         this.enqueueToRender();
31     }
32
33     startTesting()
34     {
35         const taskName = this.content('task-name').value;
36         const testGroupName = this.content('group-name').value;
37         const configurator = this.part('configurator');
38         const commitSets = configurator.commitSets();
39         const platform = configurator.platform();
40         const test = configurator.tests()[0]; // FIXME: Add the support for specifying multiple tests.
41         console.assert(!!this._hasTask === !taskName);
42         if (!this._hasTask)
43             this.dispatchAction('startTesting', this._repetitionCount, testGroupName, commitSets, platform, test, taskName, this._notifyOnCompletion);
44         else
45             this.dispatchAction('startTesting', this._repetitionCount, testGroupName, commitSets, platform, test, this._notifyOnCompletion);
46     }
47
48     didConstructShadowTree()
49     {
50         super.didConstructShadowTree();
51
52         this.part('configurator').listenToAction('testConfigChange', () => this.enqueueToRender());
53
54         this.content('task-name').oninput = () => this.enqueueToRender();
55         this.content('group-name').oninput = () => this.enqueueToRender();
56     }
57
58     render()
59     {
60         super.render();
61         const configurator = this.part('configurator');
62         this._updateTestGroupNameLazily.evaluate(configurator.tests(), configurator.platform());
63
64         const needsTaskName = !this._hasTask && !this.content('task-name').value;
65         this.content('iteration-start-pane').style.display = !!configurator.commitSets() ? null : 'none';
66         this.content('task-name').style.display = this._hasTask ? 'none' : null;
67         this.content('start-button').disabled = needsTaskName || !this.content('group-name').value;
68     }
69
70     _updateTestGroupName(tests, platform)
71     {
72         if (!platform || !tests.length)
73             return;
74         this.content('group-name').value = `${tests.map((test) => test.name()).join(', ')} on ${platform.name()}`;
75     }
76
77     static cssTemplate()
78     {
79         return super.cssTemplate() + `
80             input {
81                 width: 30%;
82                 min-width: 10rem;
83                 font-size: 1rem;
84                 font-weight: inherit;
85             }
86
87             #form > * {
88                 margin-bottom: 1rem;
89             }
90
91             #start-button {
92                 display: block;
93                 margin-top: 0.5rem;
94                 font-size: 1.2rem;
95                 font-weight: inherit;
96             }
97             `;
98     }
99
100     static htmlTemplate()
101     {
102         return `<form id="form">
103             <input id="task-name" type="text" placeholder="Name this task">
104             <custom-analysis-task-configurator id="configurator"></custom-analysis-task-configurator>
105             <div id="iteration-start-pane">
106                 <input id="group-name" type="text" placeholder="Test group name">
107                 ${super.formContent()}
108                 <button id="start-button">Start</button>
109             </div>
110         </form>`;
111     }
112 }
113
114 ComponentBase.defineElement('custom-configuration-test-group-form', CustomConfigurationTestGroupForm);