0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-01 09:31:26 -05:00

Merge pull request #289 from uxbox/us/446/shared-libraries

Us/446/shared libraries
This commit is contained in:
Andrey Antukh 2020-08-05 13:25:40 +02:00 committed by GitHub
commit 1b6753932f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 512 additions and 124 deletions

View file

@ -1,11 +1,3 @@
-- ALTER TABLE color_library
-- DROP COLUMN team_id,
-- DROP COLUMN name,
-- ADD COLUMN file_id uuid NOT NULL REFERENCES file(id) ON DELETE CASCADE;
--
-- CREATE INDEX color_library__file_id__idx
-- ON color_library(file_id);
TRUNCATE TABLE color;
TRUNCATE TABLE color_library CASCADE;
TRUNCATE TABLE image;

View file

@ -0,0 +1,9 @@
ALTER TABLE file
ADD COLUMN is_shared BOOLEAN NOT NULL DEFAULT false;
UPDATE file
SET is_shared = true
WHERE project_id IN (SELECT id
FROM project
WHERE team_id = uuid_nil());

View file

@ -372,7 +372,8 @@
(files/create-file conn {:id id
:profile-id uuid/zero
:project-id project-id
:name name})
:name name
:shared? true})
(files/create-page conn {:file-id id}))
id))

View file

@ -63,7 +63,11 @@
{:desc "Make libraries linked to a file"
:name "0012-make-libraries-linked-to-a-file"
:fn (mg/resource "migrations/0012-make-libraries-linked-to-a-file.sql")}]})
:fn (mg/resource "migrations/0012-make-libraries-linked-to-a-file.sql")}
{:desc "Mark files shareable"
:name "0013-mark-files-shareable"
:fn (mg/resource "migrations/0013-mark-files-shareable.sql")}]})
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Entry point

View file

@ -63,9 +63,14 @@
:can-edit true}))
(defn create-file
[conn {:keys [id profile-id name project-id] :as params}]
(let [id (or id (uuid/next))
file (db/insert! conn :file {:id id :project-id project-id :name name})]
[conn {:keys [id profile-id name project-id shared?] :as params}]
(let [id (or id (uuid/next))
shared? (or shared? false)
file (db/insert! conn :file
{:id id
:project-id project-id
:name name
:is-shared shared?})]
(->> (assoc params :file-id id)
(create-file-profile conn))
file))
@ -101,6 +106,26 @@
{:id id}))
;; --- Mutation: Set File shared
(declare set-file-shared)
(s/def ::set-file-shared
(s/keys :req-un [::profile-id ::id ::is-shared]))
(sm/defmutation ::set-file-shared
[{:keys [id profile-id] :as params}]
(db/with-atomic [conn db/pool]
(files/check-edition-permissions! conn profile-id id)
(set-file-shared conn params)))
(defn- set-file-shared
[conn {:keys [id is-shared] :as params}]
(db/update! conn :file
{:is-shared is-shared}
{:id id}))
;; --- Mutation: Delete Project File
(declare mark-file-deleted)

View file

