-
Notifications
You must be signed in to change notification settings - Fork 24
feat: add modal to create new assignment #1396
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
rudimatz
wants to merge
4
commits into
ietf-tools:main
Choose a base branch
from
rudimatz:feat/assignment-modal-in-tab
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+147
−17
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -11,6 +11,17 @@ | |||||
| <BaseBadge :label="props.message.role" size="xl"></BaseBadge> | ||||||
| assignment | ||||||
| </span> | ||||||
| <span v-else-if="props.message.type === 'add'" class="flex items-center gap-2"> | ||||||
| Add | ||||||
| <select | ||||||
| v-model="selectedRole" | ||||||
| class="text-base font-normal border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-neutral-800 min-w-[14rem]"> | ||||||
| <option v-for="role in roleOptions" :key="role.slug" :value="role.slug"> | ||||||
| {{ role.name }} | ||||||
| </option> | ||||||
| </select> | ||||||
| assignment | ||||||
| </span> | ||||||
| </h1> | ||||||
| <BaseButton btnType="cancel" class="m-2 flex items-center" @click="closeOverlayModal"> | ||||||
| <Icon name="uil:times" class="h-5 w-5" aria-hidden="true" /> | ||||||
|
|
@@ -94,7 +105,7 @@ | |||||
| <script setup lang="ts"> | ||||||
| import { watch } from 'vue' | ||||||
| import { BaseButton } from '#components' | ||||||
| import type { Assignment, RpcPerson } from '~/purple_client' | ||||||
| import type { Assignment, RpcPerson, RpcRole } from '~/purple_client' | ||||||
| import type { AssignmentMessageProps } from '~/utils/queue' | ||||||
| import type { ResolvedQueueItem } from './AssignmentsTypes' | ||||||
| import { overlayModalKey } from '~/providers/providerKeys' | ||||||
|
|
@@ -110,9 +121,28 @@ type Props = { | |||||
| peopleWorkload: Record<number, RpcPersonWorkload> | ||||||
| clusters: ResolvedCluster[] | ||||||
| onSuccess: () => void | ||||||
| // Only used by the 'add' message type: the roles the assigner can choose from | ||||||
| // (caller should exclude the synthetic 'blocked' role) and the role to | ||||||
| // pre-select (typically the draft's next pending activity). | ||||||
| roles?: RpcRole[] | ||||||
| defaultRole?: Assignment['role'] | ||||||
| } | ||||||
| const props = defineProps<Props>() | ||||||
|
|
||||||
| // Role options for the 'add' picker; defensively drop the synthetic 'blocked' | ||||||
| // role even if the caller forgot to. | ||||||
| const roleOptions = computed(() => (props.roles ?? []).filter((role) => role.slug !== 'blocked')) | ||||||
|
|
||||||
| const selectedRole = ref<Assignment['role']>( | ||||||
| props.message.type === 'add' ? (props.defaultRole ?? roleOptions.value[0]?.slug ?? '') : '' | ||||||
| ) | ||||||
|
|
||||||
| // The role an 'assign' action should use: chosen in the modal for 'add', or | ||||||
| // fixed by the trigger for 'assign'/'change'. | ||||||
| const effectiveRole = computed<Assignment['role']>(() => | ||||||
| props.message.type === 'add' ? selectedRole.value : props.message.role | ||||||
| ) | ||||||
|
|
||||||
| const generateId = (personId: number | undefined, personIndex: number): string => | ||||||
| `person-${personId ?? personIndex}` | ||||||
|
|
||||||
|
|
@@ -125,7 +155,9 @@ if (!overlayModalKeyInjection) { | |||||
| type SelectedPeople = Record<number, boolean> | ||||||
|
|
||||||
| const getInitialState = (message: AssignmentMessageProps): SelectedPeople => { | ||||||
| if (message.type === 'assign') { | ||||||
| // 'assign' and 'add' start with nobody selected; only 'change' pre-selects the | ||||||
| // people currently assigned to the role. | ||||||
| if (message.type !== 'change') { | ||||||
| return {} | ||||||
| } | ||||||
| return message.assignments.reduce((acc, assignment) => { | ||||||
|
|
@@ -229,12 +261,12 @@ watch( | |||||
| } | ||||||
| }) | ||||||
| ) | ||||||
| } else if (props.message.type === 'assign') { | ||||||
| const message = props.message | ||||||
| } else if (props.message.type === 'assign' || props.message.type === 'add') { | ||||||
| const rfcToBeId = props.message.rfcToBeId | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit
Suggested change
|
||||||
| // withdrawals | ||||||
| // there are no withdrawals when initially assigning | ||||||
| // there are no withdrawals when initially assigning or adding | ||||||
|
|
||||||
| // new assignments | ||||||
| // new assignments — role is fixed for 'assign', chosen for 'add' | ||||||
| newActions.push( | ||||||
| ...Object.entries(isPersonSelected.value) | ||||||
| .filter(([personIdString, isSelected]) => { | ||||||
|
|
@@ -245,18 +277,26 @@ watch( | |||||
| return { | ||||||
| type: 'assign', | ||||||
| personId, | ||||||
| rfcToBeId: message.rfcToBeId, | ||||||
| role: message.role | ||||||
| rfcToBeId, | ||||||
| role: effectiveRole.value | ||||||
| } | ||||||
| }) | ||||||
| ) | ||||||
| } | ||||||
|
|
||||||
| actions.value = newActions | ||||||
| // Changing the role in 'add' mode must rebuild the pending actions with the | ||||||
| // new role, so watch selectedRole alongside the person selection. | ||||||
| }, | ||||||
| { deep: true } | ||||||
| ) | ||||||
|
|
||||||
| watch(selectedRole, () => { | ||||||
| actions.value = actions.value.map((action) => | ||||||
| action.type === 'assign' ? { ...action, role: selectedRole.value } : action | ||||||
| ) | ||||||
| }) | ||||||
|
|
||||||
| // filter the list of editors to those who are active or currently assigned | ||||||
| const visiblePeople = computed(() => { | ||||||
| return props.people.filter((person) => { | ||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awaitthis?It seems we have inconsistent patterns across the codebase for this so I'm not sure what the correct pattern is.
If it is awaited then the noop
.catch(() => {})is probably redundant, considering the following catch.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's in an async, awaiting would make sense to me. . .