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

create EntryHistory component and place it in EntryDisplay #371

Merged
merged 87 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
ed68453
create EntryHistory component and place it in EntryDisplay
Danble Oct 25, 2023
0a1ff3c
create a history interface
Danble Oct 26, 2023
ba6faaf
show history records on lexeme page
Danble Oct 26, 2023
df0390b
add style
Danble Oct 26, 2023
df0dff7
small improve to interface
Danble Oct 26, 2023
fee3808
public updated message
Danble Oct 26, 2023
f0e9b23
add last updated message in SelectedDict component and create variant
Danble Oct 26, 2023
ae659c8
create History Page
Danble Oct 30, 2023
ee89763
create history variant
Danble Oct 30, 2023
135d56b
small details
Danble Oct 30, 2023
dc3ece7
add more records to history
Danble Oct 31, 2023
7fb6235
add more variants
Danble Oct 31, 2023
bebb17d
separate blocks of records by months
Danble Nov 1, 2023
d9fe88b
add select element
Danble Nov 1, 2023
ba69fac
Merge branch 'main' of github.com:livingtongues/living-dictionaries i…
Danble Nov 2, 2023
ec3587f
change history icon in sidebar
Danble Nov 2, 2023
d255bc2
add EntryHistory variants
Danble Nov 2, 2023
c242cfe
reorder mock dates
Danble Nov 2, 2023
c5273dd
fix broken variants
Danble Nov 3, 2023
7e5e476
prepare new interface
Danble Nov 3, 2023
3b8852a
Merge branch 'main' into history-tab-ui
jacob-8 Nov 4, 2023
cae2711
add Languages to variants
Danble Nov 7, 2023
2fd8007
Merge branch 'history-tab-ui' of github.com:livingtongues/living-dict…
Danble Nov 7, 2023
a600463
change History interface to Change interface
Danble Nov 8, 2023
c29f1af
Merge branch 'main' of github.com:livingtongues/living-dictionaries i…
Danble Nov 8, 2023
0e535ce
Merge branch 'main' of github.com:livingtongues/living-dictionaries i…
Danble Nov 9, 2023
eb873d4
use Change in every variant
Danble Nov 9, 2023
7745fc4
add sortByEditor
Danble Nov 9, 2023
2379675
TODO translations
Danble Nov 10, 2023
d0c3b30
create all sortBy functionality
Danble Nov 10, 2023
5b39858
refactor sortBy functions
Danble Nov 10, 2023
9bfd6be
rearrange of line in RecordsBlock
Danble Nov 15, 2023
8d193fc
highlight text depending upon selected sort by
Danble Nov 15, 2023
3a209f4
add missing lexeme highlighted
Danble Nov 15, 2023
4ed6ca7
fix small visual details
Danble Nov 15, 2023
0563c3b
Merge branch 'main' of github.com:livingtongues/living-dictionaries i…
Danble Dec 4, 2023
04c0586
update locales
Danble Dec 5, 2023
e113f68
change history UI display to a table
Danble Dec 5, 2023
0582380
Merge branch 'main' of github.com:livingtongues/living-dictionaries i…
Danble Dec 5, 2023
a3c2785
modify date to be very specific
Danble Dec 5, 2023
2d4a07e
small improve to history variant
Danble Dec 5, 2023
2ea4ce3
fix sortedRecords
Danble Dec 6, 2023
5e137e8
use new printDateTime helper function
Danble Dec 6, 2023
59cdcae
Merge branch 'main' of github.com:livingtongues/living-dictionaries i…
Danble Dec 6, 2023
a335766
create one getActionValues source
Danble Dec 7, 2023
a9fdb57
download history csv
Danble Dec 7, 2023
9f3e8d0
add missing semicolon
Danble Dec 7, 2023
a51c6e8
small updates to history table
jacob-8 Dec 7, 2023
6cd47b3
compute average score for lighthouse
jacob-8 Dec 7, 2023
eba0589
improve variant
Danble Dec 7, 2023
45b0a4e
add old and new values to table
Danble Dec 7, 2023
de05f94
update locales
Danble Dec 8, 2023
d8bf208
fix download
Danble Dec 8, 2023
d3ceed9
add fields to i18n
Danble Dec 8, 2023
9125c8b
small improvements
Danble Dec 11, 2023
1bbdb51
add new empty message i18n
Danble Dec 12, 2023
5d372fd
update locales
Danble Dec 13, 2023
4c13270
add styles to anchor tag
Danble Dec 13, 2023
283c4cd
add store to bold selected column
Danble Dec 13, 2023
05f2970
handle undefined values
Danble Dec 15, 2023
baaad0c
translate csv data
Danble Dec 15, 2023
8658e79
improve display of big text values
Danble Dec 15, 2023
a542fbb
Merge branch 'main' into history-tab-ui
Danble Jan 7, 2025
beea131
repair ESlint suggestions
Danble Jan 7, 2025
e7f4d16
update and fix history components
Danble Jan 8, 2025
5d17bd5
comment history variant
Danble Jan 8, 2025
2b5a67f
fix ESlint suggestions
Danble Jan 8, 2025
0cb0108
fix sortRecords file
Danble Jan 9, 2025
b41fa87
run ES lint over change interface
Danble Jan 9, 2025
5051a86
update build-citation tests
Danble Jan 9, 2025
33e4d93
Update he.json
jacob-8 Jan 16, 2025
5fd0752
Revert lighthouse-comment-formatter.cjs
jacob-8 Jan 16, 2025
536d678
Update lighthouse-comment-formatter.cjs
jacob-8 Jan 16, 2025
2357ea9
get content_updates data showing on history page and entry page
jacob-8 Jan 16, 2025
6737b02
Merge branch 'history-tab-ui' of github.com:livingtongues/living-dict…
jacob-8 Jan 16, 2025
092be6f
Merge branch 'main' of github.com:livingtongues/living-dictionaries i…
Danble Jan 21, 2025
b43f565
small test with new contaent updates data
Danble Jan 21, 2025
f575236
prepare to last changes
Danble Jan 22, 2025
8533870
Merge branch 'main' of github.com:livingtongues/living-dictionaries i…
Danble Jan 27, 2025
8885471
improvements after feedback
Danble Jan 28, 2025
6313809
update locales and fix history export
Danble Jan 29, 2025
cbc2549
small details
Danble Jan 29, 2025
69945b7
add date translation
Danble Jan 29, 2025
1f0beba
sort entrName by id
Danble Jan 30, 2025
fb89bf7
cleanup
jacob-8 Jan 30, 2025
7af2c0b
do date construction in time.ts
jacob-8 Jan 30, 2025
2794612
clean-up, add note
jacob-8 Jan 30, 2025
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
27 changes: 27 additions & 0 deletions .github/workflows/lighthouse-comment-formatter.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ const scoreSimple = (
function makeComment(lighthouseOutputs, targetPlatform) {
let comment = `## ⚡️Lighthouse report`;

if (targetPlatform === 'pr') {
comment += `
<details><summary>Average score across ${lighthouseOutputs.manifest.length} targets: <b>${computeAverageScore(lighthouseOutputs)}%</b></summary>
`
}

for (const manifest of lighthouseOutputs.manifest) {
const { url: testedUrl, summary } = manifest;
const reportUrl = lighthouseOutputs.links[testedUrl];
Expand All @@ -69,9 +75,30 @@ ${scoreRow('PWA', summary.pwa)}
}
}

if (targetPlatform === 'pr') {
comment += `
</details>`
}

return comment;
}