@ -147,6 +147,32 @@
project-id profile-id])
(mapv decode-row)))
;; --- Query: Shared Files
(def ^:private sql:shared-files
"select distinct
f.*,
array_agg(pg.id) over pages_w as pages,
first_value(pg.data) over pages_w as data
from file as f
left join page as pg on (f.id = pg.file_id)
where is_shared = true
and f.deleted_at is null
and pg.deleted_at is null
window pages_w as (partition by f.id order by pg.ordering
range between unbounded preceding
and unbounded following)
order by f.modified_at desc")
(s/def ::shared-files
(s/keys :req-un [::profile-id]))
(sq/defquery ::shared-files
[{:keys [profile-id] :as params}]
(->> (db/exec! db/pool [sql:shared-files])
(mapv decode-row)))
;; --- Query: File Permissions
(def ^:private sql:file-permissions

View file

@ -48,19 +48,10 @@
and (ppr.is_admin = true or
ppr.is_owner = true or
ppr.can_edit = true)
union
select p.*,
(select count(*) from file as f
where f.project_id = p.id
and deleted_at is null)
from project as p
where p.team_id = uuid_nil()
and p.deleted_at is null
)
select *
from projects
where team_id = ?
or team_id = uuid_nil()
order by modified_at desc")
(def ^:private sql:project-by-id

View file

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500">
<path d="M453 125c0-4-1-7-3-11L402 14a25 25 0 00-23-14H123C93 0 47 20 47 75v350c0 55 46 75 76 75h305c6 0 13-3 18-7 4-5 7-11 7-18zM123 50h240l24 50H123c-11 0-25-5-25-25s14-25 25-25zm279 400H123c-11 0-25-5-25-25V150h152v150l51-25 51 25V150h50z"/>
</svg>

After

Width:  |  Height:  |  Size: 317 B

View file

@ -269,8 +269,44 @@
"es" : "La solución de código abierto para diseñar y prototipar"
}
},
"dashboard.grid.add-shared" : {
"used-in" : [ "src/uxbox/main/ui/dashboard/grid.cljs:131", "src/uxbox/main/ui/workspace/header.cljs:147" ],
"translations" : {
"en" : "Add as Shared Library",
"fr" : "",
"ru" : "",
"es" : "Añadir como Biblioteca Compartida"
}
},
"dashboard.grid.add-shared-accept" : {
"used-in" : [ "src/uxbox/main/ui/dashboard/grid.cljs:70", "src/uxbox/main/ui/workspace/header.cljs:70" ],
"translations" : {
"en" : "Add as Shared Library",
"fr" : "",
"ru" : "",
"es" : "Añadir como Biblioteca Compartida"
}
},
"dashboard.grid.add-shared-hint" : {
"used-in" : [ "src/uxbox/main/ui/dashboard/grid.cljs:69", "src/uxbox/main/ui/workspace/header.cljs:69" ],
"translations" : {
"en" : "Once added as Shared Library, the assets of this file library will be available to be used among the rest of your files.",
"fr" : "",
"ru" : "",
"es" : "Una vez añadido como Biblioteca Compartida, los recursos de este archivo estarán disponibles para ser usado por el resto de tus archivos."
}
},
"dashboard.grid.add-shared-message" : {
"used-in" : [ "src/uxbox/main/ui/dashboard/grid.cljs:68", "src/uxbox/main/ui/workspace/header.cljs:68" ],
"translations" : {
"en" : "Add “%s” as Shared Library",
"fr" : "",
"ru" : "",
"es" : "Añadir “%s” como Biblioteca Compartida"
}
},
"dashboard.grid.delete" : {
"used-in" : [ "src/uxbox/main/ui/dashboard/project.cljs:62", "src/uxbox/main/ui/dashboard/grid.cljs:103" ],
"used-in" : [ "src/uxbox/main/ui/dashboard/project.cljs:62", "src/uxbox/main/ui/dashboard/grid.cljs:128" ],
"translations" : {
"en" : "Delete",
"fr" : "Supprimer",
@ -279,7 +315,7 @@
}
},
"dashboard.grid.empty-files" : {
"used-in" : [ "src/uxbox/main/ui/dashboard/grid.cljs:125" ],
"used-in" : [ "src/uxbox/main/ui/dashboard/grid.cljs:153" ],
"translations" : {
"en" : "You still have no files here",
"fr" : "Vous n'avez encore aucun fichier ici",
@ -287,8 +323,44 @@
"es" : "Todavía no hay ningún archivo aquí"
}
},
"dashboard.grid.remove-shared" : {
"used-in" : [ "src/uxbox/main/ui/dashboard/grid.cljs:130", "src/uxbox/main/ui/workspace/header.cljs:145" ],
"translations" : {
"en" : "Remove as Shared Library",
"fr" : "",
"ru" : "",
"es" : "Eliminar como Biblioteca Compartida"
}
},
"dashboard.grid.remove-shared-accept" : {
"used-in" : [ "src/uxbox/main/ui/dashboard/grid.cljs:81", "src/uxbox/main/ui/workspace/header.cljs:79" ],
"translations" : {
"en" : "Remove as Shared Library",
"fr" : "",
"ru" : "",
"es" : "Eliminar como Biblioteca Compartida"
}
},
"dashboard.grid.remove-shared-hint" : {
"used-in" : [ "src/uxbox/main/ui/dashboard/grid.cljs:80", "src/uxbox/main/ui/workspace/header.cljs:78" ],
"translations" : {
"en" : "Once removed as Shared Library, the File Library of this file will stop being available to be used among the rest of your files.",
"fr" : "",
"ru" : "",
"es" : "Una vez eliminado como Biblioteca Compartida, la Biblioteca de este archivo dejará de estar disponible para ser usada por el resto de tus archivos."
}
},
"dashboard.grid.remove-shared-message" : {
"used-in" : [ "src/uxbox/main/ui/dashboard/grid.cljs:79", "src/uxbox/main/ui/workspace/header.cljs:77" ],
"translations" : {
"en" : "Remove “%s” as Shared Library",
"fr" : "",
"ru" : "",
"es" : "Añadir “%s” como Biblioteca Compartida"
}
},
"dashboard.grid.rename" : {
"used-in" : [ "src/uxbox/main/ui/dashboard/project.cljs:61", "src/uxbox/main/ui/dashboard/grid.cljs:102" ],
"used-in" : [ "src/uxbox/main/ui/dashboard/project.cljs:61", "src/uxbox/main/ui/dashboard/grid.cljs:127" ],
"translations" : {
"en" : "Rename",
"fr" : "Renommer",
@ -305,6 +377,15 @@
"es" : "Borrador"
}
},
"dashboard.header.libraries" : {
"used-in" : [ "src/uxbox/main/ui/dashboard/libraries.cljs:41" ],
"translations" : {
"en" : "Shared Libraries",
"fr" : "",
"ru" : "",
"es" : "Bibliotecas Compartidas"
}
},
"dashboard.header.new-file" : {
"used-in" : [ "src/uxbox/main/ui/dashboard/project.cljs:72" ],
"translations" : {
@ -468,7 +549,7 @@
}
},
"dashboard.sidebar.drafts" : {
"used-in" : [ "src/uxbox/main/ui/dashboard/sidebar.cljs:128" ],
"used-in" : [ "src/uxbox/main/ui/dashboard/sidebar.cljs:129" ],
"translations" : {
"en" : "Drafts",
"fr" : "Brouillons",
@ -477,16 +558,16 @@
}
},
"dashboard.sidebar.libraries" : {
"used-in" : [ "src/uxbox/main/ui/dashboard/sidebar.cljs:134" ],
"used-in" : [ "src/uxbox/main/ui/dashboard/sidebar.cljs:135" ],
"translations" : {
"en" : "Libraries",
"fr" : "Librairies",
"ru" : "Библиотеки",
"es" : "Bibliotecas"
"en" : "Shared Libraries",
"fr" : "",
"ru" : "",
"es" : "Bibliotecas Compartidas"
}
},
"dashboard.sidebar.recent" : {
"used-in" : [ "src/uxbox/main/ui/dashboard/sidebar.cljs:121" ],
"used-in" : [ "src/uxbox/main/ui/dashboard/sidebar.cljs:122" ],
"translations" : {
"en" : "Recent",
"fr" : "Récent",
@ -540,7 +621,7 @@
}
},
"ds.confirm-cancel" : {
"used-in" : [ "src/uxbox/main/ui/confirm.cljs:19" ],
"used-in" : [ "src/uxbox/main/ui/confirm.cljs:20" ],
"translations" : {
"en" : "Cancel",
"fr" : "Annuler",
@ -549,7 +630,7 @@
}
},
"ds.confirm-ok" : {
"used-in" : [ "src/uxbox/main/ui/confirm.cljs:20" ],
"used-in" : [ "src/uxbox/main/ui/confirm.cljs:21" ],
"translations" : {
"en" : "Ok",
"fr" : "Ok",
@ -558,7 +639,7 @@
}
},
"ds.confirm-title" : {
"used-in" : [ "src/uxbox/main/ui/confirm.cljs:18" ],
"used-in" : [ "src/uxbox/main/ui/confirm.cljs:19" ],
"translations" : {
"en" : "Are you sure?",
"fr" : "Êtes-vous sûr?",
@ -585,7 +666,7 @@
}
},
"ds.new-file" : {
"used-in" : [ "src/uxbox/main/ui/dashboard/grid.cljs:121", "src/uxbox/main/ui/dashboard/grid.cljs:127" ],
"used-in" : [ "src/uxbox/main/ui/dashboard/grid.cljs:149", "src/uxbox/main/ui/dashboard/grid.cljs:155" ],
"translations" : {
"en" : "+ New File",
"fr" : "+ Nouveau fichier",
@ -594,7 +675,7 @@
}
},
"ds.search.placeholder" : {
"used-in" : [ "src/uxbox/main/ui/dashboard/sidebar.cljs:187" ],
"used-in" : [ "src/uxbox/main/ui/dashboard/sidebar.cljs:188" ],
"translations" : {
"en" : "Search...",
"fr" : "Rechercher...",
@ -648,7 +729,7 @@
}
},
"errors.generic" : {
"used-in" : [ "src/uxbox/main/ui.cljs:201", "src/uxbox/main/ui/settings/profile.cljs:38", "src/uxbox/main/ui/auth.cljs:91" ],
"used-in" : [ "src/uxbox/main/ui.cljs:204", "src/uxbox/main/ui/settings/profile.cljs:38", "src/uxbox/main/ui/auth.cljs:91" ],
"translations" : {
"en" : "Something wrong has happened.",
"fr" : "Quelque chose c'est mal passé.",
@ -657,7 +738,7 @@
}
},
"errors.image-format-unsupported" : {
"used-in" : [ "src/uxbox/main/data/workspace/persistence.cljs:390", "src/uxbox/main/data/users.cljs:177", "src/uxbox/main/data/images.cljs:376" ],
"used-in" : [ "src/uxbox/main/data/workspace/persistence.cljs:406", "src/uxbox/main/data/users.cljs:177", "src/uxbox/main/data/images.cljs:376" ],
"translations" : {
"en" : "The image format is not supported (must be svg, jpg or png).",
"fr" : "Le format d'image n'est pas supporté (doit être svg, jpg ou png).",
@ -666,7 +747,7 @@
}
},
"errors.image-too-large" : {
"used-in" : [ "src/uxbox/main/data/workspace/persistence.cljs:388", "src/uxbox/main/data/users.cljs:175", "src/uxbox/main/data/images.cljs:374" ],
"used-in" : [ "src/uxbox/main/data/workspace/persistence.cljs:404", "src/uxbox/main/data/users.cljs:175", "src/uxbox/main/data/images.cljs:374" ],
"translations" : {
"en" : "The image is too large to be inserted (must be under 5mb).",
"fr" : "L'image est trop grande (doit être inférieure à 5 Mo).",
@ -675,7 +756,7 @@
}
},
"errors.image-type-mismatch" : {
"used-in" : [ "src/uxbox/main/data/workspace/persistence.cljs:355", "src/uxbox/main/data/workspace/persistence.cljs:405", "src/uxbox/main/data/users.cljs:191", "src/uxbox/main/data/images.cljs:391" ],
"used-in" : [ "src/uxbox/main/data/workspace/persistence.cljs:371", "src/uxbox/main/data/workspace/persistence.cljs:421", "src/uxbox/main/data/users.cljs:191", "src/uxbox/main/data/images.cljs:391" ],
"translations" : {
"en" : "Seems that the contents of the image does not match the file extension.",
"fr" : "",
@ -684,7 +765,7 @@
}
},
"errors.image-type-not-allowed" : {
"used-in" : [ "src/uxbox/main/data/workspace/persistence.cljs:352", "src/uxbox/main/data/workspace/persistence.cljs:402", "src/uxbox/main/data/users.cljs:188", "src/uxbox/main/data/images.cljs:388" ],
"used-in" : [ "src/uxbox/main/data/workspace/persistence.cljs:368", "src/uxbox/main/data/workspace/persistence.cljs:418", "src/uxbox/main/data/users.cljs:188", "src/uxbox/main/data/images.cljs:388" ],
"translations" : {
"en" : "Seems that this is not a valid image.",
"fr" : "",
@ -693,7 +774,7 @@
}
},
"errors.network" : {
"used-in" : [ "src/uxbox/main/ui.cljs:195" ],
"used-in" : [ "src/uxbox/main/ui.cljs:198" ],
"translations" : {
"en" : "Unable to connect to backend server.",
"fr" : "Impossible de se connecter au serveur principal.",
@ -729,7 +810,7 @@
}
},
"errors.unexpected-error" : {
"used-in" : [ "src/uxbox/main/data/workspace/persistence.cljs:358", "src/uxbox/main/data/workspace/persistence.cljs:408", "src/uxbox/main/data/users.cljs:194", "src/uxbox/main/data/images.cljs:394", "src/uxbox/main/ui/settings/change_email.cljs:51", "src/uxbox/main/ui/workspace/sidebar/options/exports.cljs:65", "src/uxbox/main/ui/auth/register.cljs:54" ],
"used-in" : [ "src/uxbox/main/data/workspace/persistence.cljs:374", "src/uxbox/main/data/workspace/persistence.cljs:424", "src/uxbox/main/data/users.cljs:194", "src/uxbox/main/data/images.cljs:394", "src/uxbox/main/ui/settings/change_email.cljs:51", "src/uxbox/main/ui/workspace/sidebar/options/exports.cljs:65", "src/uxbox/main/ui/auth/register.cljs:54" ],
"translations" : {
"en" : "An unexpected error occurred.",
"fr" : "Une erreur inattendue c'est produite",
@ -756,7 +837,7 @@
}
},
"header.sitemap" : {
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:65" ],
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:85" ],
"translations" : {
"en" : "Sitemap",
"fr" : null,
@ -774,7 +855,7 @@
}
},
"image.loading" : {
"used-in" : [ "src/uxbox/main/data/workspace/persistence.cljs:366", "src/uxbox/main/data/workspace/persistence.cljs:417", "src/uxbox/main/data/users.cljs:201", "src/uxbox/main/data/images.cljs:403" ],
"used-in" : [ "src/uxbox/main/data/workspace/persistence.cljs:382", "src/uxbox/main/data/workspace/persistence.cljs:433", "src/uxbox/main/data/users.cljs:201", "src/uxbox/main/data/images.cljs:403" ],
"translations" : {
"en" : "Loading image...",
"fr" : "Chargement de l'image...",
@ -999,7 +1080,7 @@
}
},
"settings.notifications.email-not-verified" : {
"used-in" : [ "src/uxbox/main/ui/dashboard.cljs:113" ],
"used-in" : [ "src/uxbox/main/ui/dashboard.cljs:118" ],
"translations" : {
"en" : "Your email address has not been verified yet. Please check your inbox at “%s” for a confirmation email.",
"fr" : "Votre adresse e-mail n'a pas encore été vérifiée. Veuillez vérifier votre boîte de réception à “%s” pour un e-mail de confirmation.",
@ -1359,7 +1440,7 @@
}
},
"workspace.assets.assets" : {
"used-in" : [ "src/uxbox/main/ui/workspace/sidebar/assets.cljs:325" ],
"used-in" : [ "src/uxbox/main/ui/workspace/sidebar/assets.cljs:331" ],
"translations" : {
"en" : "Assets",
"fr" : "",
@ -1368,7 +1449,7 @@
}
},
"workspace.assets.box-filter-all" : {
"used-in" : [ "src/uxbox/main/ui/workspace/sidebar/assets.cljs:342" ],
"used-in" : [ "src/uxbox/main/ui/workspace/sidebar/assets.cljs:348" ],
"translations" : {
"en" : "All assets",
"fr" : "",
@ -1377,7 +1458,7 @@
}
},
"workspace.assets.box-filter-colors" : {
"used-in" : [ "src/uxbox/main/ui/workspace/sidebar/assets.cljs:344" ],
"used-in" : [ "src/uxbox/main/ui/workspace/sidebar/assets.cljs:350" ],
"translations" : {
"en" : "Colors",
"fr" : "",
@ -1386,7 +1467,7 @@
}
},
"workspace.assets.box-filter-graphics" : {
"used-in" : [ "src/uxbox/main/ui/workspace/sidebar/assets.cljs:343" ],
"used-in" : [ "src/uxbox/main/ui/workspace/sidebar/assets.cljs:349" ],
"translations" : {
"en" : "Graphics",
"fr" : "",
@ -1422,7 +1503,7 @@
}
},
"workspace.assets.file-library" : {
"used-in" : [ "src/uxbox/main/ui/workspace/sidebar/assets.cljs:271" ],
"used-in" : [ "src/uxbox/main/ui/workspace/sidebar/assets.cljs:272" ],
"translations" : {
"en" : "File library",
"fr" : "",
@ -1440,7 +1521,7 @@
}
},
"workspace.assets.not-found" : {
"used-in" : [ "src/uxbox/main/ui/workspace/sidebar/assets.cljs:282" ],
"used-in" : [ "src/uxbox/main/ui/workspace/sidebar/assets.cljs:287" ],
"translations" : {
"en" : "No assets found",
"fr" : "",
@ -1458,7 +1539,7 @@
}
},
"workspace.assets.search" : {
"used-in" : [ "src/uxbox/main/ui/workspace/sidebar/assets.cljs:329" ],
"used-in" : [ "src/uxbox/main/ui/workspace/sidebar/assets.cljs:335" ],
"translations" : {
"en" : "Search assets",
"fr" : "",
@ -1466,8 +1547,17 @@
"es" : "Buscar recursos"
}
},
"workspace.assets.shared" : {
"used-in" : [ "src/uxbox/main/ui/workspace/sidebar/assets.cljs:274" ],
"translations" : {
"en" : "SHARED",
"fr" : "",
"ru" : "",
"es" : "COMPARTIDA"
}
},
"workspace.header.menu.disable-dynamic-alignment" : {
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:117" ],
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:139" ],
"translations" : {
"en" : "Disable dynamic alignment",
"fr" : "Désactiver l'alignement dynamique",
@ -1476,7 +1566,7 @@
}
},
"workspace.header.menu.disable-snap-grid" : {
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:89" ],
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:111" ],
"translations" : {
"en" : "Disable snap to grid",
"fr" : "Désactiver l'alignement sur la grille",
@ -1485,7 +1575,7 @@
}
},
"workspace.header.menu.enable-dynamic-alignment" : {
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:118" ],
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:140" ],
"translations" : {
"en" : "Enable dynamic aligment",
"fr" : "Activer l'alignement dynamique",
@ -1494,7 +1584,7 @@
}
},
"workspace.header.menu.enable-snap-grid" : {
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:90" ],
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:112" ],
"translations" : {
"en" : "Snap to grid",
"fr" : "Aligner sur la grille",
@ -1503,7 +1593,7 @@
}
},
"workspace.header.menu.hide-grid" : {
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:82" ],
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:104" ],
"translations" : {
"en" : "Hide grid",
"fr" : "Masquer la grille",
@ -1512,7 +1602,7 @@
}
},
"workspace.header.menu.hide-layers" : {
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:96" ],
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:118" ],
"translations" : {
"en" : "Hide layers",
"fr" : "Masquer les couches",
@ -1521,7 +1611,7 @@
}
},
"workspace.header.menu.hide-libraries" : {
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:110" ],
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:132" ],
"translations" : {
"en" : "Hide libraries",
"fr" : "Masquer les librairies",
@ -1530,7 +1620,7 @@
}
},
"workspace.header.menu.hide-palette" : {
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:103" ],
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:125" ],
"translations" : {
"en" : "Hide color palette",
"fr" : "Masquer la palette de couleurs",
@ -1539,7 +1629,7 @@
}
},
"workspace.header.menu.hide-rules" : {
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:75" ],
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:97" ],
"translations" : {
"en" : "Hide rules",
"fr" : "Masquer les règles",
@ -1548,7 +1638,7 @@
}
},
"workspace.header.menu.show-grid" : {
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:83" ],
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:105" ],
"translations" : {
"en" : "Show grid",
"fr" : "Montrer la grille",
@ -1557,7 +1647,7 @@
}
},
"workspace.header.menu.show-layers" : {
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:97" ],
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:119" ],
"translations" : {
"en" : "Show layers",
"fr" : "Montrer les couches",
@ -1566,7 +1656,7 @@
}
},
"workspace.header.menu.show-libraries" : {
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:111" ],
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:133" ],
"translations" : {
"en" : "Show libraries",
"fr" : "Montrer les librairies",
@ -1575,7 +1665,7 @@
}
},
"workspace.header.menu.show-palette" : {
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:104" ],
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:126" ],
"translations" : {
"en" : "Show color palette",
"fr" : "Montrer la palette de couleurs",
@ -1584,7 +1674,7 @@
}
},
"workspace.header.menu.show-rules" : {
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:76" ],
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:98" ],
"translations" : {
"en" : "Show rules",
"fr" : "Montrer les règles",
@ -1593,7 +1683,7 @@
}
},
"workspace.header.viewer" : {
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:156" ],
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:184" ],
"translations" : {
"en" : "View mode (Ctrl + P)",
"fr" : "Mode visualisation (Ctrl + P)",

View file

@ -156,6 +156,26 @@
}
.item-badge {
background-color: $color-white;
border: 1px solid $color-gray-20;
border-radius: 4px;
position: absolute;
top: $x-small;
right: $x-small;
height: 32px;
width: 32px;
display: flex;
align-items: center;
justify-content: center;
svg {
fill: $color-gray-30;
height: 16px;
width: 16px;
}
}
&.add-file {
border: 1px dashed $color-gray-20;
justify-content: center;

View file

@ -124,6 +124,15 @@
&:hover {
background: $color-danger-dark;
}
&.not-danger {
background: $color-primary;
color: $color-gray-60;
}
&.not-danger:hover {
background: $color-primary-dark;
}
}
}

