Skip to content

feat: Alert popup when a round is already active/paused #303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions frontend/src/components/Campaign/ViewCampaign.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<cdx-button
v-if="!showAddRoundForm"
action="progressive"
@click="addRound"
@click="campaignRounds.some(r => r.status == 'active' || r.status=='paused') ? (ActiveGoalAlert = true) : addRound()"
Copy link
Preview

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inline conditional logic in the click handler is complex and hard to read. Consider extracting this logic into a separate method like handleAddRoundClick() for better maintainability.

Copilot uses AI. Check for mistakes.

:disabled="campaign.isArchived"
icon
class="add-round-button"
Expand Down Expand Up @@ -141,11 +141,23 @@
/>
</cdx-field>
</div>

</div>
<cdx-dialog
v-model:open="ActiveGoalAlert"
title="Round already active"
:primary-action="primaryAction"
@primary="ActiveGoalAlert=false"
>
<p>
You already have an active round in this campaign. Please complete or close the current round before starting a new one.
</p>
</cdx-dialog>

</template>

<script setup>
import { ref, onMounted } from 'vue'
import { ref, onMounted, defineComponent } from 'vue'
Copy link
Preview

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The defineComponent import is added but not used anywhere in the code. This unused import should be removed.

Suggested change
import { ref, onMounted, defineComponent } from 'vue'
import { ref, onMounted } from 'vue'

Copilot uses AI. Check for mistakes.

import { useRoute, useRouter } from 'vue-router'
import { useI18n } from 'vue-i18n'
import { formatDate } from '@/utils'
Expand All @@ -158,7 +170,7 @@ import { z } from 'zod'
import RoundView from '@/components/Round/RoundView.vue'
import RoundNew from '@/components/Round/RoundNew.vue'
import UserList from '@/components/UserList.vue'
import { CdxButton, CdxTextInput, CdxField } from '@wikimedia/codex'
import { CdxButton, CdxTextInput, CdxField, CdxDialog } from '@wikimedia/codex'

// Icons
import CogIcon from 'vue-material-design-icons/Cog.vue'
Expand All @@ -178,6 +190,7 @@ const campaignId = route.params.id.split('-')[0]
const campaignEditMode = ref(false)
const showAddRoundForm = ref(false)
const canCloseCampaign = ref(false)
const ActiveGoalAlert = ref(false)

const campaign = ref({})
const campaignRounds = ref([])
Expand All @@ -199,6 +212,11 @@ const errors = ref({
coordinators: ''
})

const primaryAction = {
label: 'Okay',
actionType: 'progressive'
Comment on lines +216 to +217
Copy link
Preview

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The primaryAction object uses inconsistent indentation (tabs instead of spaces) compared to the rest of the file. Ensure consistent formatting throughout the component.

Suggested change
label: 'Okay',
actionType: 'progressive'
label: 'Okay',
actionType: 'progressive'

Copilot uses AI. Check for mistakes.

};

const schema = z.object({
name: z.string().min(1, $t('montage-required-campaign-name')),
openDate: z.string().refine((val) => !isNaN(Date.parse(val)), $t('montage-required-open-date')),
Expand Down