/**
* @param {LighthouseOutputs} lighthouseOutputs
* @return {string}
*/
function computeAverageScore(lighthouseOutputs) {
let totalScore = 0;
for (const manifest of lighthouseOutputs.manifest) {
const { summary } = manifest;
totalScore += summary.performance / 4;
totalScore += summary['best-practices'] / 4;
totalScore += summary.seo / 4;
totalScore += summary.pwa / 4;
}
return ((totalScore / lighthouseOutputs.manifest.length) * 100).toFixed(1);
}

module.exports = ({ lighthouseOutputs, targetPlatform }) => {
return makeComment(lighthouseOutputs, targetPlatform);
};
Expand Down
2 changes: 2 additions & 0 deletions packages/site/src/lib/components/home/SelectedDict.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sanitize from 'xss'
import { page } from '$app/stores'

export let lastFieldUpdatedAt: number = undefined
export let dictionary: IDictionary
let aboutType: IAbout

Expand Down Expand Up @@ -89,6 +90,7 @@
<span class="i-fa6-solid-chevron-right rtl-x-flip -mt-1" />
</Button>
{/if}
{#if lastFieldUpdatedAt}<p class="mt-3 text-xs text-gray-500">This dictionary was last updated on {new Date(lastFieldUpdatedAt).toString()}</p>{/if}
</div>

<style>
Expand Down
40 changes: 40 additions & 0 deletions packages/site/src/lib/components/home/SelectedDict.variants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// import type { Variant } from 'kitbook';
// import type Component from './SelectedDict.svelte';
// import type { IDictionary } from '@living-dictionaries/types';

// const dictionary: IDictionary = {
// 'updatedBy': 'U9u2OqBEArZSFV88Xu8TlvOWbbn1',
// 'regions': [],
// 'entryCount': 486,
// 'name': 'Achi',
// 'createdBy': 'T4qikh1eTafizvpmHNcG29uRQ2j1',
// 'points': [],
// 'location': 'Guatemala',
// 'alternateNames': [],
// 'glottocode': 'achi1256',
// 'iso6393': 'acr',
// 'glossLanguages': [
// 'es',
// 'en'
// ],
// 'public': true,
// 'id': 'achi',
// }

// export const variants: Variant<Component>[] = [
// {
// name: 'Normal',
// languages: [],
// props: {
// dictionary,
// }
// },
// {
// name: 'Displays last update',
// languages: [],
// props: {
// dictionary,
// lastFieldUpdatedAt: 1673598370158,
// }
// },
// ];
11 changes: 11 additions & 0 deletions packages/site/src/lib/helpers/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ export function printDate(date: Date | number): string {
}).format(date)
}