View file

@ -90,6 +90,15 @@ $width-settings-bar: 15rem;
font-size: $fs13;
}
span.tool-badge {
border: 1px solid $color-primary;
border-radius: 2px;
font-size: $fs10;
color: $color-primary;
padding: 2px 4px;
margin-left: auto;
}
.tool-window-icon {
margin-right: $small;
display: none;

View file

@ -55,6 +55,23 @@
align-items: center;
}
.shared-badge {
margin-left: $x-small;
border: 1px solid $color-gray-20;
border-radius: 4px;
height: 16px;
width: 16px;
display: flex;
align-items: center;
justify-content: center;
svg {
fill: $color-gray-20;
height: 8px;
width: 8px;
}
}
.users-section {
display: flex;
}

View file

@ -74,6 +74,7 @@
(declare fetch-files)
(declare fetch-projects)
(declare fetch-recent-files)
(declare fetch-shared-files)
(def initialize-drafts
(ptk/reify ::initialize-drafts
@ -95,7 +96,7 @@
(defn initialize-recent
[team-id]
(us/verify ::us/uuid team-id)
(ptk/reify ::initialize-team
(ptk/reify ::initialize-recent
ptk/UpdateEvent
(update [_ state]
(update state :dashboard-local assoc
@ -128,6 +129,25 @@
(rx/of (fetch-projects (:team-id local) nil)
(fetch-files (:project-id local)))))))
(defn initialize-libraries
[team-id]
(us/verify ::us/uuid team-id)
(ptk/reify ::initialize-libraries
ptk/UpdateEvent
(update [_ state]
(update state :dashboard-local assoc
:project-for-edit nil
:project-id nil
:team-id team-id))
ptk/WatchEvent
(watch [_ state stream]
(let [local (:dashboard-local state)]
(rx/of (fetch-projects (:team-id local) nil)
(fetch-shared-files (:team-id local)))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Data Fetching
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -202,6 +222,29 @@
files (d/index-by :id files)]
(assoc state :files files)))))
;; --- Fetch Shared Files
(declare shared-files-fetched)
(defn fetch-shared-files
[]
(ptk/reify ::fetch-shared-files
ptk/WatchEvent
(watch [_ state stream]
(let [params {}]
(->> (rp/query :shared-files params)
(rx/map shared-files-fetched))))))
(defn shared-files-fetched
[files]
(us/verify (s/every ::file) files)
(ptk/reify ::shared-files-fetched
ptk/UpdateEvent
(update [_ state]
(let [state (dissoc state :files)
files (d/index-by :id files)]
(assoc state :files files)))))
;; --- Fetch recent files
(declare recent-files-fetched)
@ -333,11 +376,25 @@
ptk/WatchEvent
(watch [_ state stream]
(let [local (:dashboard-local state)
params {:id id :name name}]
(let [params {:id id :name name}]
(->> (rp/mutation :rename-file params)
(rx/ignore))))))
;; --- Set File shared
(defn set-file-shared
[id is-shared]
{:pre [(uuid? id) (boolean? is-shared)]}
(ptk/reify ::set-file-shared
ptk/UpdateEvent
(update [_ state]
(assoc-in state [:files id :is-shared] is-shared))
ptk/WatchEvent
(watch [_ state stream]
(let [params {:id id :is-shared is-shared}]
(->> (rp/mutation :set-file-shared params)
(rx/ignore))))))
;; --- Create File

View file

@ -1436,6 +1436,7 @@
;; Persistence
(def set-file-shared dwp/set-file-shared)
(def fetch-images dwp/fetch-images)
(def add-image-from-url dwp/add-image-from-url)
(def upload-image dwp/upload-image)

View file

@ -182,6 +182,22 @@
:workspace-project project)
(reduce assoc-page $$ pages))))))
;; --- Set File shared
(defn set-file-shared
[id is-shared]
{:pre [(uuid? id) (boolean? is-shared)]}
(ptk/reify ::set-file-shared
ptk/UpdateEvent
(update [_ state]
(assoc-in state [:workspace-file :is-shared] is-shared))
ptk/WatchEvent
(watch [_ state stream]
(let [params {:id id :is-shared is-shared}]
(->> (rp/mutation :set-file-shared params)
(rx/ignore))))))
;; --- Fetch Pages
(declare page-fetched)

