Skip to content

Commit cbcbd03

Browse files
aronhoyerkvashchuka
andcommitted
feat: add flag to render only job name
Co-authored-by: Anna Kvashchuk <kvashchuk.anna@gmail.com>
1 parent 0f82dd4 commit cbcbd03

File tree

5 files changed

+48
-6
lines changed

5 files changed

+48
-6
lines changed

frontend/__tests__/components/WorkflowDashboard.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,17 @@ describe('<WorkflowDashboard />', () => {
230230
expect(workflowDashboardWrapper.html()).toMatchSnapshot();
231231
});
232232

233+
it('should render only job name', async () => {
234+
vi.spyOn(preferences, 'showOnlyJobName', 'get').mockReturnValueOnce(true);
235+
236+
fetchCctrayJson.mockResolvedValueOnce([jobDetails1, jobDetails2]);
237+
const workflowDashboardWrapper = mountWithWrapper(WorkflowDashboard);
238+
239+
await flushPromises();
240+
241+
expect(workflowDashboardWrapper.findComponent(Job).find('a').text()).toBe('Cancel Previous Runs');
242+
});
243+
233244
it.each([
234245
['branch_protection_rule', [{ ...jobDetails1, triggeredEvent: 'branch_protection_rule' }, jobDetails2]],
235246
['check_run', [{ ...jobDetails1, triggeredEvent: 'check_run' }, jobDetails2]],

frontend/src/components/Preferences.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@
3939
@update:model-value="modelValueUpdated"
4040
/>
4141
</v-card-item>
42+
<v-card-item class="pt-0 pb-0">
43+
<v-switch
44+
v-model="showOnlyJobName"
45+
label="Show only job name"
46+
color="success"
47+
hide-details
48+
@update:model-value="modelValueUpdated"
49+
/>
50+
</v-card-item>
4251
<v-card-item class="pt-0 pb-0">
4352
<v-btn
4453
:icon="themeIcon"
@@ -99,7 +108,8 @@ export default {
99108
enableMaxIdleTimeOptimization: preferences.enableMaxIdleTimeOptimization,
100109
themeInstance,
101110
isDirty: false,
102-
showBuildsDueToTriggeredEvents: getShowBuildsDueToTriggeredEvents()
111+
showBuildsDueToTriggeredEvents: getShowBuildsDueToTriggeredEvents(),
112+
showOnlyJobName: preferences.showOnlyJobName
103113
};
104114
},
105115
computed: {
@@ -130,6 +140,7 @@ export default {
130140
preferences.maxIdleTime = this.maxIdleTime;
131141
preferences.theme = this.themeInstance.global.name;
132142
preferences.showBuildsDueToTriggeredEvents = this.showBuildsDueToTriggeredEvents;
143+
preferences.showOnlyJobName = this.showOnlyJobName;
133144
134145
this.isDirty = false;
135146
},
@@ -138,6 +149,7 @@ export default {
138149
this.showHealthyBuilds === preferences.showHealthyBuilds &&
139150
this.maxIdleTime === preferences.maxIdleTime &&
140151
this.enableMaxIdleTimeOptimization === preferences.enableMaxIdleTimeOptimization &&
152+
this.showOnlyJobName === preferences.showOnlyJobName &&
141153
this.hasSameShowBuildsDueToTriggeredEvents());
142154
},
143155
hasSameShowBuildsDueToTriggeredEvents() {

frontend/src/components/WorkflowDashboard.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,24 @@ export default {
5050
isIdleHealthyBuild(lastBuildStatus, activity) {
5151
return lastBuildStatus === 'Success' && activity === 'Sleeping';
5252
},
53+
mapNameIfPreferred(data) {
54+
const parts = data.name.split(' :: ');
55+
56+
return preferences.showOnlyJobName
57+
? {
58+
...data,
59+
name: parts[parts.length - 1]
60+
}
61+
: data;
62+
},
5363
marshalData(data) {
5464
return data
5565
.filter(({ lastBuildStatus, activity }) =>
5666
this.showHealthyBuilds ? true : !this.isIdleHealthyBuild(lastBuildStatus, activity))
5767
.filter(({ triggeredEvent }) =>
5868
!this.hasPreferredTriggeredEvents ||
59-
preferences.showBuildsDueToTriggeredEvents.indexOf(triggeredEvent) !== -1);
69+
preferences.showBuildsDueToTriggeredEvents.indexOf(triggeredEvent) !== -1)
70+
.map(this.mapNameIfPreferred);
6071
}
6172
}
6273
};

frontend/src/services/preferences.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ class Preferences {
7070
set showBuildsDueToTriggeredEvents(events) {
7171
this.__set__('show-builds-due-to-triggered-events', JSON.stringify(events));
7272
}
73+
74+
set showOnlyJobName(value) {
75+
this.__set__('show-only-job-name', JSON.stringify(value));
76+
}
77+
78+
get showOnlyJobName() {
79+
return JSON.parse(this.__get__('show-only-job-name'));
80+
}
7381
}
7482

7583
export default new Preferences();

frontend/vite.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ export default defineConfig({
4444
coverage: {
4545
reporter: ['text', 'html'],
4646
all: true,
47-
statements: 80.58,
48-
branches: 94.64,
49-
functions: 43.65,
50-
lines: 80.58,
47+
statements: 80.62,
48+
branches: 94.87,
49+
functions: 44.18,
50+
lines: 80.62,
5151
thresholdAutoUpdate: true
5252
},
5353
setupFiles: '__tests__/vitest.setup.js'

0 commit comments

Comments
 (0)