Skip to content

Commit d6958c5

Browse files
committed
Fix lint
1 parent e1d2cf4 commit d6958c5

File tree

2 files changed

+77
-83
lines changed

2 files changed

+77
-83
lines changed

routers/web/web.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ func registerWebRoutes(m *web.Router) {
10491049
m.Post("/{workflow_id}/status", projects.WorkflowsStatus)
10501050
m.Post("/{workflow_id}/delete", projects.WorkflowsDelete)
10511051
}, reqUnitAccess(unit.TypeProjects, perm.AccessModeWrite, true))
1052-
m.Group("", func() { //nolint:dupl // duplicates lines 1421-1441
1052+
m.Group("", func() {
10531053
m.Get("/new", org.RenderNewProject)
10541054
m.Post("/new", web.Bind(forms.CreateProjectForm{}), org.NewProjectPost)
10551055
m.Group("/{id}", func() {
@@ -1437,7 +1437,7 @@ func registerWebRoutes(m *web.Router) {
14371437
m.Group("/{username}/{reponame}/projects", func() {
14381438
m.Get("", repo.Projects)
14391439
m.Get("/{id}", repo.ViewProject)
1440-
m.Group("", func() { //nolint:dupl // duplicates lines 1034-1054
1440+
m.Group("", func() {
14411441
m.Get("/new", repo.RenderNewProject)
14421442
m.Post("/new", web.Bind(forms.CreateProjectForm{}), repo.NewProjectPost)
14431443
m.Group("/{id}", func() {

web_src/js/components/projects/ProjectWorkflow.vue

Lines changed: 75 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ const showCancelButton = computed(() => {
8383
return typeof eventId === 'string' && eventId.startsWith('clone-');
8484
});
8585
86-
const isTemporaryWorkflow = (workflow) => {
86+
const isTemporaryWorkflow = (workflow: any) => {
8787
if (!workflow) return false;
8888
if (workflow.id > 0) return false;
8989
const eventId = typeof workflow.event_id === 'string' ? workflow.event_id : '';
9090
return eventId.startsWith('clone-') || eventId.startsWith('new-');
9191
};
9292
93-
const removeTemporaryWorkflow = (workflow) => {
93+
const removeTemporaryWorkflow = (workflow: any) => {
9494
if (!isTemporaryWorkflow(workflow)) return;
9595
9696
const eventId = workflow.event_id;
@@ -221,7 +221,7 @@ const deleteWorkflow = async () => {
221221
setEditMode(false);
222222
};
223223
224-
const cloneWorkflow = (sourceWorkflow) => {
224+
const cloneWorkflow = (sourceWorkflow: any) => {
225225
if (!sourceWorkflow) return;
226226
227227
// Generate a unique temporary ID for the cloned workflow
@@ -274,7 +274,7 @@ const cloneWorkflow = (sourceWorkflow) => {
274274
window.history.pushState({eventId: tempId}, '', newUrl);
275275
};
276276
277-
const selectWorkflowEvent = async (event) => {
277+
const selectWorkflowEvent = async (event: any) => {
278278
// Prevent rapid successive clicks
279279
if (store.loading) return;
280280
@@ -314,32 +314,11 @@ const saveWorkflow = async () => {
314314
setEditMode(false);
315315
};
316316
317-
const isWorkflowConfigured = (event) => {
317+
const isWorkflowConfigured = (event: any) => {
318318
// Check if the event_id is a number (saved workflow ID) or if it has id > 0
319319
return !Number.isNaN(parseInt(event.event_id)) || (event.id !== undefined && event.id > 0);
320320
};
321321
322-
// Generate filter description for display name
323-
const getFilterDescription = (workflow) => {
324-
if (!workflow.filters || !Array.isArray(workflow.filters) || workflow.filters.length === 0) {
325-
return '';
326-
}
327-
328-
const descriptions = [];
329-
for (const filter of workflow.filters) {
330-
if (filter.type === 'issue_type' && filter.value) {
331-
if (filter.value === 'issue') {
332-
descriptions.push('Issues');
333-
} else if (filter.value === 'pull_request') {
334-
descriptions.push('Pull Requests');
335-
}
336-
}
337-
// Add more filter types here as needed
338-
}
339-
340-
return descriptions.length > 0 ? ` (${descriptions.join(', ')})` : '';
341-
};
342-
343322
// Get flat list of all workflows - use cached data to prevent frequent recomputation
344323
const workflowList = computed(() => {
345324
// Use a stable reference to prevent unnecessary DOM updates
@@ -355,7 +334,7 @@ const workflowList = computed(() => {
355334
}));
356335
});
357336
358-
const createNewWorkflow = (eventType, capabilities, displayName) => {
337+
const createNewWorkflow = (eventType: any, capabilities: any, displayName: any) => {
359338
// Store current selection before creating new workflow
360339
if (!isInEditMode.value) {
361340
previousSelection.value = {
@@ -370,8 +349,8 @@ const createNewWorkflow = (eventType, capabilities, displayName) => {
370349
event_id: tempId,
371350
display_name: displayName,
372351
capabilities,
373-
filters: [],
374-
actions: [],
352+
filters: [] as any[],
353+
actions: [] as any[],
375354
filter_summary: '',
376355
workflow_event: eventType,
377356
enabled: true, // Ensure new workflows are enabled by default
@@ -385,9 +364,9 @@ const createNewWorkflow = (eventType, capabilities, displayName) => {
385364
};
386365
387366
// Add debounce mechanism
388-
let selectTimeout = null;
367+
let selectTimeout: ReturnType<typeof setTimeout> | null = null;
389368
390-
const selectWorkflowItem = async (item) => {
369+
const selectWorkflowItem = async (item: any) => {
391370
// Prevent rapid successive clicks with debounce
392371
if (store.loading || selectTimeout) return;
393372
@@ -428,15 +407,15 @@ const hasAvailableFilters = computed(() => {
428407
return store.selectedWorkflow?.capabilities?.available_filters?.length > 0;
429408
});
430409
431-
const hasFilter = (filterType) => {
410+
const hasFilter = (filterType: any) => {
432411
return store.selectedWorkflow?.capabilities?.available_filters?.includes(filterType);
433412
};
434413
435-
const hasAction = (actionType) => {
414+
const hasAction = (actionType: any) => {
436415
return store.selectedWorkflow?.capabilities?.available_actions?.includes(actionType);
437416
};
438417
439-
const getStatusClass = (item) => {
418+
const getStatusClass = (item: any) => {
440419
if (!item.isConfigured) {
441420
return 'status-inactive'; // Gray dot for unconfigured
442421
}
@@ -449,7 +428,7 @@ const getStatusClass = (item) => {
449428
return 'status-active'; // Green dot for enabled
450429
};
451430
452-
const isItemSelected = (item) => {
431+
const isItemSelected = (item: any) => {
453432
if (!store.selectedItem) return false;
454433
455434
if (item.isConfigured || item.id === 0) {
@@ -461,7 +440,7 @@ const isItemSelected = (item) => {
461440
};
462441
463442
// Get display name for workflow with numbering for same types
464-
const getWorkflowDisplayName = (item, index) => {
443+
const getWorkflowDisplayName = (item: any, _index: any) => {
465444
const list = workflowList.value;
466445
467446
// Find all workflows of the same type
@@ -486,12 +465,12 @@ const getWorkflowDisplayName = (item, index) => {
486465
};
487466
488467
// Toggle label selection for add_labels, remove_labels, or filter_labels
489-
const toggleLabel = (type, labelId) => {
468+
const toggleLabel = (type: string, labelId: any) => {
490469
let labels;
491470
if (type === 'filter_labels') {
492471
labels = store.workflowFilters.labels;
493472
} else {
494-
labels = store.workflowActions[type];
473+
labels = (store.workflowActions as any)[type];
495474
}
496475
const index = labels.indexOf(labelId);
497476
if (index > -1) {
@@ -502,7 +481,7 @@ const toggleLabel = (type, labelId) => {
502481
};
503482
504483
// Calculate text color based on background color for better contrast
505-
const getLabelTextColor = (hexColor) => {
484+
const getLabelTextColor = (hexColor: any) => {
506485
if (!hexColor) return '#000';
507486
// Remove # if present
508487
const color = hexColor.replace('#', '');
@@ -566,7 +545,7 @@ onMounted(async () => {
566545
await nextTick();
567546
const workflowItemsContainer = elRoot.value.querySelector('.workflow-items');
568547
if (workflowItemsContainer) {
569-
workflowClickHandler = (e) => {
548+
workflowClickHandler = (e: any) => {
570549
const workflowItem = e.target.closest('.workflow-item');
571550
if (workflowItem) {
572551
e.preventDefault();
@@ -638,7 +617,7 @@ onMounted(async () => {
638617
});
639618
640619
// Define popstateHandler at component level
641-
const popstateHandler = (e) => {
620+
const popstateHandler = (e: any) => {
642621
if (e.state?.eventId) {
643622
// Handle browser back/forward navigation
644623
const event = store.workflowEvents.find((ev) => ev.event_id === e.state.eventId);
@@ -658,7 +637,7 @@ const popstateHandler = (e) => {
658637
};
659638
660639
// Store reference to cleanup event listener
661-
let workflowClickHandler = null;
640+
let workflowClickHandler: ((e: any) => void) | null = null;
662641
663642
onUnmounted(() => {
664643
// Clean up resources
@@ -697,10 +676,8 @@ onUnmounted(() => {
697676
<div class="workflow-content">
698677
<div class="workflow-info">
699678
<span class="status-indicator">
700-
<span
701-
v-html="svg('octicon-dot-fill')"
702-
:class="getStatusClass(item)"
703-
/>
679+
<!-- eslint-disable-next-line vue/no-v-html -->
680+
<span v-html="svg('octicon-dot-fill')" :class="getStatusClass(item)"/>
704681
</span>
705682
<div class="workflow-details">
706683
<div class="workflow-title">
@@ -886,22 +863,26 @@ onUnmounted(() => {
886863
<label>{{ locale.onlyIfHasLabels }}</label>
887864
<div v-if="isInEditMode" class="ui fluid multiple search selection dropdown label-dropdown">
888865
<input type="hidden" :value="store.workflowFilters.labels.join(',')">
889-
<i class="dropdown icon"></i>
866+
<i class="dropdown icon"/>
890867
<div class="text" :class="{ default: !store.workflowFilters.labels?.length }">
891868
<span v-if="!store.workflowFilters.labels?.length">{{ locale.anyLabel }}</span>
892869
<template v-else>
893-
<span v-for="labelId in store.workflowFilters.labels" :key="labelId"
894-
class="ui label"
895-
:style="`background-color: ${store.projectLabels.find(l => String(l.id) === labelId)?.color}; color: ${getLabelTextColor(store.projectLabels.find(l => String(l.id) === labelId)?.color)}`">
870+
<span
871+
v-for="labelId in store.workflowFilters.labels" :key="labelId"
872+
class="ui label"
873+
:style="`background-color: ${store.projectLabels.find(l => String(l.id) === labelId)?.color}; color: ${getLabelTextColor(store.projectLabels.find(l => String(l.id) === labelId)?.color)}`"
874+
>
896875
{{ store.projectLabels.find(l => String(l.id) === labelId)?.name }}
897876
</span>
898877
</template>
899878
</div>
900879
<div class="menu">
901-
<div class="item" v-for="label in store.projectLabels" :key="label.id"
902-
:data-value="String(label.id)"
903-
@click.prevent="toggleLabel('filter_labels', String(label.id))"
904-
:class="{ active: store.workflowFilters.labels.includes(String(label.id)), selected: store.workflowFilters.labels.includes(String(label.id)) }">
880+
<div
881+
class="item" v-for="label in store.projectLabels" :key="label.id"
882+
:data-value="String(label.id)"
883+
@click.prevent="toggleLabel('filter_labels', String(label.id))"
884+
:class="{ active: store.workflowFilters.labels.includes(String(label.id)), selected: store.workflowFilters.labels.includes(String(label.id)) }"
885+
>
905886
<span class="ui label" :style="`background-color: ${label.color}; color: ${getLabelTextColor(label.color)}`">
906887
{{ label.name }}
907888
</span>
@@ -910,9 +891,11 @@ onUnmounted(() => {
910891
</div>
911892
<div v-else class="ui labels">
912893
<span v-if="!store.workflowFilters.labels?.length" class="text-muted">Any labels</span>
913-
<span v-for="labelId in store.workflowFilters.labels" :key="labelId"
914-
class="ui label"
915-
:style="`background-color: ${store.projectLabels.find(l => String(l.id) === labelId)?.color}; color: ${getLabelTextColor(store.projectLabels.find(l => String(l.id) === labelId)?.color)}`">
894+
<span
895+
v-for="labelId in store.workflowFilters.labels" :key="labelId"
896+
class="ui label"
897+
:style="`background-color: ${store.projectLabels.find(l => String(l.id) === labelId)?.color}; color: ${getLabelTextColor(store.projectLabels.find(l => String(l.id) === labelId)?.color)}`"
898+
>
916899
{{ store.projectLabels.find(l => String(l.id) === labelId)?.name }}
917900
</span>
918901
</div>
@@ -945,22 +928,26 @@ onUnmounted(() => {
945928
<label>{{ locale.addLabels }}</label>
946929
<div v-if="isInEditMode" class="ui fluid multiple search selection dropdown label-dropdown">
947930
<input type="hidden" :value="store.workflowActions.add_labels.join(',')">
948-
<i class="dropdown icon"></i>
931+
<i class="dropdown icon"/>
949932
<div class="text" :class="{ default: !store.workflowActions.add_labels?.length }">
950933
<span v-if="!store.workflowActions.add_labels?.length">Select labels...</span>
951934
<template v-else>
952-
<span v-for="labelId in store.workflowActions.add_labels" :key="labelId"
953-
class="ui label"
954-
:style="`background-color: ${store.projectLabels.find(l => String(l.id) === labelId)?.color}; color: ${getLabelTextColor(store.projectLabels.find(l => String(l.id) === labelId)?.color)}`">
935+
<span
936+
v-for="labelId in store.workflowActions.add_labels" :key="labelId"
937+
class="ui label"
938+
:style="`background-color: ${store.projectLabels.find(l => String(l.id) === labelId)?.color}; color: ${getLabelTextColor(store.projectLabels.find(l => String(l.id) === labelId)?.color)}`"
939+
>
955940
{{ store.projectLabels.find(l => String(l.id) === labelId)?.name }}
956941
</span>
957942
</template>
958943
</div>
959944
<div class="menu">
960-
<div class="item" v-for="label in store.projectLabels" :key="label.id"
961-
:data-value="String(label.id)"
962-
@click.prevent="toggleLabel('add_labels', String(label.id))"
963-
:class="{ active: store.workflowActions.add_labels.includes(String(label.id)), selected: store.workflowActions.add_labels.includes(String(label.id)) }">
945+
<div
946+
class="item" v-for="label in store.projectLabels" :key="label.id"
947+
:data-value="String(label.id)"
948+
@click.prevent="toggleLabel('add_labels', String(label.id))"
949+
:class="{ active: store.workflowActions.add_labels.includes(String(label.id)), selected: store.workflowActions.add_labels.includes(String(label.id)) }"
950+
>
964951
<span class="ui label" :style="`background-color: ${label.color}; color: ${getLabelTextColor(label.color)}`">
965952
{{ label.name }}
966953
</span>
@@ -969,9 +956,11 @@ onUnmounted(() => {
969956
</div>
970957
<div v-else class="ui labels">
971958
<span v-if="!store.workflowActions.add_labels?.length" class="text-muted">None</span>
972-
<span v-for="labelId in store.workflowActions.add_labels" :key="labelId"
973-
class="ui label"
974-
:style="`background-color: ${store.projectLabels.find(l => String(l.id) === labelId)?.color}; color: ${getLabelTextColor(store.projectLabels.find(l => String(l.id) === labelId)?.color)}`">
959+
<span
960+
v-for="labelId in store.workflowActions.add_labels" :key="labelId"
961+
class="ui label"
962+
:style="`background-color: ${store.projectLabels.find(l => String(l.id) === labelId)?.color}; color: ${getLabelTextColor(store.projectLabels.find(l => String(l.id) === labelId)?.color)}`"
963+
>
975964
{{ store.projectLabels.find(l => String(l.id) === labelId)?.name }}
976965
</span>
977966
</div>
@@ -981,22 +970,26 @@ onUnmounted(() => {
981970
<label>{{ locale.removeLabels }}</label>
982971
<div v-if="isInEditMode" class="ui fluid multiple search selection dropdown label-dropdown">
983972
<input type="hidden" :value="store.workflowActions.remove_labels.join(',')">
984-
<i class="dropdown icon"></i>
973+
<i class="dropdown icon"/>
985974
<div class="text" :class="{ default: !store.workflowActions.remove_labels?.length }">
986975
<span v-if="!store.workflowActions.remove_labels?.length">Select labels...</span>
987976
<template v-else>
988-
<span v-for="labelId in store.workflowActions.remove_labels" :key="labelId"
989-
class="ui label"
990-
:style="`background-color: ${store.projectLabels.find(l => String(l.id) === labelId)?.color}; color: ${getLabelTextColor(store.projectLabels.find(l => String(l.id) === labelId)?.color)}`">
977+
<span
978+
v-for="labelId in store.workflowActions.remove_labels" :key="labelId"
979+
class="ui label"
980+
:style="`background-color: ${store.projectLabels.find(l => String(l.id) === labelId)?.color}; color: ${getLabelTextColor(store.projectLabels.find(l => String(l.id) === labelId)?.color)}`"
981+
>
991982
{{ store.projectLabels.find(l => String(l.id) === labelId)?.name }}
992983
</span>
993984
</template>
994985
</div>
995986
<div class="menu">
996-
<div class="item" v-for="label in store.projectLabels" :key="label.id"
997-
:data-value="String(label.id)"
998-
@click.prevent="toggleLabel('remove_labels', String(label.id))"
999-
:class="{ active: store.workflowActions.remove_labels.includes(String(label.id)), selected: store.workflowActions.remove_labels.includes(String(label.id)) }">
987+
<div
988+
class="item" v-for="label in store.projectLabels" :key="label.id"
989+
:data-value="String(label.id)"
990+
@click.prevent="toggleLabel('remove_labels', String(label.id))"
991+
:class="{ active: store.workflowActions.remove_labels.includes(String(label.id)), selected: store.workflowActions.remove_labels.includes(String(label.id)) }"
992+
>
1000993
<span class="ui label" :style="`background-color: ${label.color}; color: ${getLabelTextColor(label.color)}`">
1001994
{{ label.name }}
1002995
</span>
@@ -1005,9 +998,11 @@ onUnmounted(() => {
1005998
</div>
1006999
<div v-else class="ui labels">
10071000
<span v-if="!store.workflowActions.remove_labels?.length" class="text-muted">None</span>
1008-
<span v-for="labelId in store.workflowActions.remove_labels" :key="labelId"
1009-
class="ui label"
1010-
:style="`background-color: ${store.projectLabels.find(l => String(l.id) === labelId)?.color}; color: ${getLabelTextColor(store.projectLabels.find(l => String(l.id) === labelId)?.color)}`">
1001+
<span
1002+
v-for="labelId in store.workflowActions.remove_labels" :key="labelId"
1003+
class="ui label"
1004+
:style="`background-color: ${store.projectLabels.find(l => String(l.id) === labelId)?.color}; color: ${getLabelTextColor(store.projectLabels.find(l => String(l.id) === labelId)?.color)}`"
1005+
>
10111006
{{ store.projectLabels.find(l => String(l.id) === labelId)?.name }}
10121007
</span>
10131008
</div>
@@ -1027,14 +1022,13 @@ onUnmounted(() => {
10271022
</select>
10281023
<div v-else class="readonly-value">
10291024
{{ store.workflowActions.issue_state === 'close' ? locale.closeIssue :
1030-
store.workflowActions.issue_state === 'reopen' ? locale.reopenIssue : locale.noChange }}
1025+
store.workflowActions.issue_state === 'reopen' ? locale.reopenIssue : locale.noChange }}
10311026
</div>
10321027
</div>
10331028
</div>
10341029
</div>
10351030
</div>
10361031
</div>
1037-
10381032
</div>
10391033
</div>
10401034
</div>

0 commit comments

Comments
 (0)