View file

@ -64,20 +64,22 @@
["/" :dashboard-team]
["/search" :dashboard-search]
["/project/:project-id" :dashboard-project]
["/library"
["/icons"
["" { :name :dashboard-library-icons-index :section :icons}]
["/:library-id" { :name :dashboard-library-icons :section :icons}]]
["/libraries" :dashboard-libraries]
["/images"
["" { :name :dashboard-library-images-index :section :images}]
["/:library-id" { :name :dashboard-library-images :section :images}]]
;; ["/library"
;; ["/icons"
;; ["" { :name :dashboard-library-icons-index :section :icons}]
;; ["/:library-id" { :name :dashboard-library-icons :section :icons}]]
;;
;; ["/images"
;; ["" { :name :dashboard-library-images-index :section :images}]
;; ["/:library-id" { :name :dashboard-library-images :section :images}]]
;;
;; ["/palettes"
;; ["" { :name :dashboard-library-palettes-index :section :palettes}]
;; ["/:library-id" { :name :dashboard-library-palettes :section :palettes }]]]
["/palettes"
["" { :name :dashboard-library-palettes-index :section :palettes}]
["/:library-id" { :name :dashboard-library-palettes :section :palettes }]]
]]]
]]
["/workspace/:project-id/:file-id" :workspace]])
@ -119,12 +121,13 @@
(:dashboard-search
:dashboard-team
:dashboard-project
:dashboard-library-icons
:dashboard-library-icons-index
:dashboard-library-images
:dashboard-library-images-index
:dashboard-library-palettes
:dashboard-library-palettes-index)
:dashboard-libraries)
;; :dashboard-library-icons
;; :dashboard-library-icons-index
;; :dashboard-library-images
;; :dashboard-library-images-index
;; :dashboard-library-palettes
;; :dashboard-library-palettes-index)
[:& dashboard {:route route}]
:viewer