export function printDateTime(date: Date | number): string {
return new Intl.DateTimeFormat('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
}).format(date)
}

export function printDateWithWeekday(date: Date | number): string {
return new Intl.DateTimeFormat('en-US', {
weekday: 'long',
Expand Down
2 changes: 1 addition & 1 deletion packages/site/src/lib/i18n/locales/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@
"history": {
"history": "הִיסטוֹרִיָה",
"entry": "כְּנִיסָה",
"editor": "עוֹרֵך",
"editor": "עוֹרֵך"
"action": "פְּעוּלָה",
"field": "שָׂדֶה",
"date": "תַאֲרִיך",
Expand Down
2 changes: 1 addition & 1 deletion packages/site/src/lib/i18n/locales/ms.json
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@
"spreadsheet": "Hamparan"
},
"video": {
"video_url": "URL video",
"video_url": "URL Video",
"video_credit": "Kredit video",
"prepare_to_record_video": "Bersedia untuk Rakam dengan Mikrofon & Kamera",
"video_info": "Terdapat dua cara untuk memaparkan video anda dalam kamus yang hidup: 1) Anda boleh merakam video anda di sini, atau memuat naik video anda yang dirakam sebelumnya ke platform kami. Kelebihan: Mudah dan hebat untuk rakaman cepat. Kelemahan: Anda hanya boleh memuat naik video sehingga 100MB supaya ia hanya perlu resolusi pendek dan rendah. 2) Mempunyai video anda pada perkhidmatan hosting yang mengkhususkan diri dalam penyimpanan video dan menghubungkan URL ke laman web kami. Kelebihan: Mudah (selagi video anda sudah dimuat naik di platform itu), video anda boleh mempunyai resolusi dan panjang yang anda inginkan. Kelemahan: Jika anda ingin merakam sesuatu yang tidak dijangka atau sangat mudah, mungkin terlalu banyak usaha untuk melakukannya dengan cara itu, dan anda mungkin ingin mengutamakan Kaedah 1.",
Expand Down
11 changes: 11 additions & 0 deletions packages/site/src/routes/[dictionaryId]/SideMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
export let entry_count: number
export let on_close: () => void
export let is_manager: boolean
$: ({ can_edit } = $page.data)
</script>

<div class="md:hidden">
Expand Down Expand Up @@ -59,6 +60,16 @@
{$page.data.t('dictionary.contributors')}
</span>
</a>
{#if $can_edit}
<a
href={`/${dictionary.id}/history`}
class:active={$page.url.pathname.includes('history')}>
<i class="far fa-history fa-fw" />
<span class="font-medium mx-2">
{$page.data.t('history.history')}
</span>
</a>
{/if}
<a
href={`/${dictionary.id}/grammar`}
class:active={$page.url.pathname.includes('grammar')}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<script lang="ts">
import type { EntryFieldValue, EntryView, IDictionary, TablesUpdate } from '@living-dictionaries/types'
import type { Change, EntryFieldValue, EntryView, IDictionary, TablesUpdate } from '@living-dictionaries/types'
import { Button } from 'svelte-pieces'
import EntryField from './EntryField.svelte'
import EntryMedia from './EntryMedia.svelte'
import EntryHistory from './EntryHistory.svelte'
import Sense from './SupaSense.svelte'
import { page } from '$app/stores'
import EntryDialect from '$lib/components/entry/EntryDialect.svelte'
Expand All @@ -15,6 +16,7 @@
export let can_edit = false
export let videoAccess = false
export let dbOperations: DbOperations
export let history: Change[] = undefined

const text_fields = ['morphology', 'interlinearization'] satisfies EntryFieldValue[]

Expand All @@ -40,6 +42,7 @@

<div style="grid-area: media;">
<EntryMedia {dictionary} {entry} {can_edit} {videoAccess} {dbOperations} />
{#if history?.length > 0}<EntryHistory {history} {can_edit} class="mt-5 hidden md:block" />{/if}
</div>

<div class="flex flex-col grow" style="grid-area: content;">
Expand Down Expand Up @@ -169,6 +172,7 @@
</div>
</div>

{#if history?.length > 0}<EntryHistory {history} {can_edit} class="mt-3 md:hidden" />{/if}
<style>
.media-on-right-grid {
grid-template-columns: 3fr 1fr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@
// ],
// },
// },
// {
// 'latitude': 18.933437473181115,
// 'longitude': 83.04198437500133
// }
// ]
// }
// },
// {
// name: 'Local orthographies',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<script lang="ts">
import type { Change } from '@living-dictionaries/types'

export let history: Change[]
export let canEdit = false

const formatter = new Intl.DateTimeFormat('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
timeZoneName: 'short',
})
</script>

<div class="{$$props.class} text-gray-500">
{#if canEdit}
<!-- TODO translate -->
<strong>Lexeme history:</strong>
{#each history as record}
<p class="m-3">{record.updatedName} edited this entry on {formatter.format(new Date(record.updatedAtMs))}</p>
{/each}
{:else}
<p class="m-3">Last edited on {new Date(history[0].updatedAtMs).toDateString()}</p>
{/if}
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// import type { Variant } from 'kitbook';
// import type Component from './EntryHistory.svelte';
// import type { Change } from '@living-dictionaries/types';

// const history:Change[] = [
// {
// updatedBy: '0002',
// updatedName: 'Diego Córdova',
// entryName: 'Giraffe',
// entryId: '002',
// dictionaryId: 'banange',
// dictionaryName: 'Banange',
// previousValue: ['n'],
// currentValue: [],
// field: 'parts of speech',
// updatedAtMs: 1673598370158
// },
// {
// updatedBy: '0001',
// updatedName: 'Anna Luisa',
// entryName: 'Giraffe',
// entryId: '002',
// dictionaryId: 'banange',
// dictionaryName: 'Banange',
// previousValue: ['adj'],
// currentValue: ['n'],
// field: 'parts of speech',
// updatedAtMs: 1673238370158
// },
// {
// updatedBy: '0002',
// updatedName: 'Diego Córdova',
// entryName: 'Giraffe',
// entryId: '002',
// dictionaryId: 'banange',
// dictionaryName: 'Banange',
// previousValue: null,
// currentValue: ['adj'],
// field: 'parts of speech',
// updatedAtMs: 1669598370158
// },
// {
// updatedBy: '0001',
// updatedName: 'Anna Luisa',
// entryName: 'Giraffe',
// entryId: '002',
// dictionaryId: 'banange',
// dictionaryName: 'Banange',
// previousValue: 'Snake',
// currentValue: 'Giraffe',
// field: 'Lexeme',
// updatedAtMs: 1619598370128
// },
// ];

// export const variants: Variant<Component>[] = [
// {
// name: 'Lexeme history authorized',
// languages: [],
// props: {
// history,
// canEdit: true,
// },
// },
// {
// name: 'Lexeme history unauthorized',
// languages: [],
// props: {
// history,
// },
// },
// ];
65 changes: 65 additions & 0 deletions packages/site/src/routes/[dictionaryId]/history/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<script lang="ts">
import type { Change } from '@living-dictionaries/types'
import { Button, ResponsiveTable } from 'svelte-pieces'
import RecordRow from './RecordRow.svelte'
import SortRecords from './sortRecords.svelte'
import { getActionValue } from './getActionValue'
import Filter from '$lib/components/Filter.svelte'
import { downloadObjectsAsCSV } from '$lib/export/csv'
import { printDateTime } from '$lib/helpers/time'
import { page } from '$app/stores'

export let data
$: ({ dictionary, can_edit } = data)

function exportHistoryAsCSV(records: Change[]) {
const headers = {
entryName: $page.data.t('history.entry'),
updatedName: $page.data.t('history.editor'),
action: $page.data.t('history.action'),
previousValue: $page.data.t('history.old_value'),
currentValue: $page.data.t('history.new_value'),
field: $page.data.t('history.field'),
date: $page.data.t('history.date'),
}

const formattedUsers = records.map((record) => {
return {
entryName: record.entryName,
updatedName: record.updatedName,
action: $page.data.t(`history.${getActionValue(record)}`),
previousValue: JSON.stringify(record.previousValue),
currentValue: JSON.stringify(record.currentValue),
field: $page.data.t(`entry_field.${record.field}`),
date: printDateTime(record.updatedAtMs),
}
})

downloadObjectsAsCSV(headers, formattedUsers, `${$dictionary.id}-history`)
}
</script>

{#if can_edit}
{#if data.history?.length > 0}
<div class="sticky top-0 h-[calc(100vh-1.5rem)] z-2 relative flex flex-col">
<Filter items={data.history} let:filteredItems={filteredRecords} placeholder={$page.data.t('history.history_search')}>
<div slot="right">
<Button form="filled" color="black" class="flex items-center space-x-1" onclick={() => exportHistoryAsCSV(filteredRecords)}>
<i class="fas fa-download" />
<span class="hidden sm:inline">{$page.data.t('history.download_history')}</span>
</Button>
</div>
<div class="mb-1" />
<ResponsiveTable stickyColumn stickyHeading>
<SortRecords history={filteredRecords} let:sortedRecords>
{#each sortedRecords as record}
<RecordRow {record} />
{/each}
</SortRecords>
</ResponsiveTable>
</Filter>
</div>
{:else}
{$page.data.t('history.empty')}
{/if}
{/if}
13 changes: 13 additions & 0 deletions packages/site/src/routes/[dictionaryId]/history/+page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { getCollection } from 'sveltefirets'
import type { Change } from '@living-dictionaries/types'

export async function load({ params, parent }) {
await parent()
try {
const history = await getCollection<Change>(`dictionaries/${params.dictionaryId}/history`)
return { history }
} catch (err) {
console.error(err)
return { history: null }
}
}
Loading
Loading