-
Notifications
You must be signed in to change notification settings - Fork 6
Feat: remove team member #342
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
base: main
Are you sure you want to change the base?
Changes from all commits
7ff9cb5
a9d9d4b
2057faa
98111c0
879ff7c
ccfe732
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| <template> | ||
| <button | ||
| ref="triggerButton" | ||
| :title="t('noteSettings.team.contextMenu.title')" | ||
| class="more-actions-button" | ||
| @click="handleButtonClick" | ||
| > | ||
| <Icon | ||
| name="EtcVertical" | ||
| /> | ||
| </button> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { ref } from 'vue'; | ||
| import { Icon, ContextMenu, usePopover, useConfirm, type ContextMenuItem } from '@codexteam/ui/vue'; | ||
| import { type TeamMember } from '@/domain/entities/Team'; | ||
| import { useI18n } from 'vue-i18n'; | ||
| import { NoteId } from '@/domain/entities/Note'; | ||
| import useNoteSettings from '@/application/services/useNoteSettings'; | ||
|
|
||
| const { removeMemberByUserId } = useNoteSettings(); | ||
|
Comment on lines
+20
to
+22
|
||
|
|
||
| const props = defineProps<{ | ||
| /** | ||
| * Team member data | ||
| */ | ||
| teamMember: TeamMember; | ||
| /** | ||
| * Id of the current note | ||
| */ | ||
| noteId: NoteId; | ||
| }>(); | ||
|
|
||
| const { t } = useI18n(); | ||
| const { showPopover, hide } = usePopover(); | ||
| const { confirm } = useConfirm(); | ||
|
|
||
| const triggerButton = ref<HTMLButtonElement>(); | ||
|
|
||
| const menuItems: ContextMenuItem[] = [ | ||
| { | ||
| title: t('noteSettings.team.contextMenu.remove'), | ||
| onActivate: async () => { | ||
| hide(); | ||
| await handleRemove(props.teamMember); | ||
| }, | ||
| }, | ||
| ]; | ||
|
|
||
| const emit = defineEmits<{ | ||
| teamMemberRemoved: [userId: TeamMember['user']['id']]; | ||
| }>(); | ||
|
|
||
| const handleButtonClick = (): void => { | ||
| if (triggerButton.value) { | ||
| showPopover({ | ||
| targetEl: triggerButton.value, | ||
| with: { | ||
| component: ContextMenu, | ||
| props: { | ||
| items: menuItems, | ||
| }, | ||
| }, | ||
| align: { | ||
| vertically: 'below', | ||
| horizontally: 'right', | ||
| }, | ||
| width: 'auto', | ||
| }); | ||
| } | ||
| }; | ||
|
|
||
| /** | ||
| * Remove team member by user id | ||
| * | ||
| * @param member - team member to remove | ||
| */ | ||
| const handleRemove = async (member: TeamMember): Promise<void> => { | ||
| const shouldRemove = await confirm( | ||
| t('noteSettings.team.removeMemberConfirmationTitle'), | ||
| t('noteSettings.team.removeMemberConfirmationBody', { username: member.user.name }) | ||
| ); | ||
|
|
||
| if (shouldRemove) { | ||
| const isDeleted = await removeMemberByUserId(props.noteId, member.user.id); | ||
|
|
||
| if (isDeleted) { | ||
| emit('teamMemberRemoved', member.user.id); | ||
| } | ||
| } | ||
| }; | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| .more-actions-button { | ||
| color: var(--ct-text-color-primary); | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| border: none; | ||
| cursor: pointer; | ||
| } | ||
| </style> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,11 @@ | |
| :note-id="noteId" | ||
| :team-member="member" | ||
| /> | ||
| <MoreActions | ||
| :note-id="noteId" | ||
| :team-member="member" | ||
| @team-member-removed="handleMemberRemoved" | ||
| /> | ||
|
Comment on lines
+18
to
+22
|
||
| </template> | ||
|
|
||
| <template #left> | ||
|
|
@@ -34,12 +39,13 @@ | |
|
|
||
| <script setup lang="ts"> | ||
| import { computed } from 'vue'; | ||
| import { Team, MemberRole } from '@/domain/entities/Team'; | ||
| import { Team, MemberRole, TeamMember } from '@/domain/entities/Team'; | ||
| import { Note, NoteId } from '@/domain/entities/Note'; | ||
| import { Section, Row, Avatar } from '@codexteam/ui/vue'; | ||
| import RoleSelect from './RoleSelect.vue'; | ||
| import { useI18n } from 'vue-i18n'; | ||
| import useNote from '@/application/services/useNote.ts'; | ||
| import MoreActions from './MoreActions.vue'; | ||
|
|
||
| const props = defineProps<{ | ||
| /** | ||
|
|
@@ -52,6 +58,10 @@ const props = defineProps<{ | |
| noteId: NoteId; | ||
| }>(); | ||
|
|
||
| const emit = defineEmits<{ | ||
| teamMemberRemoved: [id: TeamMember['user']['id']]; | ||
| }>(); | ||
|
|
||
| const { t } = useI18n(); | ||
| const { note } = useNote({ id: props.noteId }); | ||
|
|
||
|
|
@@ -79,6 +89,11 @@ const sortedTeam = computed(() => { | |
| return roleOrder[a.role] - roleOrder[b.role]; | ||
| }); | ||
| }); | ||
|
|
||
| // Listen for teamMemberRemoved event from child component and bubble them up | ||
| const handleMemberRemoved = (userId: TeamMember['user']['id']): void => { | ||
| emit('teamMemberRemoved', userId); | ||
| }; | ||
| </script> | ||
|
|
||
| <style scoped> | ||
|
|
||
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.
The icon-only needs an accessible name and should explicitly set type="button" to avoid default submit behavior when used inside a . Consider adding an aria-label/title (e.g., "More actions") and type="button" on this button element.