From 49407e668fb3db65b719465a5bd7fed05cbebc20 Mon Sep 17 00:00:00 2001 From: Bartosz Prusinowski Date: Wed, 11 Oct 2023 11:40:38 +0200 Subject: [PATCH 01/25] style: Profile table adjustments --- app/login/components/login-menu.tsx | 2 +- app/login/components/profile-tables.tsx | 33 +++++++++++++++++-------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/app/login/components/login-menu.tsx b/app/login/components/login-menu.tsx index 84a4b0537..191e47d62 100644 --- a/app/login/components/login-menu.tsx +++ b/app/login/components/login-menu.tsx @@ -13,7 +13,7 @@ export const LoginMenu = () => { {user.name} - {" "} + ) : ( + )} + + ); +}; + type ProfileVisualizationsTableProps = { userConfigs: ParsedConfig[]; preview?: boolean; @@ -34,15 +65,15 @@ export const ProfileVisualizationsTable = ( props: ProfileVisualizationsTableProps ) => { const { userConfigs, preview, onShowAll } = props; - const rootClasses = useRootStyles(); return ( - - - My visualizations - + 0} + onShowAll={onShowAll} + > {userConfigs.length > 0 ? ( - + <> .MuiTableCell-root": { @@ -62,7 +93,7 @@ export const ProfileVisualizationsTable = ( ))} -
+ ) : ( No charts yet,{" "} @@ -72,18 +103,7 @@ export const ProfileVisualizationsTable = ( . )} - {preview && ( - - )} -
+ ); }; From 8d1c2c151d6cb3ff03a291d0f99a8a524a02fd2c Mon Sep 17 00:00:00 2001 From: Bartosz Prusinowski Date: Wed, 11 Oct 2023 16:53:39 +0200 Subject: [PATCH 14/25] feat: Add logic to remove configs from database --- app/db/config.ts | 18 ++++++++++++++++++ app/pages/api/config-remove.ts | 24 ++++++++++++++++++++++++ app/utils/chart-config/api.ts | 15 +++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 app/pages/api/config-remove.ts diff --git a/app/db/config.ts b/app/db/config.ts index 7f4a69d9f..659619c47 100644 --- a/app/db/config.ts +++ b/app/db/config.ts @@ -62,6 +62,24 @@ export const updateConfig = async ({ }); }; +/** + * Remove config from the DB. + * Only valid for logged in users. + * + * @param key Key of the config to be updated + */ +export const removeConfig = async ({ + key, +}: { + key: string; +}): Promise<{ key: string }> => { + return await prisma.config.delete({ + where: { + key, + }, + }); +}; + const migrateDataSet = (dataSet: string): string => { if (dataSet.includes("https://environment.ld.admin.ch/foen/nfi")) { return dataSet.replace(/None-None-/, ""); diff --git a/app/pages/api/config-remove.ts b/app/pages/api/config-remove.ts new file mode 100644 index 000000000..c59d069af --- /dev/null +++ b/app/pages/api/config-remove.ts @@ -0,0 +1,24 @@ +import { getServerSession } from "next-auth"; + +import { removeConfig } from "@/db/config"; + +import { api } from "../../server/nextkit"; + +import { nextAuthOptions } from "./auth/[...nextauth]"; + +const route = api({ + POST: async ({ req, res }) => { + const session = await getServerSession(req, res, nextAuthOptions); + const serverUserId = session?.user?.id; + const { key, userId } = req.body; + console.log(key, userId, serverUserId); + + if (serverUserId !== userId) { + throw new Error("Unauthorized!"); + } + + return await removeConfig({ key }); + }, +}); + +export default route; diff --git a/app/utils/chart-config/api.ts b/app/utils/chart-config/api.ts index dececca95..cd15ded75 100644 --- a/app/utils/chart-config/api.ts +++ b/app/utils/chart-config/api.ts @@ -62,6 +62,21 @@ export const updateConfig = async ( ); }; +export const removeConfig = async (options: UpdateConfigOptions) => { + const { key, userId } = options; + + return apiFetch>( + "/api/config-remove", + { + method: "POST", + data: { + key, + userId, + }, + } + ); +}; + export const fetchChartConfig = async (id: string) => { return await apiFetch>( `/api/config/${id}` From 80338dbabde388c7a68f2908bbccdb93a5ca1321 Mon Sep 17 00:00:00 2001 From: Bartosz Prusinowski Date: Wed, 11 Oct 2023 16:57:27 +0200 Subject: [PATCH 15/25] fix: Keep locale when using browse button (user profile) --- app/login/components/profile-header.tsx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/app/login/components/profile-header.tsx b/app/login/components/profile-header.tsx index 5d9c6e8ac..a9685ecdb 100644 --- a/app/login/components/profile-header.tsx +++ b/app/login/components/profile-header.tsx @@ -3,6 +3,7 @@ import { makeStyles } from "@mui/styles"; import { User } from "@prisma/client"; import clsx from "clsx"; import { signOut } from "next-auth/react"; +import NextLink from "next/link"; import { useRootStyles } from "@/login/utils"; @@ -35,8 +36,8 @@ export const ProfileHeader = (props: ProfileHeaderProps) => { {user.name} - + + + + )} + + ); +}; From 3b0865cd9ab100225e5f039fc5014336b0dc9473 Mon Sep 17 00:00:00 2001 From: Bartosz Prusinowski Date: Thu, 12 Oct 2023 12:54:10 +0200 Subject: [PATCH 21/25] chore: Add translations --- app/browser/dataset-browse.tsx | 2 +- app/locales/de/messages.po | 91 ++++++++++++++++ app/locales/en/messages.po | 91 ++++++++++++++++ app/locales/fr/messages.po | 91 ++++++++++++++++ app/locales/it/messages.po | 91 ++++++++++++++++ app/login/components/profile-content-tabs.tsx | 26 ++++- app/login/components/profile-tables.tsx | 100 +++++++++++------- 7 files changed, 451 insertions(+), 41 deletions(-) diff --git a/app/browser/dataset-browse.tsx b/app/browser/dataset-browse.tsx index b8f8f1df5..ded0dee85 100644 --- a/app/browser/dataset-browse.tsx +++ b/app/browser/dataset-browse.tsx @@ -592,7 +592,7 @@ const NavSection = ({ color="inherit" onClick={open} > - Show all + Show all )} diff --git a/app/locales/de/messages.po b/app/locales/de/messages.po index 1512f3325..1d61fba6c 100644 --- a/app/locales/de/messages.po +++ b/app/locales/de/messages.po @@ -17,6 +17,10 @@ msgstr "" msgid "Add filter" msgstr "Filter hinzufügen" +#: app/configurator/components/chart-options-selector.tsx +msgid "Axis orientation" +msgstr "Achsenausrichtung" + #: app/configurator/components/chart-configurator.tsx msgid "Drag filters to reorganize" msgstr "Ziehen Sie die Filter per Drag & Drop, um sie neu zu organisieren" @@ -239,6 +243,18 @@ msgstr "Balken" msgid "controls.chart.type.column" msgstr "Säulen" +#: app/configurator/components/field-i18n.ts +msgid "controls.chart.type.comboLineColumn" +msgstr "Column-line" + +#: app/configurator/components/field-i18n.ts +msgid "controls.chart.type.comboLineDual" +msgstr "Dual-axis line" + +#: app/configurator/components/field-i18n.ts +msgid "controls.chart.type.comboLineSingle" +msgstr "Multi-line" + #: app/configurator/components/field-i18n.ts msgid "controls.chart.type.line" msgstr "Linien" @@ -481,6 +497,7 @@ msgstr "Zurück zur Übersicht" msgid "controls.nav.back-to-preview" msgstr "Zurück zur Vorschau" +#: app/configurator/components/chart-options-selector.tsx #: app/configurator/components/field.tsx #: app/configurator/components/field.tsx msgid "controls.none" @@ -735,6 +752,7 @@ msgstr "Filter anwenden" msgid "controls.size" msgstr "Grösse" +#: app/configurator/components/chart-options-selector.tsx #: app/configurator/table/table-chart-sorting-options.tsx msgid "controls.sorting.addDimension" msgstr "Dimension hinzufügen" @@ -1068,6 +1086,66 @@ msgstr "Filter ausblenden" msgid "interactive.data.filters.show" msgstr "Filter anzeigen" +#: app/login/components/profile-tables.tsx +msgid "login.chart.copy" +msgstr "Kopieren" + +#: app/login/components/profile-tables.tsx +msgid "login.chart.delete" +msgstr "Löschen" + +#: app/login/components/profile-tables.tsx +msgid "login.chart.delete.confirmation" +msgstr "Sind Sie sicher, dass Sie diese Grafik löschen wollen?" + +#: app/login/components/profile-tables.tsx +msgid "login.chart.edit" +msgstr "Bearbeiten" + +#: app/login/components/profile-tables.tsx +msgid "login.chart.share" +msgstr "Teilen" + +#: app/login/components/profile-tables.tsx +msgid "login.create-chart" +msgstr "erstellen Sie einen" + +#: app/login/components/profile-tables.tsx +msgid "login.no-charts" +msgstr "Noch keine Charts" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.chart.confirmation.default" +msgstr "Sind Sie sicher, dass Sie diese Aktion durchführen wollen?" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.chart.delete.warning" +msgstr "Denken Sie daran, dass das Entfernen dieser Visualisierung sich auf alle Stellen auswirkt, an denen sie möglicherweise bereits eingebettet ist!" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations" +msgstr "Meine Visualisierungen" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations.chart-actions" +msgstr "Aktionen" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations.chart-name" +msgstr "Name" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations.chart-published-date" +msgstr "Veröffentlicht" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations.chart-type" +msgstr "Typ" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations.dataset-name" +msgstr "Datensatz" + #: app/components/header.tsx #: app/components/header.tsx msgid "logo.swiss.confederation" @@ -1093,6 +1171,10 @@ msgstr "Zur Diagrammansicht wechseln" msgid "metadata.switch.table" msgstr "Zur Tabellenansicht wechseln" +#: app/login/components/profile-tables.tsx +msgid "no" +msgstr "Nein" + #: app/components/publish-actions.tsx msgid "publication.embed.AEM" msgstr "Einbett-Code für AEM «Externe Applikation»" @@ -1162,6 +1244,11 @@ msgstr "Suche" msgid "select.controls.metadata.search" msgstr "Springen zu..." +#: app/browser/dataset-browse.tsx +#: app/login/components/profile-tables.tsx +msgid "show.all" +msgstr "Alle anzeigen" + #: app/configurator/components/chart-controls/drag-and-drop-tab.tsx msgid "table.column.no" msgstr "Spalte {0}" @@ -1171,3 +1258,7 @@ msgstr "Spalte {0}" #: app/components/chart-footnotes.tsx msgid "typography.colon" msgstr ": " + +#: app/login/components/profile-tables.tsx +msgid "yes" +msgstr "Ja" diff --git a/app/locales/en/messages.po b/app/locales/en/messages.po index d1eb04374..4e53f0a0a 100644 --- a/app/locales/en/messages.po +++ b/app/locales/en/messages.po @@ -17,6 +17,10 @@ msgstr "" msgid "Add filter" msgstr "Add filter" +#: app/configurator/components/chart-options-selector.tsx +msgid "Axis orientation" +msgstr "Axis orientation" + #: app/configurator/components/chart-configurator.tsx msgid "Drag filters to reorganize" msgstr "Drag filters to reorganize" @@ -239,6 +243,18 @@ msgstr "Bars" msgid "controls.chart.type.column" msgstr "Columns" +#: app/configurator/components/field-i18n.ts +msgid "controls.chart.type.comboLineColumn" +msgstr "Column-line" + +#: app/configurator/components/field-i18n.ts +msgid "controls.chart.type.comboLineDual" +msgstr "Dual-axis line" + +#: app/configurator/components/field-i18n.ts +msgid "controls.chart.type.comboLineSingle" +msgstr "Multi-line" + #: app/configurator/components/field-i18n.ts msgid "controls.chart.type.line" msgstr "Lines" @@ -481,6 +497,7 @@ msgstr "Back to main" msgid "controls.nav.back-to-preview" msgstr "Back to preview" +#: app/configurator/components/chart-options-selector.tsx #: app/configurator/components/field.tsx #: app/configurator/components/field.tsx msgid "controls.none" @@ -735,6 +752,7 @@ msgstr "Apply filters" msgid "controls.size" msgstr "Size" +#: app/configurator/components/chart-options-selector.tsx #: app/configurator/table/table-chart-sorting-options.tsx msgid "controls.sorting.addDimension" msgstr "Add dimension" @@ -1068,6 +1086,66 @@ msgstr "Hide Filters" msgid "interactive.data.filters.show" msgstr "Show Filters" +#: app/login/components/profile-tables.tsx +msgid "login.chart.copy" +msgstr "Copy" + +#: app/login/components/profile-tables.tsx +msgid "login.chart.delete" +msgstr "Delete" + +#: app/login/components/profile-tables.tsx +msgid "login.chart.delete.confirmation" +msgstr "Are you sure you want to delete this chart?" + +#: app/login/components/profile-tables.tsx +msgid "login.chart.edit" +msgstr "Edit" + +#: app/login/components/profile-tables.tsx +msgid "login.chart.share" +msgstr "Share" + +#: app/login/components/profile-tables.tsx +msgid "login.create-chart" +msgstr "create one" + +#: app/login/components/profile-tables.tsx +msgid "login.no-charts" +msgstr "No charts yet" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.chart.confirmation.default" +msgstr "Are you sure you want to perform this action?" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.chart.delete.warning" +msgstr "Keep in mind that removing this visualization will affect all the places where it might be already embedded!" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations" +msgstr "My visualizations" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations.chart-actions" +msgstr "Actions" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations.chart-name" +msgstr "Name" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations.chart-published-date" +msgstr "Published" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations.chart-type" +msgstr "Type" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations.dataset-name" +msgstr "Dataset" + #: app/components/header.tsx #: app/components/header.tsx msgid "logo.swiss.confederation" @@ -1093,6 +1171,10 @@ msgstr "Switch to chart view" msgid "metadata.switch.table" msgstr "Switch to table view" +#: app/login/components/profile-tables.tsx +msgid "no" +msgstr "No" + #: app/components/publish-actions.tsx msgid "publication.embed.AEM" msgstr "Embed Code for AEM \"External Application\"" @@ -1162,6 +1244,11 @@ msgstr "Search" msgid "select.controls.metadata.search" msgstr "Jump to..." +#: app/browser/dataset-browse.tsx +#: app/login/components/profile-tables.tsx +msgid "show.all" +msgstr "Show all" + #: app/configurator/components/chart-controls/drag-and-drop-tab.tsx msgid "table.column.no" msgstr "Column {0}" @@ -1171,3 +1258,7 @@ msgstr "Column {0}" #: app/components/chart-footnotes.tsx msgid "typography.colon" msgstr ": " + +#: app/login/components/profile-tables.tsx +msgid "yes" +msgstr "Yes" diff --git a/app/locales/fr/messages.po b/app/locales/fr/messages.po index c358b0150..e6d35e4a3 100644 --- a/app/locales/fr/messages.po +++ b/app/locales/fr/messages.po @@ -17,6 +17,10 @@ msgstr "" msgid "Add filter" msgstr "Ajouter un filtre" +#: app/configurator/components/chart-options-selector.tsx +msgid "Axis orientation" +msgstr "Orientation de l'axe" + #: app/configurator/components/chart-configurator.tsx msgid "Drag filters to reorganize" msgstr "Faites glisser les filtres pour les réorganiser" @@ -239,6 +243,18 @@ msgstr "Barres" msgid "controls.chart.type.column" msgstr "Colonnes" +#: app/configurator/components/field-i18n.ts +msgid "controls.chart.type.comboLineColumn" +msgstr "Column-line" + +#: app/configurator/components/field-i18n.ts +msgid "controls.chart.type.comboLineDual" +msgstr "Dual-axis line" + +#: app/configurator/components/field-i18n.ts +msgid "controls.chart.type.comboLineSingle" +msgstr "Multi-line" + #: app/configurator/components/field-i18n.ts msgid "controls.chart.type.line" msgstr "Lignes" @@ -481,6 +497,7 @@ msgstr "Retour aux paramètres généraux" msgid "controls.nav.back-to-preview" msgstr "Retour à l'aperçu" +#: app/configurator/components/chart-options-selector.tsx #: app/configurator/components/field.tsx #: app/configurator/components/field.tsx msgid "controls.none" @@ -735,6 +752,7 @@ msgstr "Appliquer les filtres" msgid "controls.size" msgstr "Taille" +#: app/configurator/components/chart-options-selector.tsx #: app/configurator/table/table-chart-sorting-options.tsx msgid "controls.sorting.addDimension" msgstr "Ajouter une dimension" @@ -1068,6 +1086,66 @@ msgstr "Masquer les filtres" msgid "interactive.data.filters.show" msgstr "Afficher les filtres" +#: app/login/components/profile-tables.tsx +msgid "login.chart.copy" +msgstr "Copie" + +#: app/login/components/profile-tables.tsx +msgid "login.chart.delete" +msgstr "Supprimer" + +#: app/login/components/profile-tables.tsx +msgid "login.chart.delete.confirmation" +msgstr "Êtes-vous sûr de vouloir supprimer cette carte ?" + +#: app/login/components/profile-tables.tsx +msgid "login.chart.edit" +msgstr "Editer" + +#: app/login/components/profile-tables.tsx +msgid "login.chart.share" +msgstr "Partager" + +#: app/login/components/profile-tables.tsx +msgid "login.create-chart" +msgstr "créez-en un" + +#: app/login/components/profile-tables.tsx +msgid "login.no-charts" +msgstr "Pas encore de graphiques" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.chart.confirmation.default" +msgstr "Êtes-vous sûr de vouloir effectuer cette action ?" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.chart.delete.warning" +msgstr "Gardez à l'esprit que la suppression de cette visualisation affectera tous les endroits où elle est déjà intégrée !" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations" +msgstr "Mes visualisations" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations.chart-actions" +msgstr "Actions" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations.chart-name" +msgstr "Nom" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations.chart-published-date" +msgstr "Publié" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations.chart-type" +msgstr "Type" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations.dataset-name" +msgstr "Ensemble de données" + #: app/components/header.tsx #: app/components/header.tsx msgid "logo.swiss.confederation" @@ -1093,6 +1171,10 @@ msgstr "Passer à la vue graphique" msgid "metadata.switch.table" msgstr "Passer à la vue en tableau" +#: app/login/components/profile-tables.tsx +msgid "no" +msgstr "Non" + #: app/components/publish-actions.tsx msgid "publication.embed.AEM" msgstr "Code pour intégrer sur AEM comme \"External Application\"" @@ -1162,6 +1244,11 @@ msgstr "Chercher" msgid "select.controls.metadata.search" msgstr "Sauter à..." +#: app/browser/dataset-browse.tsx +#: app/login/components/profile-tables.tsx +msgid "show.all" +msgstr "Tout afficher" + #: app/configurator/components/chart-controls/drag-and-drop-tab.tsx msgid "table.column.no" msgstr "Colonne {0}" @@ -1171,3 +1258,7 @@ msgstr "Colonne {0}" #: app/components/chart-footnotes.tsx msgid "typography.colon" msgstr " : " + +#: app/login/components/profile-tables.tsx +msgid "yes" +msgstr "Oui" diff --git a/app/locales/it/messages.po b/app/locales/it/messages.po index 9cc5a8572..677342604 100644 --- a/app/locales/it/messages.po +++ b/app/locales/it/messages.po @@ -17,6 +17,10 @@ msgstr "" msgid "Add filter" msgstr "Aggiungi filtro" +#: app/configurator/components/chart-options-selector.tsx +msgid "Axis orientation" +msgstr "Orientamento dell'asse" + #: app/configurator/components/chart-configurator.tsx msgid "Drag filters to reorganize" msgstr "Trascina i filtri per riorganizzarli" @@ -239,6 +243,18 @@ msgstr "Barre" msgid "controls.chart.type.column" msgstr "Colonne" +#: app/configurator/components/field-i18n.ts +msgid "controls.chart.type.comboLineColumn" +msgstr "Column-line" + +#: app/configurator/components/field-i18n.ts +msgid "controls.chart.type.comboLineDual" +msgstr "Dual-axis line" + +#: app/configurator/components/field-i18n.ts +msgid "controls.chart.type.comboLineSingle" +msgstr "Multi-line" + #: app/configurator/components/field-i18n.ts msgid "controls.chart.type.line" msgstr "Linee" @@ -481,6 +497,7 @@ msgstr "Torna alle impostazioni generali" msgid "controls.nav.back-to-preview" msgstr "Torna all'anteprima" +#: app/configurator/components/chart-options-selector.tsx #: app/configurator/components/field.tsx #: app/configurator/components/field.tsx msgid "controls.none" @@ -735,6 +752,7 @@ msgstr "Appliquer les filtres" msgid "controls.size" msgstr "Grandezza" +#: app/configurator/components/chart-options-selector.tsx #: app/configurator/table/table-chart-sorting-options.tsx msgid "controls.sorting.addDimension" msgstr "Aggiungi una dimensione" @@ -1068,6 +1086,66 @@ msgstr "Nascondi i filtri" msgid "interactive.data.filters.show" msgstr "Mostra i filtri" +#: app/login/components/profile-tables.tsx +msgid "login.chart.copy" +msgstr "Copia" + +#: app/login/components/profile-tables.tsx +msgid "login.chart.delete" +msgstr "Cancellare" + +#: app/login/components/profile-tables.tsx +msgid "login.chart.delete.confirmation" +msgstr "Sei sicuro di voler cancellare questo grafico?" + +#: app/login/components/profile-tables.tsx +msgid "login.chart.edit" +msgstr "Modifica" + +#: app/login/components/profile-tables.tsx +msgid "login.chart.share" +msgstr "Condividi" + +#: app/login/components/profile-tables.tsx +msgid "login.create-chart" +msgstr "creane uno" + +#: app/login/components/profile-tables.tsx +msgid "login.no-charts" +msgstr "Non ci sono ancora grafici" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.chart.confirmation.default" +msgstr "Siete sicuri di voler eseguire questa azione?" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.chart.delete.warning" +msgstr "Tenete presente che la rimozione di questa visualizzazione avrà effetto su tutti i luoghi in cui potrebbe essere già incorporata!" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations" +msgstr "Le mie visualizzazioni" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations.chart-actions" +msgstr "Azioni" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations.chart-name" +msgstr "Nome" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations.chart-published-date" +msgstr "Pubblicato" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations.chart-type" +msgstr "Tipo" + +#: app/login/components/profile-tables.tsx +msgid "login.profile.my-visualizations.dataset-name" +msgstr "Set di dati" + #: app/components/header.tsx #: app/components/header.tsx msgid "logo.swiss.confederation" @@ -1093,6 +1171,10 @@ msgstr "Passare alla visualizzazione del grafico" msgid "metadata.switch.table" msgstr "Passare alla vista tabella" +#: app/login/components/profile-tables.tsx +msgid "no" +msgstr "No" + #: app/components/publish-actions.tsx msgid "publication.embed.AEM" msgstr "Codice da incorporare su AEM come \"External Application\"" @@ -1162,6 +1244,11 @@ msgstr "Cerca" msgid "select.controls.metadata.search" msgstr "Salta a..." +#: app/browser/dataset-browse.tsx +#: app/login/components/profile-tables.tsx +msgid "show.all" +msgstr "Mostra tutti" + #: app/configurator/components/chart-controls/drag-and-drop-tab.tsx msgid "table.column.no" msgstr "Colonna {0}" @@ -1171,3 +1258,7 @@ msgstr "Colonna {0}" #: app/components/chart-footnotes.tsx msgid "typography.colon" msgstr ": " + +#: app/login/components/profile-tables.tsx +msgid "yes" +msgstr "Sì" diff --git a/app/login/components/profile-content-tabs.tsx b/app/login/components/profile-content-tabs.tsx index ebbf2c1b8..69dd9ce43 100644 --- a/app/login/components/profile-content-tabs.tsx +++ b/app/login/components/profile-content-tabs.tsx @@ -1,3 +1,4 @@ +import { t } from "@lingui/macro"; import { TabContext, TabList, TabPanel } from "@mui/lab"; import { Box, Tab, Theme } from "@mui/material"; import { makeStyles } from "@mui/styles"; @@ -55,7 +56,13 @@ export const ProfileContentTabs = (props: ProfileContentTabsProps) => { - {["Home", "My visualizations"].map((d) => ( + {[ + "Home", + t({ + id: "login.profile.my-visualizations", + message: "My visualizations", + }), + ].map((d) => ( ))} @@ -72,11 +79,24 @@ export const ProfileContentTabs = (props: ProfileContentTabsProps) => { userConfigs={userConfigs} setUserConfigs={setUserConfigs} preview - onShowAll={() => setValue("My visualizations")} + onShowAll={() => + setValue( + t({ + id: "login.profile.my-visualizations", + message: "My visualizations", + }) + ) + } /> - + { onClick={onShowAll} sx={{ ml: 1, mt: 2 }} > - Show all + + Show all + )} @@ -85,8 +88,10 @@ export const ProfileVisualizationsTable = ( return ( PREVIEW_LIMIT} onShowAll={onShowAll} > @@ -100,12 +105,31 @@ export const ProfileVisualizationsTable = ( }, }} > - {/* TODO: translate */} - Type - Name - Dataset - Published - Actions + + + Type + + + + + Name + + + + + Dataset + + + + + Published + + + + + Actions + + {userConfigs @@ -122,10 +146,9 @@ export const ProfileVisualizationsTable = ( ) : ( - {/* TODO: translate */} - No charts yet,{" "} + No charts yet,{" "} - create one + create one . @@ -157,18 +180,30 @@ const ProfileVisualizationsRow = (props: ProfileVisualizationsRowProps) => { { type: "link", href: `/create/new?copy=${config.key}`, - // TODO: translate - label: "Copy", + label: t({ id: "login.chart.copy", message: "Copy" }), iconName: "copy", }, + { + type: "link", + href: `/create/new?edit=${config.key}`, + label: t({ id: "login.chart.edit", message: "Edit" }), + iconName: "edit", + }, + { + type: "link", + href: `/v/${config.key}`, + label: t({ id: "login.chart.share", message: "Share" }), + iconName: "linkExternal", + }, { type: "button", - // TODO: translate - label: "Delete", + label: t({ id: "login.chart.delete", message: "Delete" }), iconName: "trash", requireConfirmation: true, - // TODO: translate - confirmationText: "Are you sure you want to delete this chart?", + confirmationText: t({ + id: "login.chart.delete.confirmation", + message: "Are you sure you want to delete this chart?", + }), onClick: async () => { await removeConfig({ key: config.key, userId }); }, @@ -176,18 +211,6 @@ const ProfileVisualizationsRow = (props: ProfileVisualizationsRowProps) => { onRemoveSuccess(config.key); }, }, - { - type: "link", - href: `/create/new?edit=${config.key}`, - label: "Edit", - iconName: "edit", - }, - { - type: "link", - href: `/v/${config.key}`, - label: "Share", - iconName: "linkExternal", - }, ]; return actions; @@ -381,16 +404,19 @@ const ActionButton = (props: ActionButtonProps) => { > - {/* TODO: translate */} {confirmationText ?? - "Are you sure you want to perform this action?"} + t({ + id: "login.profile.chart.confirmation.default", + message: "Are you sure you want to perform this action?", + })} - {/* TODO: translate */} - Keep in mind that removing this visualization will affect all the - places where it might be already embedded! + + Keep in mind that removing this visualization will affect all + the places where it might be already embedded! + { }} > From 9ebb3adc85bfc42ddeecda8c8eb293a8f4817442 Mon Sep 17 00:00:00 2001 From: Bartosz Prusinowski Date: Thu, 12 Oct 2023 12:55:40 +0200 Subject: [PATCH 22/25] docs: Update CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52ca022d8..0c303d46c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ You can also check the [release page](https://github.com/visualize-admin/visuali - Features - Added a new group of charts – Combo charts – that includes multi-measure line, dual-axis line and column-line charts + - Added a way to edit and remove charts for logged in users + - Improved user profile page # [3.22.9] - 2023-10-06 From ec2b57ae3876dd8ea6dfbf57bfbeec2bb90396f2 Mon Sep 17 00:00:00 2001 From: Bartosz Prusinowski Date: Thu, 12 Oct 2023 13:02:21 +0200 Subject: [PATCH 23/25] chore: Translate browse all datasets button --- app/locales/de/messages.po | 7 ++++++ app/locales/en/messages.po | 7 ++++++ app/locales/fr/messages.po | 7 ++++++ app/locales/it/messages.po | 7 ++++++ app/login/components/profile-header.tsx | 31 +++++++++++++------------ 5 files changed, 44 insertions(+), 15 deletions(-) diff --git a/app/locales/de/messages.po b/app/locales/de/messages.po index 1d61fba6c..22d74d0b8 100644 --- a/app/locales/de/messages.po +++ b/app/locales/de/messages.po @@ -54,6 +54,10 @@ msgstr "Organisationen" msgid "browse-panel.themes" msgstr "Kategorien" +#: app/login/components/profile-header.tsx +msgid "browse.dataset.all" +msgstr "Alle Datensätze durchsuchen" + #: app/browser/dataset-preview.tsx msgid "browse.dataset.create-visualization" msgstr "Visualisierung von diesem Datensatz erstellen" @@ -1122,6 +1126,9 @@ msgstr "Sind Sie sicher, dass Sie diese Aktion durchführen wollen?" msgid "login.profile.chart.delete.warning" msgstr "Denken Sie daran, dass das Entfernen dieser Visualisierung sich auf alle Stellen auswirkt, an denen sie möglicherweise bereits eingebettet ist!" +#: app/login/components/profile-content-tabs.tsx +#: app/login/components/profile-content-tabs.tsx +#: app/login/components/profile-content-tabs.tsx #: app/login/components/profile-tables.tsx msgid "login.profile.my-visualizations" msgstr "Meine Visualisierungen" diff --git a/app/locales/en/messages.po b/app/locales/en/messages.po index 4e53f0a0a..05630f96c 100644 --- a/app/locales/en/messages.po +++ b/app/locales/en/messages.po @@ -54,6 +54,10 @@ msgstr "Organizations" msgid "browse-panel.themes" msgstr "Categories" +#: app/login/components/profile-header.tsx +msgid "browse.dataset.all" +msgstr "Browse all datasets" + #: app/browser/dataset-preview.tsx msgid "browse.dataset.create-visualization" msgstr "Start a visualization" @@ -1122,6 +1126,9 @@ msgstr "Are you sure you want to perform this action?" msgid "login.profile.chart.delete.warning" msgstr "Keep in mind that removing this visualization will affect all the places where it might be already embedded!" +#: app/login/components/profile-content-tabs.tsx +#: app/login/components/profile-content-tabs.tsx +#: app/login/components/profile-content-tabs.tsx #: app/login/components/profile-tables.tsx msgid "login.profile.my-visualizations" msgstr "My visualizations" diff --git a/app/locales/fr/messages.po b/app/locales/fr/messages.po index e6d35e4a3..b125e868f 100644 --- a/app/locales/fr/messages.po +++ b/app/locales/fr/messages.po @@ -54,6 +54,10 @@ msgstr "Organisations" msgid "browse-panel.themes" msgstr "Catégories" +#: app/login/components/profile-header.tsx +msgid "browse.dataset.all" +msgstr "Parcourir tous les ensembles de données" + #: app/browser/dataset-preview.tsx msgid "browse.dataset.create-visualization" msgstr "Démarrer une visualisation" @@ -1122,6 +1126,9 @@ msgstr "Êtes-vous sûr de vouloir effectuer cette action ?" msgid "login.profile.chart.delete.warning" msgstr "Gardez à l'esprit que la suppression de cette visualisation affectera tous les endroits où elle est déjà intégrée !" +#: app/login/components/profile-content-tabs.tsx +#: app/login/components/profile-content-tabs.tsx +#: app/login/components/profile-content-tabs.tsx #: app/login/components/profile-tables.tsx msgid "login.profile.my-visualizations" msgstr "Mes visualisations" diff --git a/app/locales/it/messages.po b/app/locales/it/messages.po index 677342604..117c2ac54 100644 --- a/app/locales/it/messages.po +++ b/app/locales/it/messages.po @@ -54,6 +54,10 @@ msgstr "Organizzazioni" msgid "browse-panel.themes" msgstr "Categorie" +#: app/login/components/profile-header.tsx +msgid "browse.dataset.all" +msgstr "Sfoglia tutti i set di dati" + #: app/browser/dataset-preview.tsx msgid "browse.dataset.create-visualization" msgstr "Iniziare una visualizzazione" @@ -1122,6 +1126,9 @@ msgstr "Siete sicuri di voler eseguire questa azione?" msgid "login.profile.chart.delete.warning" msgstr "Tenete presente che la rimozione di questa visualizzazione avrà effetto su tutti i luoghi in cui potrebbe essere già incorporata!" +#: app/login/components/profile-content-tabs.tsx +#: app/login/components/profile-content-tabs.tsx +#: app/login/components/profile-content-tabs.tsx #: app/login/components/profile-tables.tsx msgid "login.profile.my-visualizations" msgstr "Le mie visualizzazioni" diff --git a/app/login/components/profile-header.tsx b/app/login/components/profile-header.tsx index a9685ecdb..2de39841c 100644 --- a/app/login/components/profile-header.tsx +++ b/app/login/components/profile-header.tsx @@ -1,3 +1,4 @@ +import { Trans } from "@lingui/macro"; import { Box, Button, Link, Theme, Typography } from "@mui/material"; import { makeStyles } from "@mui/styles"; import { User } from "@prisma/client"; @@ -36,9 +37,7 @@ export const ProfileHeader = (props: ProfileHeaderProps) => { {user.name} - + ); }; From 32d593eb89c0f8fbcb4657ef324bc9461c5112a6 Mon Sep 17 00:00:00 2001 From: Bartosz Prusinowski Date: Thu, 12 Oct 2023 13:04:38 +0200 Subject: [PATCH 24/25] chore: Remove unused --- app/login/components/profile-tables.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/login/components/profile-tables.tsx b/app/login/components/profile-tables.tsx index e1e9eea75..72ff2e3cd 100644 --- a/app/login/components/profile-tables.tsx +++ b/app/login/components/profile-tables.tsx @@ -275,10 +275,9 @@ const Actions = (props: ActionsProps) => { const { actions } = props; const buttonRef = React.useRef(null); const { isOpen, open, close } = useDisclosure(); - const clickAwayListenerRef = React.useRef(null); return ( - + Date: Thu, 12 Oct 2023 13:07:12 +0200 Subject: [PATCH 25/25] refactor: Separate confirmation title and text --- app/login/components/profile-tables.tsx | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/app/login/components/profile-tables.tsx b/app/login/components/profile-tables.tsx index 72ff2e3cd..f0f4e239a 100644 --- a/app/login/components/profile-tables.tsx +++ b/app/login/components/profile-tables.tsx @@ -200,10 +200,15 @@ const ProfileVisualizationsRow = (props: ProfileVisualizationsRowProps) => { label: t({ id: "login.chart.delete", message: "Delete" }), iconName: "trash", requireConfirmation: true, - confirmationText: t({ + confirmationTitle: t({ id: "login.chart.delete.confirmation", message: "Are you sure you want to delete this chart?", }), + confirmationText: t({ + id: "login.profile.chart.delete.warning", + message: + "Keep in mind that removing this visualization will affect all the places where it might be already embedded!", + }), onClick: async () => { await removeConfig({ key: config.key, userId }); }, @@ -350,6 +355,7 @@ type ActionButtonProps = { label: string; iconName: IconName; requireConfirmation?: boolean; + confirmationTitle?: string; confirmationText?: string; onClick: () => Promise; onDialogClose?: () => void; @@ -361,6 +367,7 @@ const ActionButton = (props: ActionButtonProps) => { label, iconName, requireConfirmation, + confirmationTitle, confirmationText, onClick, onDialogClose, @@ -403,21 +410,18 @@ const ActionButton = (props: ActionButtonProps) => { > - {confirmationText ?? + {confirmationTitle ?? t({ id: "login.profile.chart.confirmation.default", message: "Are you sure you want to perform this action?", })} - - - - Keep in mind that removing this visualization will affect all - the places where it might be already embedded! - - - + {confirmationText && ( + + {confirmationText} + + )} .MuiButton-root": {