Skip to content

Commit

Permalink
Skip mounting if not on actions page
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinovantes committed Apr 15, 2022
1 parent 54e2257 commit 92a0c18
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 7 additions & 2 deletions src/components/UserscriptApp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ref, defineComponent, onMounted, computed } from 'vue'
import UserscriptAppSettings from './UserscriptAppSettings.vue'
import { useStore } from '@/store'
import { deleteWorkflowRuns } from '@/services/github/deleteWorkflowRuns'
import { isOnWorkflowsPage } from '@/utils/isOnWorkflowsPage'
export default defineComponent({
components: {
Expand Down Expand Up @@ -39,8 +40,9 @@ export default defineComponent({
return {
title: `${DEFINE.PRODUCT_NAME} ${DEFINE.VERSION}`,
projectUrl: DEFINE.REPO.url,
isOpen: ref(false),
isOnWorkflowsPage: isOnWorkflowsPage(window.location),
numDeletionsLeft,
stopDeleting,
startDeleting,
Expand All @@ -50,7 +52,10 @@ export default defineComponent({
</script>

<template>
<div class="userscript-delete-workflow-runs">
<div
v-if="isOnWorkflowsPage"
class="userscript-delete-workflow-runs"
>
<div
v-if="isOpen"
class="dialog-wrapper"
Expand Down
6 changes: 0 additions & 6 deletions src/services/github/deleteWorkflowRuns.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { isOnWorkflowsPage } from '@/utils/isOnWorkflowsPage'
import { waitForSelector } from '@/utils/waitForSelector'

export async function deleteWorkflowRuns(numWorkflowRunsToKeep: number, onBeforeDelete?: () => Promise<void>): Promise<void> {
if (!isOnWorkflowsPage(window.location)) {
console.warn(DEFINE.NAME, 'Not on workflows page')
return
}

const container = document.querySelector('#partial-actions-workflow-runs')
if (!container) {
throw new Error('Cannot find container')
Expand Down

0 comments on commit 92a0c18

Please sign in to comment.