Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added link to entity and dataset from submission activity feed #790

Merged
merged 2 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions src/components/submission/feed-entry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,16 @@ except according to the terms contained in the LICENSE file.
<template v-else-if="entry.action === 'entity.create'">
<span class="icon-magic-wand entity-icon"></span>
<i18n-t keypath="title.entity.create">
<template #label><span class="submission-feed-entry-entity-data">{{ entityLabel(entry) }}</span></template>
<template #dataset><span class="submission-feed-entry-entity-data">{{ entityDataset(entry) }}</span></template>
<template #label>
<router-link :to="entityPath(projectId, entityDataset(entry), entityUuid(entry))" class="submission-feed-entry-entity-data">
{{ entityLabel(entry) }}
</router-link>
</template>
<template #dataset>
<router-link :to="datasetPath(projectId, entityDataset(entry))" class="submission-feed-entry-entity-data">
{{ entityDataset(entry) }}
</router-link>
</template>
</i18n-t>
</template>
<template v-else-if="entry.action === 'entity.create.error'">
Expand Down Expand Up @@ -69,6 +77,7 @@ import MarkdownView from '../markdown/view.vue';
import SubmissionDiffItem from './diff-item.vue';

import useReviewState from '../../composables/review-state';
import useRoutes from '../../composables/routes';
import { useRequestData } from '../../request-data';

export default {
Expand All @@ -95,7 +104,8 @@ export default {
setup() {
const { diffs } = useRequestData();
const { reviewStateIcon } = useReviewState();
return { diffs, reviewStateIcon };
const { datasetPath, entityPath } = useRoutes();
return { diffs, reviewStateIcon, datasetPath, entityPath };
},
computed: {
updateOrEdit() {
Expand Down Expand Up @@ -155,6 +165,11 @@ export default {
return entry.details.entity.dataset;
return '';
},
entityUuid(entry) {
if ('entity' in entry.details)
return entry.details.entity.uuid;
return '';
},
entityProblem(entry) {
if ('problem' in entry.details &&
'problemDetails' in entry.details.problem &&
Expand Down Expand Up @@ -215,7 +230,7 @@ export default {
*/
"create": "Submitted by {name}",
"entity": {
"create": "Created Entity {label} in {dataset} Dataset",
"create": "Created Entity {label} in Dataset {dataset}",
Copy link
Member

@matthew-white matthew-white May 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we definitely want to make this change? I know it's "Dataset {dataset}" in the current release criteria, but I'm not sure that's intentional. I think we landed on "{dataset} Dataset" during 2022.3 after considering both options: https://docs.google.com/document/d/1naxyzFU8EjcWKfYzE_mEF5cY38l1QRNUZ_0VW2Gp-r0/edit?disco=AAAAZ-n7VuE

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't definitely want to make it, so i'll put it back.

Just saw it in the release criteria and felt drawn to it... We have more formatting than we did before and it's also weird how Entity X and Y Dataset are not following the same pattern.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean about the inconsistency. I think it works this way only because {dataset} is a single word, so "{dataset} Dataset" becomes almost like a compound noun.

"error": "Problem creating Entity",
},
"updateReviewState": {
Expand Down
6 changes: 6 additions & 0 deletions src/composables/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,19 @@ export default memoizeForContainer(({ router, requestData }) => {
return _datasetPath(projectIdOrSuffix, datasetName, suffix);
};

const entityPath = (projectId, datasetName, entityUuid) => {
const encodedName = encodeURIComponent(datasetName);
return `/projects/${projectId}/datasets/${encodedName}/entities/${entityUuid}`;
};

const userPath = (id) => `/users/${id}/edit`;

return {
projectPath,
formPath, publishedFormPath, primaryFormPath,
submissionPath,
datasetPath,
entityPath,
userPath,
canRoute: canRouteToLocation
};
Expand Down
20 changes: 18 additions & 2 deletions test/components/submission/feed-entry.spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

import { RouterLinkStub } from '@vue/test-utils';

import ActorLink from '../../../src/components/actor-link.vue';
import DateTime from '../../../src/components/date-time.vue';
import MarkdownView from '../../../src/components/markdown/view.vue';
Expand Down Expand Up @@ -161,7 +164,20 @@ describe('SubmissionFeedEntry', () => {
details: { entity: { uuid: 'xyz', label: 'EntityName', dataset: 'DatasetName' } }
});
const title = mountComponent().get('.feed-entry-title');
title.text().should.equal('Created Entity EntityName in DatasetName Dataset');
title.text().should.equal('Created Entity EntityName in Dataset DatasetName');
});

it('renders links to entity and dataset', () => {
testData.extendedAudits.createPast(1, {
action: 'entity.create',
details: { entity: { uuid: 'xyz', label: 'EntityName', dataset: 'DatasetName' } }
});
const links = mountComponent().findAllComponents(RouterLinkStub);
links.length.should.equal(2);
links.map(link => link.props().to).should.eql([
'/projects/1/datasets/DatasetName/entities/xyz',
'/projects/1/datasets/DatasetName'
]);
});

it('renders okay and does not crash for action where entity details are missing', () => {
Expand All @@ -170,7 +186,7 @@ describe('SubmissionFeedEntry', () => {
details: { entity: { uuid: 'xyz' } }
});
const title = mountComponent().get('.feed-entry-title');
title.text().should.equal('Created Entity in Dataset');
title.text().should.equal('Created Entity in Dataset');
});
});

Expand Down
9 changes: 9 additions & 0 deletions test/composables/routes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,13 @@ describe('useRoutes()', () => {
datasetPath(1, 'á').should.equal('/projects/1/datasets/%C3%A1');
});
});

describe('entityPath()', () => {
it('returns a path if given IDs', () => {
const container = createTestContainer({ router: mockRouter('/') });
const { entityPath } = withSetup(useRoutes, { container });
const path = entityPath(1, 'a b', 'abcd1234');
path.should.equal('/projects/1/datasets/a%20b/entities/abcd1234');
});
});
});
2 changes: 1 addition & 1 deletion transifex/strings_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3512,7 +3512,7 @@
},
"entity": {
"create": {
"string": "Created Entity {label} in {dataset} Dataset"
"string": "Created Entity {label} in Dataset {dataset}"
},
"error": {
"string": "Problem creating Entity"
Expand Down