Commit a640a0a6 authored by Robert Hunt's avatar Robert Hunt

Remove unnecessary mapper

- Remove mapper code
- Update codebase to use the default property names rather than the old
mapped names
parent 75344e64
......@@ -63,7 +63,7 @@ export default {
:name="project.name"
:url="project.webUrl"
/>
<reference :path="mergeRequest.webUrl" :reference="mergeRequest.reference" />
<reference :path="mergeRequest.webUrl" :reference="mergeRequest.ref" />
<branch-path
v-if="hasBranchDetails"
:source-branch="mergeRequest.sourceBranch"
......@@ -76,7 +76,7 @@ export default {
:approvers="mergeRequest.approvedByUsers"
:commenters="mergeRequest.participants"
/>
<merged-by :merged-by="mergeRequest.mergedBy" />
<merged-by :merged-by="mergeRequest.mergeUser" />
</template>
</gl-drawer>
</template>
......@@ -39,7 +39,7 @@ export default {
v-if="hasMergedBy"
:key="mergedBy.id"
:title="mergedBy.name"
:href="mergedBy.web_url"
:href="mergedBy.webUrl"
class="js-user-link"
:data-user-id="mergedBy.id"
:data-name="mergedBy.name"
......@@ -49,7 +49,7 @@ export default {
:entity-name="mergedBy.name"
label=""
:sub-label="mergedBy.name"
:src="mergedBy.avatar_url"
:src="mergedBy.avatarUrl"
/>
</gl-avatar-link>
<drawer-section-sub-header v-else :is-empty="true">
......
......@@ -76,12 +76,12 @@ export default {
<gl-avatar-link
v-gl-tooltip
target="blank"
:href="avatar.web_url"
:href="avatar.webUrl"
:title="avatar.name"
class="gl-text-gray-900 author-link js-user-link"
>
<gl-avatar
:src="avatar.avatar_url"
:src="avatar.avatarUrl"
:entity-id="avatar.id"
:entity-name="avatar.name"
:size="24"
......@@ -94,13 +94,13 @@ export default {
v-for="approver in approversToPresent"
:key="approver.id"
:title="approver.name"
:href="approver.web_url"
:href="approver.webUrl"
:data-user-id="approver.id"
:data-name="approver.name"
class="gl-display-none gl-lg-display-inline-flex! gl-align-items-center gl-justify-content-end gl-ml-3 gl-text-gray-900 author-link js-user-link"
>
<gl-avatar
:src="approver.avatar_url"
:src="approver.avatarUrl"
:entity-id="approver.id"
:entity-name="approver.name"
:size="16"
......
......@@ -43,13 +43,13 @@ export default {
<gl-avatar-link
:key="mergeRequest.author.id"
:title="mergeRequest.author.name"
:href="mergeRequest.author.web_url"
:href="mergeRequest.author.webUrl"
:data-user-id="mergeRequest.author.id"
:data-name="mergeRequest.author.name"
class="gl-display-inline-flex gl-align-items-center gl-ml-3 gl-text-gray-900 author-link js-user-link"
>
<gl-avatar
:src="mergeRequest.author.avatar_url"
:src="mergeRequest.author.avatarUrl"
:entity-id="mergeRequest.author.id"
:entity-name="mergeRequest.author.name"
:size="16"
......
import { convertObjectPropsToSnakeCase } from '~/lib/utils/common_utils';
import { getIdFromGraphQLId, convertNodeIdsFromGraphQLIds } from '~/graphql_shared/utils';
export const mapViolations = (nodes = []) => {
......@@ -9,13 +8,13 @@ export const mapViolations = (nodes = []) => {
committers: convertNodeIdsFromGraphQLIds(node.mergeRequest.committers?.nodes || []),
approvedByUsers: convertNodeIdsFromGraphQLIds(node.mergeRequest.approvedBy?.nodes || []),
participants: convertNodeIdsFromGraphQLIds(node.mergeRequest.participants?.nodes || []),
reference: node.mergeRequest.ref,
mergedBy: {
...convertObjectPropsToSnakeCase(node.mergeRequest.mergeUser),
mergeUser: {
...node.mergeRequest.mergeUser,
id: getIdFromGraphQLId(node.mergeRequest.mergeUser?.id),
},
project: {
...node.mergeRequest.project,
id: getIdFromGraphQLId(node.mergeRequest.project?.id),
complianceFramework: node.mergeRequest.project?.complianceFrameworks?.nodes[0] || null,
},
},
......
......@@ -58,7 +58,7 @@ describe('MergedBy component', () => {
expect(findAvatarLink().classes()).toContain('js-user-link');
expect(findAvatarLink().attributes()).toMatchObject({
title: mergedBy.name,
href: mergedBy.web_url,
href: mergedBy.webUrl,
'data-name': mergedBy.name,
'data-user-id': `${mergedBy.id}`,
});
......@@ -69,7 +69,7 @@ describe('MergedBy component', () => {
});
expect(findAvatarLabel().attributes()).toMatchObject({
'entity-name': mergedBy.name,
src: mergedBy.avatar_url,
src: mergedBy.avatarUrl,
});
});
......
......@@ -109,7 +109,7 @@ describe('MergeRequestDrawer component', () => {
it('has the reference section', () => {
expect(findReference().props()).toStrictEqual({
path: data.mergeRequest.webUrl,
reference: data.mergeRequest.reference,
reference: data.mergeRequest.ref,
});
});
......@@ -132,7 +132,7 @@ describe('MergeRequestDrawer component', () => {
it('has the merged by section', () => {
expect(findMergedBy().props()).toStrictEqual({
mergedBy: data.mergeRequest.mergedBy,
mergedBy: data.mergeRequest.mergeUser,
});
});
});
......
import { mapViolations } from 'ee/compliance_dashboard/graphql/mappers';
import { convertObjectPropsToSnakeCase } from '~/lib/utils/common_utils';
import { getIdFromGraphQLId, convertNodeIdsFromGraphQLIds } from '~/graphql_shared/utils';
import { createComplianceViolation } from '../mock_data';
......@@ -13,11 +12,15 @@ describe('mapViolations', () => {
committers: convertNodeIdsFromGraphQLIds(violation.mergeRequest.committers.nodes),
approvedByUsers: convertNodeIdsFromGraphQLIds(violation.mergeRequest.approvedBy.nodes),
participants: convertNodeIdsFromGraphQLIds(violation.mergeRequest.participants.nodes),
reference: violation.mergeRequest.ref,
mergedBy: {
...convertObjectPropsToSnakeCase(violation.mergeRequest.mergeUser),
mergeUser: {
...violation.mergeRequest.mergeUser,
id: getIdFromGraphQLId(violation.mergeRequest.mergeUser?.id),
},
project: {
...violation.project,
id: getIdFromGraphQLId(violation.mergeRequest.project?.id),
complianceFramework: violation.mergeRequest.project?.complianceFrameworks?.nodes[0],
},
},
violatingUser: {
...violation.violatingUser,
......
export const createUser = (id) => ({
id,
avatar_url: `https://${id}`,
avatarUrl: `https://${id}`,
name: `User ${id}`,
state: 'active',
username: `user-${id}`,
web_url: `http://localhost:3000/user-${id}`,
webUrl: `http://localhost:3000/user-${id}`,
});
export const mergedAt = () => {
......
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