Skip to content
Snippets Groups Projects
Verified Commit 9529a2e6 authored by Himanshu Kapoor's avatar Himanshu Kapoor Committed by GitLab
Browse files

Merge branch 'feat/maintainers-edit-wiki-comments' into 'master'

allow maintainers to edit/delete notes

See merge request !177654



Merged-by: default avatarHimanshu Kapoor <info@fleon.org>
Approved-by: default avatarAlex Fracazo <afracazo@gitlab.com>
Approved-by: default avatarHimanshu Kapoor <info@fleon.org>
Co-authored-by: Salihu Dickson's avatarSalihu <salihudickson@gmail.com>
parents 90b16b69 6021e90f
No related branches found
No related tags found
3 merge requests!181325Fix ambiguous `created_at` in project.rb,!179611Draft: Rebase CR approach for zoekt assignments,!177654allow maintainers to edit/delete notes
Pipeline #1627564057 passed with warnings
Pipeline: GitLab

#1627590908

    Pipeline: GitLab

    #1627590904

      Pipeline: GitLab

      #1627586016

        +30
        ...@@ -36,11 +36,6 @@ export default { ...@@ -36,11 +36,6 @@ export default {
        required: false, required: false,
        default: false, default: false,
        }, },
        userPermissions: {
        type: Object,
        required: false,
        default: () => ({}),
        },
        }, },
        data() { data() {
        return { return {
        ...@@ -53,18 +48,14 @@ export default { ...@@ -53,18 +48,14 @@ export default {
        userSignedId() { userSignedId() {
        return Boolean(this.currentUserData?.id); return Boolean(this.currentUserData?.id);
        }, },
        userPermissions() {
        return this.note.userPermissions;
        },
        canReply() { canReply() {
        const { return this.userPermissions?.createNote && this.userSignedId && !this.replyNote;
        userPermissions: { createNote },
        userSignedId,
        } = this;
        return createNote && userSignedId && !this.replyNote;
        }, },
        canEdit() { canEdit() {
        const { currentUserData, userSignedId } = this; return this.userSignedId && this.userPermissions?.adminNote;
        return userSignedId && currentUserData?.id.toString() === this.authorId;
        }, },
        canReportAsAbuse() { canReportAsAbuse() {
        const { currentUserData, userSignedId } = this; const { currentUserData, userSignedId } = this;
        ......
        ...@@ -22,7 +22,6 @@ describe('WikiNote', () => { ...@@ -22,7 +22,6 @@ describe('WikiNote', () => {
        const createWrapper = (props) => { const createWrapper = (props) => {
        return shallowMountExtended(WikiNote, { return shallowMountExtended(WikiNote, {
        propsData: { propsData: {
        note,
        noteableId, noteableId,
        ...props, ...props,
        }, },
        ...@@ -47,7 +46,7 @@ describe('WikiNote', () => { ...@@ -47,7 +46,7 @@ describe('WikiNote', () => {
        }; };
        beforeEach(() => { beforeEach(() => {
        wrapper = createWrapper(); wrapper = createWrapper({ note });
        }); });
        describe('renders correctly by default', () => { describe('renders correctly by default', () => {
        ...@@ -95,7 +94,7 @@ describe('WikiNote', () => { ...@@ -95,7 +94,7 @@ describe('WikiNote', () => {
        expect(noteActions.props()).toMatchObject({ expect(noteActions.props()).toMatchObject({
        authorId: '1', authorId: '1',
        noteUrl: note.url, noteUrl: note.url,
        showReply: false, showReply: true,
        showEdit: false, showEdit: false,
        canReportAsAbuse: true, canReportAsAbuse: true,
        }); });
        ...@@ -114,7 +113,7 @@ describe('WikiNote', () => { ...@@ -114,7 +113,7 @@ describe('WikiNote', () => {
        describe('when user is signed in', () => { describe('when user is signed in', () => {
        beforeEach(() => { beforeEach(() => {
        wrapper = createWrapper(); wrapper = createWrapper({ note });
        }); });
        it('should emit reply when reply event is fired from note actions', () => { it('should emit reply when reply event is fired from note actions', () => {
        ...@@ -125,11 +124,7 @@ describe('WikiNote', () => { ...@@ -125,11 +124,7 @@ describe('WikiNote', () => {
        }); });
        it('should pass prop "showReply" as true to note actions when user can reply', () => { it('should pass prop "showReply" as true to note actions when user can reply', () => {
        wrapper = createWrapper({ wrapper = createWrapper({ note });
        userPermissions: {
        createNote: true,
        },
        });
        const noteActions = wrapper.findComponent(NoteActions); const noteActions = wrapper.findComponent(NoteActions);
        expect(noteActions.props().showReply).toBe(true); expect(noteActions.props().showReply).toBe(true);
        ...@@ -137,8 +132,12 @@ describe('WikiNote', () => { ...@@ -137,8 +132,12 @@ describe('WikiNote', () => {
        it('should pass prop "showReply" as false to note actions when user cannot reply', () => { it('should pass prop "showReply" as false to note actions when user cannot reply', () => {
        wrapper = createWrapper({ wrapper = createWrapper({
        userPermissions: { note: {
        createNote: false, ...note,
        userPermissions: {
        ...note.userPermissions,
        createNote: false,
        },
        }, },
        }); });
        ...@@ -176,9 +175,9 @@ describe('WikiNote', () => { ...@@ -176,9 +175,9 @@ describe('WikiNote', () => {
        wrapper = createWrapper({ wrapper = createWrapper({
        note: { note: {
        ...note, ...note,
        author: { userPermissions: {
        ...note.author, ...note.userPermissions,
        id: 'gid://gitlab/User/70', adminNote: true,
        }, },
        }, },
        }); });
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Finish editing this message first!
        Please register or to comment