View file

@ -11,10 +11,11 @@
[rumext.alpha :as mf]
[uxbox.main.ui.modal :as modal]
[uxbox.util.i18n :refer (tr)]
[uxbox.util.data :refer [classnames]]
[uxbox.util.dom :as dom]))
(mf/defc confirm-dialog
[{:keys [message on-accept on-cancel hint cancel-text accept-text] :as ctx}]
[{:keys [message on-accept on-cancel hint cancel-text accept-text not-danger?] :as ctx}]
(let [message (or message (tr "ds.confirm-title"))
cancel-text (or cancel-text (tr "ds.confirm-cancel"))
accept-text (or accept-text (tr "ds.confirm-ok"))
@ -45,5 +46,7 @@
[:input.dialog-accept-button
{:type "button"
:class (classnames :not-danger not-danger?)
:value accept-text
:on-click accept}]]]]]))

View file

@ -21,7 +21,8 @@
[uxbox.main.ui.dashboard.search :refer [search-page]]
[uxbox.main.ui.dashboard.project :refer [project-page]]
[uxbox.main.ui.dashboard.recent-files :refer [recent-files-page]]
[uxbox.main.ui.dashboard.library :refer [library-page]]
[uxbox.main.ui.dashboard.libraries :refer [libraries-page]]
;; [uxbox.main.ui.dashboard.library :refer [library-page]]
[uxbox.main.ui.dashboard.profile :refer [profile-section]]
[uxbox.util.router :as rt]
[uxbox.util.i18n :as i18n :refer [t]]))
@ -36,8 +37,8 @@
(let [search-term (get-in route [:params :query :search-term])
route-name (get-in route [:data :name])
team-id (get-in route [:params :path :team-id])
project-id (get-in route [:params :path :project-id])
library-id (get-in route [:params :path :library-id])]
project-id (get-in route [:params :path :project-id])]
;; library-id (get-in route [:params :path :library-id])]
(cond->
{:search-term search-term}
@ -48,13 +49,13 @@
(assoc :project-id (uuid project-id))
(= "drafts" project-id)
(assoc :project-id (:default-project-id profile))
(assoc :project-id (:default-project-id profile)))))
(str/starts-with? (name route-name) "dashboard-library")
(assoc :library-section (get-in route [:data :section]))
(uuid-str? library-id)
(assoc :library-id (uuid library-id)))))
;; (str/starts-with? (name route-name) "dashboard-library")
;; (assoc :library-section (get-in route [:data :section]))
;;
;; (uuid-str? library-id)
;; (assoc :library-id (uuid library-id)))))
(declare global-notifications)
@ -63,7 +64,8 @@
[{:keys [route] :as props}]
(let [profile (mf/deref refs/profile)
page (get-in route [:data :name])
{:keys [search-term team-id project-id library-id library-section] :as params}
;; {:keys [search-term team-id project-id library-id library-section] :as params}
{:keys [search-term team-id project-id] :as params}
(parse-params route profile)]
[:*
[:& global-notifications {:profile profile}]
@ -84,16 +86,19 @@
:dashboard-team
[:& recent-files-page {:team-id team-id}]
(:dashboard-library-icons
:dashboard-library-icons-index
:dashboard-library-images
:dashboard-library-images-index
:dashboard-library-palettes
:dashboard-library-palettes-index)
[:& library-page {:key (str library-id)
:team-id team-id
:library-id library-id
:section library-section}]
:dashboard-libraries
[:& libraries-page {:team-id team-id}]
;; (:dashboard-library-icons
;; :dashboard-library-icons-index
;; :dashboard-library-images
;; :dashboard-library-images-index
;; :dashboard-library-palettes
;; :dashboard-library-palettes-index)
;; [:& library-page {:key (str library-id)
;; :team-id team-id
;; :library-id library-id
;; :section library-section}]
:dashboard-project
[:& project-page {:team-id team-id

View file

@ -60,6 +60,28 @@
(dom/stop-propagation %)
(modal/show! confirm-dialog {:on-accept delete-fn}))
add-shared-fn #(st/emit! nil (dsh/set-file-shared (:id file) true))
on-add-shared
#(do
(dom/stop-propagation %)
(modal/show! confirm-dialog
{:message (t locale "dashboard.grid.add-shared-message" (:name file))
:hint (t locale "dashboard.grid.add-shared-hint")
:accept-text (t locale "dashboard.grid.add-shared-accept")
:not-danger? true
:on-accept add-shared-fn}))
remove-shared-fn #(st/emit! nil (dsh/set-file-shared (:id file) false))
on-remove-shared
#(do
(dom/stop-propagation %)
(modal/show! confirm-dialog
{:message (t locale "dashboard.grid.remove-shared-message" (:name file))
:hint (t locale "dashboard.grid.remove-shared-hint")
:accept-text (t locale "dashboard.grid.remove-shared-accept")
:not-danger? false
:on-accept remove-shared-fn}))
on-blur #(let [name (-> % dom/get-target dom/get-value)]
(st/emit! (dsh/rename-file (:id file) name))
(swap! local assoc :edition false))
@ -77,6 +99,9 @@
[:div.grid-item.project-th {:on-click on-navigate}
[:div.overlay]
[:& grid-item-thumbnail {:file file}]
(when (:is-shared file)
[:div.item-badge
i/library])
[:div.item-info
(if (:edition @local)
[:input.element-name {:type "text"
@ -100,7 +125,10 @@
[:& context-menu {:on-close on-menu-close
:show (:menu-open @local)
:options [[(t locale "dashboard.grid.rename") on-edit]
[(t locale "dashboard.grid.delete") on-delete]]}]]]))
[(t locale "dashboard.grid.delete") on-delete]
(if (:is-shared file)
[(t locale "dashboard.grid.remove-shared") on-remove-shared]
[(t locale "dashboard.grid.add-shared") on-add-shared])]}]]]))
;; --- Grid

