Commit 6c7b826b authored by Rajat Jain's avatar Rajat Jain

Make design note pin compliant with Pajamas

Refactor and stop using badge for design note pin

Changelog: other
parent f15ceccb
<script> <script>
import { GlTooltipDirective, GlIcon, GlLoadingIcon, GlLink, GlBadge } from '@gitlab/ui'; import { GlTooltipDirective, GlIcon, GlLoadingIcon, GlLink } from '@gitlab/ui';
import { ApolloMutation } from 'vue-apollo'; import { ApolloMutation } from 'vue-apollo';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import ReplyPlaceholder from '~/notes/components/discussion_reply_placeholder.vue'; import ReplyPlaceholder from '~/notes/components/discussion_reply_placeholder.vue';
import { updateGlobalTodoCount } from '~/vue_shared/components/sidebar/todo_toggle/utils'; import { updateGlobalTodoCount } from '~/vue_shared/components/sidebar/todo_toggle/utils';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import DesignNotePin from '~/vue_shared/components/design_management/design_note_pin.vue';
import { ACTIVE_DISCUSSION_SOURCE_TYPES } from '../../constants'; import { ACTIVE_DISCUSSION_SOURCE_TYPES } from '../../constants';
import createNoteMutation from '../../graphql/mutations/create_note.mutation.graphql'; import createNoteMutation from '../../graphql/mutations/create_note.mutation.graphql';
import toggleResolveDiscussionMutation from '../../graphql/mutations/toggle_resolve_discussion.mutation.graphql'; import toggleResolveDiscussionMutation from '../../graphql/mutations/toggle_resolve_discussion.mutation.graphql';
...@@ -30,7 +31,7 @@ export default { ...@@ -30,7 +31,7 @@ export default {
GlLink, GlLink,
ToggleRepliesWidget, ToggleRepliesWidget,
TimeAgoTooltip, TimeAgoTooltip,
GlBadge, DesignNotePin,
}, },
directives: { directives: {
GlTooltip: GlTooltipDirective, GlTooltip: GlTooltipDirective,
...@@ -213,12 +214,7 @@ export default { ...@@ -213,12 +214,7 @@ export default {
<template> <template>
<div class="design-discussion-wrapper"> <div class="design-discussion-wrapper">
<gl-badge <design-note-pin :is-resolved="discussion.resolved" :label="discussion.index" />
class="gl-display-flex gl-align-items-center gl-justify-content-center gl-cursor-pointer"
:class="{ resolved: discussion.resolved }"
>
{{ discussion.index }}
</gl-badge>
<ul <ul
class="design-discussion bordered-box gl-relative gl-p-0 gl-list-style-none" class="design-discussion bordered-box gl-relative gl-p-0 gl-list-style-none"
data-qa-selector="design_discussion_content" data-qa-selector="design_discussion_content"
......
<script> <script>
import { __ } from '~/locale'; import { __ } from '~/locale';
import DesignNotePin from '~/vue_shared/components/design_management/design_note_pin.vue';
import { ACTIVE_DISCUSSION_SOURCE_TYPES } from '../constants'; import { ACTIVE_DISCUSSION_SOURCE_TYPES } from '../constants';
import updateActiveDiscussionMutation from '../graphql/mutations/update_active_discussion.mutation.graphql'; import updateActiveDiscussionMutation from '../graphql/mutations/update_active_discussion.mutation.graphql';
import activeDiscussionQuery from '../graphql/queries/active_discussion.query.graphql'; import activeDiscussionQuery from '../graphql/queries/active_discussion.query.graphql';
import DesignNotePin from './design_note_pin.vue';
export default { export default {
name: 'DesignOverlay', name: 'DesignOverlay',
...@@ -251,9 +251,6 @@ export default { ...@@ -251,9 +251,6 @@ export default {
!discussionNotes.some(({ id }) => id === this.activeDiscussion.id) !discussionNotes.some(({ id }) => id === this.activeDiscussion.id)
); );
}, },
designPinClass(note) {
return { inactive: this.isNoteInactive(note), resolved: note.resolved };
},
}, },
i18n: { i18n: {
newCommentButtonLabel: __('Add comment to design'), newCommentButtonLabel: __('Add comment to design'),
...@@ -287,7 +284,8 @@ export default { ...@@ -287,7 +284,8 @@ export default {
? getNotePositionStyle(movingNoteNewPosition) ? getNotePositionStyle(movingNoteNewPosition)
: getNotePositionStyle(note.position) : getNotePositionStyle(note.position)
" "
:class="designPinClass(note)" :is-inactive="isNoteInactive(note)"
:is-resolved="note.resolved"
@mousedown.stop="onNoteMousedown($event, note)" @mousedown.stop="onNoteMousedown($event, note)"
@mouseup.stop="onNoteMouseup(note)" @mouseup.stop="onNoteMouseup(note)"
/> />
......
...@@ -10,13 +10,24 @@ export default { ...@@ -10,13 +10,24 @@ export default {
props: { props: {
position: { position: {
type: Object, type: Object,
required: true, required: false,
default: null,
}, },
label: { label: {
type: Number, type: Number,
required: false, required: false,
default: null, default: null,
}, },
isResolved: {
type: Boolean,
required: false,
default: false,
},
isInactive: {
type: Boolean,
required: false,
default: false,
},
}, },
computed: { computed: {
isNewNote() { isNewNote() {
...@@ -36,10 +47,13 @@ export default { ...@@ -36,10 +47,13 @@ export default {
:style="position" :style="position"
:aria-label="pinLabel" :aria-label="pinLabel"
:class="{ :class="{
'btn-transparent comment-indicator gl-p-0': isNewNote, 'btn-transparent comment-indicator': isNewNote,
'js-image-badge badge badge-pill': !isNewNote, 'js-image-badge design-note-pin': !isNewNote,
resolved: isResolved,
inactive: isInactive,
'gl-absolute': position,
}" }"
class="gl-absolute gl-display-flex gl-align-items-center gl-justify-content-center gl-font-lg gl-outline-0!" class="gl-display-flex gl-align-items-center gl-justify-content-center gl-font-sm"
type="button" type="button"
@mousedown="$emit('mousedown', $event)" @mousedown="$emit('mousedown', $event)"
@mouseup="$emit('mouseup', $event)" @mouseup="$emit('mouseup', $event)"
......
...@@ -12,7 +12,7 @@ $t-gray-a-16-design-pin: rgba($black, 0.16); ...@@ -12,7 +12,7 @@ $t-gray-a-16-design-pin: rgba($black, 0.16);
top: 35px; top: 35px;
} }
.badge.badge-pill { .design-note-pin {
display: flex; display: flex;
height: $design-pin-diameter; height: $design-pin-diameter;
width: $design-pin-diameter; width: $design-pin-diameter;
...@@ -23,6 +23,7 @@ $t-gray-a-16-design-pin: rgba($black, 0.16); ...@@ -23,6 +23,7 @@ $t-gray-a-16-design-pin: rgba($black, 0.16);
border-radius: 50%; border-radius: 50%;
z-index: 1; z-index: 1;
padding: 0; padding: 0;
border: 0;
&.resolved { &.resolved {
background-color: $gray-500; background-color: $gray-500;
...@@ -34,7 +35,7 @@ $t-gray-a-16-design-pin: rgba($black, 0.16); ...@@ -34,7 +35,7 @@ $t-gray-a-16-design-pin: rgba($black, 0.16);
} }
.comment-indicator, .comment-indicator,
.frame .badge.badge-pill { .frame .design-note-pin {
&:active { &:active {
cursor: grabbing; cursor: grabbing;
} }
...@@ -43,7 +44,7 @@ $t-gray-a-16-design-pin: rgba($black, 0.16); ...@@ -43,7 +44,7 @@ $t-gray-a-16-design-pin: rgba($black, 0.16);
/** /**
* Design pin that overlays the design * Design pin that overlays the design
*/ */
.frame .badge.badge-pill { .frame .design-note-pin {
box-shadow: 0 2px 4px $t-gray-a-08, 0 0 1px $t-gray-a-24; box-shadow: 0 2px 4px $t-gray-a-08, 0 0 1px $t-gray-a-24;
border: $white 2px solid; border: $white 2px solid;
will-change: transform, box-shadow, opacity; will-change: transform, box-shadow, opacity;
...@@ -114,7 +115,7 @@ $t-gray-a-16-design-pin: rgba($black, 0.16); ...@@ -114,7 +115,7 @@ $t-gray-a-16-design-pin: rgba($black, 0.16);
} }
} }
.badge.badge-pill { .design-note-pin {
margin-left: $gl-padding; margin-left: $gl-padding;
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
exports[`Design note pin component should match the snapshot of note with index 1`] = ` exports[`Design note pin component should match the snapshot of note with index 1`] = `
<button <button
aria-label="Comment '1' position" aria-label="Comment '1' position"
class="gl-absolute gl-display-flex gl-align-items-center gl-justify-content-center gl-font-lg gl-outline-0! js-image-badge badge badge-pill" class="gl-display-flex gl-align-items-center gl-justify-content-center gl-font-sm js-image-badge design-note-pin gl-absolute"
style="left: 10px; top: 10px;" style="left: 10px; top: 10px;"
type="button" type="button"
> >
...@@ -16,7 +16,7 @@ exports[`Design note pin component should match the snapshot of note with index ...@@ -16,7 +16,7 @@ exports[`Design note pin component should match the snapshot of note with index
exports[`Design note pin component should match the snapshot of note without index 1`] = ` exports[`Design note pin component should match the snapshot of note without index 1`] = `
<button <button
aria-label="Comment form position" aria-label="Comment form position"
class="gl-absolute gl-display-flex gl-align-items-center gl-justify-content-center gl-font-lg gl-outline-0! btn-transparent comment-indicator gl-p-0" class="gl-display-flex gl-align-items-center gl-justify-content-center gl-font-sm btn-transparent comment-indicator gl-absolute"
style="left: 10px; top: 10px;" style="left: 10px; top: 10px;"
type="button" type="button"
> >
...@@ -26,3 +26,30 @@ exports[`Design note pin component should match the snapshot of note without ind ...@@ -26,3 +26,30 @@ exports[`Design note pin component should match the snapshot of note without ind
/> />
</button> </button>
`; `;
exports[`Design note pin component should match the snapshot when pin is resolved 1`] = `
<button
aria-label="Comment form position"
class="gl-display-flex gl-align-items-center gl-justify-content-center gl-font-sm btn-transparent comment-indicator resolved gl-absolute"
style="left: 10px; top: 10px;"
type="button"
>
<gl-icon-stub
name="image-comment-dark"
size="24"
/>
</button>
`;
exports[`Design note pin component should match the snapshot when position is absent 1`] = `
<button
aria-label="Comment form position"
class="gl-display-flex gl-align-items-center gl-justify-content-center gl-font-sm btn-transparent comment-indicator"
type="button"
>
<gl-icon-stub
name="image-comment-dark"
size="24"
/>
</button>
`;
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import DesignNotePin from '~/design_management/components/design_note_pin.vue'; import DesignNotePin from '~/vue_shared/components/design_management/design_note_pin.vue';
describe('Design note pin component', () => { describe('Design note pin component', () => {
let wrapper; let wrapper;
...@@ -29,4 +29,14 @@ describe('Design note pin component', () => { ...@@ -29,4 +29,14 @@ describe('Design note pin component', () => {
createComponent({ label: 1 }); createComponent({ label: 1 });
expect(wrapper.element).toMatchSnapshot(); expect(wrapper.element).toMatchSnapshot();
}); });
it('should match the snapshot when pin is resolved', () => {
createComponent({ isResolved: true });
expect(wrapper.element).toMatchSnapshot();
});
it('should match the snapshot when position is absent', () => {
createComponent({ position: null });
expect(wrapper.element).toMatchSnapshot();
});
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment