Skip to content

Commit

Permalink
feat(details): show checksum of file variants
Browse files Browse the repository at this point in the history
  • Loading branch information
anehx committed Nov 10, 2023
1 parent 212f986 commit 2419c4d
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 20 deletions.
39 changes: 28 additions & 11 deletions addon/components/single-document-details.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
<div class="uk-accordion-content">
<ul class="uk-list uk-list-divider">
{{#each (filter-by "variant" "original" @document.files) as |file|}}
<li data-test-file class="uk-flex" title={{file.name}}>
<li data-test-file class="uk-flex">
<span class="uk-margin-right">
{{format-date
file.createdAt
Expand All @@ -219,16 +219,33 @@
<span class="uk-width-expand">
{{~await (resolve-user file.createdByUser)~}}
</span>
<a
uk-icon="download"
class="uk-icon-link"
data-test-file-download-link
href={{file.downloadUrl}}
target="_blank"
rel="noopener noreferrer"
>
<span class="uk-invisible">{{t "alexandria.download"}}</span>
</a>
<span>
<UkIcon @icon="info" class="uk-icon-link" />
<div uk-dropdown pos="left-bottom">
<p>
<span class="uk-text-bold">{{t "alexandria.document-details.version.filename"}}</span>
<br>
<span class="uk-text-break">{{file.name}}</span>
</p>
{{#if file.checksum}}
<p>
<span class="uk-text-bold">{{t "alexandria.document-details.version.checksum"}}</span>
<br>
<span class="uk-text-break">{{file.checksum}}</span>
</p>
{{/if}}
</div>
<a
uk-icon="download"
class="uk-icon-link"
data-test-file-download-link
href={{file.downloadUrl}}
target="_blank"
rel="noopener noreferrer"
>
<span hidden>{{t "alexandria.download"}}</span>
</a>
</span>
</li>
{{/each}}
</ul>
Expand Down
1 change: 1 addition & 0 deletions addon/models/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default class FileModel extends Model {
@attr downloadUrl;
@attr objectName;
@attr metainfo;
@attr checksum;

@attr createdAt;
@attr createdByUser;
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/mirage/factories/category.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default Factory.extend({

withDocuments: trait({
afterCreate(category, server) {
server.createList("document", 2, { category });
server.createList("document", 2, { category }, "withFiles");
},
}),
});
16 changes: 11 additions & 5 deletions tests/dummy/mirage/factories/document.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { faker } from "@faker-js/faker";
import { Factory } from "miragejs";
import { Factory, trait } from "miragejs";

import { setAllLocales } from "./helpers";

export default Factory.extend({
title: () => setAllLocales(faker.commerce.product()),
title: () => setAllLocales(faker.system.commonFileName()),
description: () => setAllLocales(faker.company.catchPhrase()),
createdByUser: () => faker.person.fullName(),
createdByGroup: () => faker.company.name(),
Expand All @@ -14,8 +14,14 @@ export default Factory.extend({
date: () => (Math.random() >= 0.5 ? faker.date.past() : null),

afterCreate(document, server) {
document.update({
tags: server.create("tag"),
});
document.update({ tags: server.create("tag") });
},

withFiles: trait({
afterCreate(document, server) {
server.createList("file", faker.number.int({ min: 1, max: 5 }), {
document,
});
},
}),
});
7 changes: 4 additions & 3 deletions tests/dummy/mirage/factories/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { faker } from "@faker-js/faker";
import { Factory } from "miragejs";

export default Factory.extend({
createdByUser: "dummy",
createdByGroup: "dummy-group",
createdByUser: () => faker.person.fullName(),
createdByGroup: () => faker.company.name(),
createdAt: () => faker.date.past(),
name: () => faker.lorem.word(),
name: () => faker.system.fileName(),
variant: "original",
uploadUrl: "/api/v1/file-upload",
downloadUrl: () => faker.internet.url(),
checksum: () => `sha256:${faker.git.commitSha({ length: 64 })}`,
});
3 changes: 3 additions & 0 deletions translations/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ alexandria:
tags:
title: "Tags"
add: "Hinzufügen"
version:
filename: "Dateiname"
checksum: "Checksumme"

document-download:
button: "{numDocs, plural, =1 {Herunterladen} other {Auswahl herunterladen}}"
Expand Down
3 changes: 3 additions & 0 deletions translations/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ alexandria:
tags:
title: "Tags"
add: "Add"
version:
filename: "Filename"
checksum: "Checksum"

document-download:
button: "{numDocs, plural, =1 {Download} other {Downlaod selection}}"
Expand Down

0 comments on commit 2419c4d

Please sign in to comment.