View file

@ -0,0 +1,44 @@
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; This Source Code Form is "Incompatible With Secondary Licenses", as
;; defined by the Mozilla Public License, v. 2.0.
;;
;; Copyright (c) 2020 UXBOX Labs SL
(ns uxbox.main.ui.dashboard.libraries
(:require
[okulary.core :as l]
[rumext.alpha :as mf]
[uxbox.main.ui.icons :as i]
[uxbox.util.i18n :as i18n :refer [tr]]
[uxbox.util.dom :as dom]
[uxbox.util.router :as rt]
[uxbox.main.data.dashboard :as dsh]
[uxbox.main.store :as st]
[uxbox.main.ui.modal :as modal]
[uxbox.main.ui.keyboard :as kbd]
[uxbox.main.ui.confirm :refer [confirm-dialog]]
[uxbox.main.ui.components.context-menu :refer [context-menu]]
[uxbox.main.ui.dashboard.grid :refer [grid]]))
(def files-ref
(-> (comp vals :files)
(l/derived st/state)))
(mf/defc libraries-page
[{:keys [section team-id] :as props}]
(let [files (->> (mf/deref files-ref)
(sort-by :modified-at)
(reverse))]
(mf/use-effect
(mf/deps section team-id)
#(st/emit! (dsh/initialize-libraries team-id)))
[:*
[:header.main-bar
[:h1.dashboard-title (tr "dashboard.header.libraries")]]
[:section.libraries-page
[:& grid {:files files :hide-new? true}]]]))

View file

@ -104,13 +104,14 @@
selected-section
selected-project-id
selected-team-id] :as props}]
(let [home? (and (= selected-section :dashboard-team)
(= selected-team-id (:default-team-id profile)))
drafts? (and (= selected-section :dashboard-project)
(= selected-team-id (:default-team-id profile))
(= selected-project-id (:default-project-id profile)))
library? (and (str/starts-with? (name selected-section) "dashboard-library")
(= selected-team-id (:default-team-id profile)))
(let [home? (and (= selected-section :dashboard-team)
(= selected-team-id (:default-team-id profile)))
drafts? (and (= selected-section :dashboard-project)
(= selected-team-id (:default-team-id profile))
(= selected-project-id (:default-project-id profile)))
libraries? (= selected-section :dashboard-libraries)
;; library? (and (str/starts-with? (name selected-section) "dashboard-library")
;; (= selected-team-id (:default-team-id profile)))
locale (i18n/use-locale)]
[:div.sidebar-team
[:ul.library-elements.library-common
@ -128,8 +129,8 @@
[:span.element-title (t locale "dashboard.sidebar.drafts")]]
[:li
{:on-click #(st/emit! (rt/nav :dashboard-library-icons-index {:team-id team-id}))
:class-name (when library? "current")}
{:on-click #(st/emit! (rt/nav :dashboard-libraries {:team-id team-id}))
:class-name (when libraries? "current")}
i/icon-set
[:span.element-title (t locale "dashboard.sidebar.libraries")]]]

View file

@ -55,6 +55,7 @@
(def interaction (icon-xref :interaction))
(def layers (icon-xref :layers))
(def letter-spacing (icon-xref :letter-spacing))
(def library (icon-xref :library))
(def line (icon-xref :line))
(def line-height (icon-xref :line-height))
(def loader (icon-xref :loader))

View file

@ -18,6 +18,8 @@
[uxbox.main.refs :as refs]
[uxbox.main.store :as st]
[uxbox.main.ui.components.dropdown :refer [dropdown]]
[uxbox.main.ui.modal :as modal]
[uxbox.main.ui.confirm :refer [confirm-dialog]]
[uxbox.main.ui.workspace.presence :as presence]
[uxbox.util.i18n :as i18n :refer [t]]
[uxbox.util.data :refer [classnames]]
@ -58,13 +60,33 @@
(mf/defc menu
[{:keys [layout project file] :as props}]
(let [show-menu? (mf/use-state false)
locale (i18n/use-locale)]
locale (i18n/use-locale)
add-shared-fn #(st/emit! nil (dw/set-file-shared (:id file) true))
on-add-shared
#(modal/show! confirm-dialog
{:message (t locale "dashboard.grid.add-shared-message" (:name file))
:hint (t locale "dashboard.grid.add-shared-hint")
:accept-text (t locale "dashboard.grid.add-shared-accept")
:not-danger? true
:on-accept add-shared-fn})
remove-shared-fn #(st/emit! nil (dw/set-file-shared (:id file) false))
on-remove-shared
#(modal/show! confirm-dialog
{:message (t locale "dashboard.grid.remove-shared-message" (:name file))
:hint (t locale "dashboard.grid.remove-shared-hint")
:accept-text (t locale "dashboard.grid.remove-shared-accept")
:not-danger? false
:on-accept remove-shared-fn})]
[:div.menu-section
[:div.btn-icon-dark.btn-small {:on-click #(reset! show-menu? true)} i/actions]
[:div.project-tree {:alt (t locale "header.sitemap")}
[:span.project-name (:name project) " /"]
[:span (:name file)]]
(when (:is-shared file)
[:div.shared-badge i/library])
[:& dropdown {:show @show-menu?
:on-close #(reset! show-menu? false)}
@ -117,6 +139,12 @@
(t locale "workspace.header.menu.disable-dynamic-alignment")
(t locale "workspace.header.menu.enable-dynamic-alignment"))]
[:span.shortcut "Ctrl+a"]]
(if (:is-shared file)
[:li {:on-click on-remove-shared}
[:span (t locale "dashboard.grid.remove-shared")]]
[:li {:on-click on-add-shared}
[:span (t locale "dashboard.grid.add-shared")]])
]]]))
;; --- Header Component

View file

@ -255,6 +255,7 @@
(mf/defc library-toolbox
[{:keys [library-id
shared?
images
colors
initial-open?
@ -268,7 +269,9 @@
{:class (classnames :open @open?)
:on-click toggle-open}
i/arrow-slide]
[:span (tr "workspace.assets.file-library")]]
[:span (tr "workspace.assets.file-library")]
(when shared?
[:span.tool-badge (tr "workspace.assets.shared")])]
(when @open?
(let [show-graphics (and (or (= box-filter :all) (= box-filter :graphics))
(or (> (count images) 0) (str/empty? search-term)))
@ -286,7 +289,8 @@
(mf/defc assets-toolbox
[]
(let [team-id (-> refs/workspace-project mf/deref :team-id)
file-id (-> refs/workspace-file mf/deref :id)
file (mf/deref refs/workspace-file)
file-id (:id file)
file-images (mf/deref refs/workspace-images)
file-colors (mf/deref refs/workspace-colors)
@ -347,6 +351,7 @@
]]
[:& library-toolbox {:library-id file-id
:shared? (:is-shared file)
:images filtered-images
:colors filtered-colors
:initial-open? true