diff --git a/src/application/i18n/messages/en.json b/src/application/i18n/messages/en.json index aed70cd6..5c39816e 100644 --- a/src/application/i18n/messages/en.json +++ b/src/application/i18n/messages/en.json @@ -67,6 +67,12 @@ "roles": { "Read": "Reader", "Write": "Writer" + }, + "removeMemberConfirmationTitle": "Remove member", + "removeMemberConfirmationBody": "Are you sure you want to remove '{username}' from the team?", + "contextMenu": { + "title": "More actions", + "remove": "Remove" } } }, diff --git a/src/application/services/useNoteSettings.ts b/src/application/services/useNoteSettings.ts index 7e2d38a3..bd488b3a 100644 --- a/src/application/services/useNoteSettings.ts +++ b/src/application/services/useNoteSettings.ts @@ -66,6 +66,14 @@ interface UseNoteSettingsComposableState { * @param newParentURL - New parent note URL */ setParent: (id: NoteId, newParentURL: string) => Promise; + + /** + * Delete team member by user id + * @param id - Note id + * @param userId - User id + * @returns true if user was removed + */ + removeMemberByUserId: (id: NoteId, userId: UserId) => Promise; } /** @@ -188,6 +196,16 @@ export default function (): UseNoteSettingsComposableState { } }; + /** + * Delete team member by user id + * @param id - Note id + * @param userId - User id + * @returns true if user was removed + */ + const removeMemberByUserId = async (id: NoteId, userId: UserId): Promise => { + return await noteSettingsService.removeMemberByUserId(id, userId); + }; + return { updateCover, setParent, @@ -198,5 +216,6 @@ export default function (): UseNoteSettingsComposableState { revokeHash, changeRole, deleteNoteById, + removeMemberByUserId, }; } diff --git a/src/domain/noteSettings.repository.interface.ts b/src/domain/noteSettings.repository.interface.ts index ce2d8a1e..4ac752d1 100644 --- a/src/domain/noteSettings.repository.interface.ts +++ b/src/domain/noteSettings.repository.interface.ts @@ -43,4 +43,12 @@ export default interface NoteSettingsRepositoryInterface { * @param id - Note id */ deleteNote(id: NoteId): Promise; + + /** + * Delete team member by user id + * @param id - Note id + * @param userId - User id + * @returns true if user was removed + */ + removeMemberByUserId(id: NoteId, userId: UserId): Promise; } diff --git a/src/domain/noteSettings.service.ts b/src/domain/noteSettings.service.ts index 26ca425d..bede251f 100644 --- a/src/domain/noteSettings.service.ts +++ b/src/domain/noteSettings.service.ts @@ -118,4 +118,14 @@ export default class NoteSettingsService { public async deleteNote(id: NoteId): Promise { return await this.noteSettingsRepository.deleteNote(id); } + + /** + * Delete team member by user id + * @param id - Note id + * @param userId - User id + * @returns true if user was removed + */ + public async removeMemberByUserId(id: NoteId, userId: UserId): Promise { + return await this.noteSettingsRepository.removeMemberByUserId(id, userId); + } } diff --git a/src/infrastructure/noteSettings.repository.ts b/src/infrastructure/noteSettings.repository.ts index 90efebe2..72d9f245 100644 --- a/src/infrastructure/noteSettings.repository.ts +++ b/src/infrastructure/noteSettings.repository.ts @@ -69,4 +69,17 @@ export default class NoteSettingsRepository implements NoteSettingsRepositoryInt public async deleteNote(id: NoteId): Promise { await this.transport.delete(`/note/` + id); } + + /** + * Delete team member by user id + * @param id - Note id + * @param userId - User id + * @returns true if user was removed + */ + public async removeMemberByUserId(id: NoteId, userId: UserId): Promise { + const data = { userId }; + const response = await this.transport.delete(`/note-settings/${id}/team`, data); + + return response === userId; + } } diff --git a/src/presentation/components/team/MoreActions.vue b/src/presentation/components/team/MoreActions.vue new file mode 100644 index 00000000..16bda254 --- /dev/null +++ b/src/presentation/components/team/MoreActions.vue @@ -0,0 +1,104 @@ + + + + + diff --git a/src/presentation/components/team/Team.vue b/src/presentation/components/team/Team.vue index b02e5817..17a35df6 100644 --- a/src/presentation/components/team/Team.vue +++ b/src/presentation/components/team/Team.vue @@ -15,6 +15,11 @@ :note-id="noteId" :team-member="member" /> +