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