mirror of
https://github.com/penpot/penpot.git
synced 2026-11-26 21:00:32 +00:00
✨ Add Copy link to the file and project menus in the dashboard (#13200)
Both menus get a Copy link option after Move to. The file menu copies the workspace URL of the file and the project menu the URL of the project page, then show a confirmation toast. A copy error shows a toast that closes on its own; errors that are not clipboard ones are also logged. Also tidy both menus: - Add a separator before Import Penpot files in the project menu. - Rename "Open file in a new tab" to "Open in new tab". - Add a separator before the download option in the multiple files menu, as in the single file menu. - Show Pin or Unpin depending on the project state. Viewers already had no project menu in the project list and on the project page. Disable it, and rename on double-click, for pinned projects in the sidebar too, so viewers can copy file links but not project links. The user guide documents both options. New translation keys are in en and es only. Closes #13182 AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
888e2d9368
commit
3346c67a3b
@ -37,6 +37,10 @@ desc: Learn how to organize your work in Penpot. Create, manage and organize pro
|
||||
<p>When you move a project to another team, all files within the project are moved along with it. Team members of the destination team will gain access to the project and its files according to their permissions.</p>
|
||||
<p class="advice">Moving a project to another team changes its ownership and access permissions. Make sure the destination team has the appropriate members and permissions for the work contained in the project.</p>
|
||||
|
||||
<h3 id="copy-project-link">Copy a project link</h3>
|
||||
<p>To share a project, right-click on it or click its three-dot menu and select <strong>Copy link</strong>. Penpot copies the address of the project page to your clipboard. People who open it need access to the team that owns the project.</p>
|
||||
<p>Viewers can't open the project menu, so only Editors, Admins and Owners can copy a project link.</p>
|
||||
|
||||
<h3 id="delete-project">Delete a project</h3>
|
||||
<p>To delete a project, right-click on it and select <strong>Delete</strong> from the menu. You'll be asked to confirm the deletion. Keep in mind that deleting a project will also delete all files within it. Make sure you have backed up any important files before deleting a project.</p>
|
||||
<p class="advice">Deleted projects and their files are moved to the trash area where they can be restored or permanently deleted.</p>
|
||||
@ -72,6 +76,10 @@ desc: Learn how to organize your work in Penpot. Create, manage and organize pro
|
||||
<p>When moving a file to a project in another team, the file becomes accessible to members of that team according to their permissions. Moving a file doesn't affect its content or any shared libraries it might be using. Only its location in your project structure changes.</p>
|
||||
<p class="advice">When moving files between teams, be aware that this changes who has access to the file. Make sure the destination team has the appropriate members and permissions for the work contained in the file.</p>
|
||||
|
||||
<h3 id="copy-file-link">Copy a file link</h3>
|
||||
<p>To share a file without opening it first, right-click on the file card or click its three-dot menu and select <strong>Copy link</strong>. Penpot copies the address of the file to your clipboard. People who open it need access to the team that owns the file. Every team member, Viewers included, can copy a file link.</p>
|
||||
<p>To open a file in a separate browser tab, select <strong>Open in new tab</strong> from the same menu.</p>
|
||||
|
||||
<h3 id="duplicate-file">Duplicate a file</h3>
|
||||
<p>To create a copy of an existing file, right-click on the file card and select <strong>Duplicate</strong>. The duplicated file will be created in the same location (project or drafts) with the same name plus "Copy" added to it. You can then rename or move it as needed.</p>
|
||||
<p>Duplicating a file creates a complete copy including all pages, boards, and design elements. This is useful when you want to create variations of a design or use a file as a starting point for a new project.</p>
|
||||
|
||||
19
frontend/playwright/data/dashboard/get-projects-pinned.json
Normal file
19
frontend/playwright/data/dashboard/get-projects-pinned.json
Normal file
@ -0,0 +1,19 @@
|
||||
[{
|
||||
"~:id": "~ue5a24d1b-ef1e-812f-8004-52bab84be6f7",
|
||||
"~:team-id": "~uc7ce0794-0992-8105-8004-38e630f40f6d",
|
||||
"~:created-at": "~m1715266551088",
|
||||
"~:modified-at": "~m1715266551088",
|
||||
"~:is-default": false,
|
||||
"~:name": "New Project 1",
|
||||
"~:is-pinned": true,
|
||||
"~:count": 1
|
||||
},
|
||||
{
|
||||
"~:id": "~uc7ce0794-0992-8105-8004-38e630f7920b",
|
||||
"~:team-id": "~uc7ce0794-0992-8105-8004-38e630f40f6d",
|
||||
"~:created-at": "~m1713533116382",
|
||||
"~:modified-at": "~m1713873823633",
|
||||
"~:is-default": true,
|
||||
"~:name": "Drafts",
|
||||
"~:count": 1
|
||||
}]
|
||||
@ -236,6 +236,12 @@ export class DashboardPage extends BaseWebSocketPage {
|
||||
);
|
||||
}
|
||||
|
||||
// The clipboard text parsed as a URL, as left by a "Copy link" action.
|
||||
async copiedLink() {
|
||||
const text = await this.page.evaluate(() => navigator.clipboard.readText());
|
||||
return new URL(text);
|
||||
}
|
||||
|
||||
async goToDashboard() {
|
||||
await this.page.goto(
|
||||
`/?screen=dashboard-recent&team-id=${DashboardPage.anyTeamId}`,
|
||||
|
||||
@ -45,10 +45,11 @@ test("A viewer sees no project or file edit affordances", async ({ page }) => {
|
||||
await button.click();
|
||||
await button.click({ button: "right" });
|
||||
|
||||
// A viewer keeps the two unconditional items (open in a new tab and
|
||||
// download). Anything gated by `can-edit` that leaks into the menu makes
|
||||
// this count grow, which is what the four labels below only describe.
|
||||
await expect(page.getByRole("menuitem")).toHaveCount(2);
|
||||
// A viewer keeps the three unconditional items (open in a new tab, copy
|
||||
// link and download). Anything gated by `can-edit` that leaks into the
|
||||
// menu makes this count grow, which is what the four labels below only
|
||||
// describe.
|
||||
await expect(page.getByRole("menuitem")).toHaveCount(3);
|
||||
|
||||
await expect(page.getByText("rename")).toBeHidden();
|
||||
await expect(page.getByText("duplicate")).toBeHidden();
|
||||
@ -57,6 +58,79 @@ test("A viewer sees no project or file edit affordances", async ({ page }) => {
|
||||
});
|
||||
});
|
||||
|
||||
test("A viewer can copy a file's link from the context menu", async ({
|
||||
page,
|
||||
}) => {
|
||||
await DashboardPage.mockRPC(
|
||||
page,
|
||||
"get-all-projects",
|
||||
"dashboard/get-all-projects.json",
|
||||
);
|
||||
|
||||
const dashboardPage = new DashboardPage(page);
|
||||
await dashboardPage.setupDrafts();
|
||||
await dashboardPage.goToDrafts();
|
||||
|
||||
const button = page.getByRole("button", { name: /New File 2/ });
|
||||
await button.click({ button: "right" });
|
||||
await page.getByTestId("file-copy-link").click();
|
||||
|
||||
await expect(
|
||||
page.getByRole("alert").filter({ hasText: "Link copied to clipboard" }),
|
||||
).toBeVisible();
|
||||
|
||||
const link = await dashboardPage.copiedLink();
|
||||
expect(link.searchParams.get("screen")).toBe("workspace");
|
||||
expect(link.searchParams.get("team-id")).toBe(DashboardPage.anyTeamId);
|
||||
expect(link.searchParams.get("file-id")).toBe(
|
||||
"8b479b80-e02d-8074-8004-4088dc6bfd11",
|
||||
);
|
||||
});
|
||||
|
||||
test("A viewer cannot open a pinned project's menu from the sidebar", async ({
|
||||
page,
|
||||
}) => {
|
||||
const dashboardPage = new DashboardPage(page);
|
||||
await dashboardPage.mockRPC(
|
||||
"get-projects?team-id=*",
|
||||
"dashboard/get-projects-pinned.json",
|
||||
);
|
||||
await dashboardPage.goToDashboard();
|
||||
|
||||
await page
|
||||
.getByTestId("pinned-projects")
|
||||
.getByText("New Project 1")
|
||||
.click({ button: "right" });
|
||||
|
||||
await expect(page.getByRole("menu")).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("A viewer's multiple selection menu has no Copy link and no separator", async ({
|
||||
page,
|
||||
}) => {
|
||||
await DashboardPage.mockRPC(
|
||||
page,
|
||||
"get-all-projects",
|
||||
"dashboard/get-all-projects.json",
|
||||
);
|
||||
|
||||
const dashboardPage = new DashboardPage(page);
|
||||
await dashboardPage.setupDrafts();
|
||||
await dashboardPage.goToDrafts();
|
||||
|
||||
const button = page.getByRole("button", { name: /New File 1/ });
|
||||
await button.click();
|
||||
await page
|
||||
.getByRole("button", { name: /New File 2/ })
|
||||
.click({ modifiers: ["Shift"] });
|
||||
await button.click({ button: "right" });
|
||||
|
||||
const menu = page.getByRole("menu");
|
||||
await expect(menu.getByTestId("file-binary-export-multi")).toBeVisible();
|
||||
await expect(menu.getByTestId("file-copy-link")).toHaveCount(0);
|
||||
await expect(menu.getByRole("separator")).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("A viewer cannot add a custom font", async ({ page }) => {
|
||||
const dashboardPage = new DashboardPage(page);
|
||||
|
||||
|
||||
@ -71,14 +71,44 @@ test("User has context menu options for edit file", async ({ page }) => {
|
||||
await button.click();
|
||||
await button.click({ button: "right" });
|
||||
|
||||
await expect(dashboardPage.page.getByText("open in new tab")).toBeVisible();
|
||||
await expect(dashboardPage.page.getByText("rename")).toBeVisible();
|
||||
await expect(dashboardPage.page.getByText("duplicate")).toBeVisible();
|
||||
await expect(dashboardPage.page.getByText("copy link")).toBeVisible();
|
||||
await expect(
|
||||
dashboardPage.page.getByText("add as shared library"),
|
||||
).toBeVisible();
|
||||
await expect(dashboardPage.page.getByText("delete")).toBeVisible();
|
||||
});
|
||||
|
||||
test("User can copy a file's link from the context menu", async ({ page }) => {
|
||||
await DashboardPage.mockRPC(
|
||||
page,
|
||||
"get-all-projects",
|
||||
"dashboard/get-all-projects.json",
|
||||
);
|
||||
|
||||
const dashboardPage = new DashboardPage(page);
|
||||
await dashboardPage.setupDrafts();
|
||||
await dashboardPage.goToDrafts();
|
||||
|
||||
const button = page.getByRole("button", { name: /New File 2/ });
|
||||
await button.click({ button: "right" });
|
||||
await page.getByTestId("file-copy-link").click();
|
||||
|
||||
await expect(
|
||||
page.getByRole("alert").filter({ hasText: "Link copied to clipboard" }),
|
||||
).toBeVisible();
|
||||
|
||||
const link = await dashboardPage.copiedLink();
|
||||
expect(`${link.origin}${link.pathname}`).toBe(new URL("/", page.url()).href);
|
||||
expect(link.searchParams.get("screen")).toBe("workspace");
|
||||
expect(link.searchParams.get("team-id")).toBe(DashboardPage.anyTeamId);
|
||||
expect(link.searchParams.get("file-id")).toBe(
|
||||
"8b479b80-e02d-8074-8004-4088dc6bfd11",
|
||||
);
|
||||
});
|
||||
|
||||
test("Multiple elements in context", async ({ page }) => {
|
||||
await DashboardPage.mockRPC(
|
||||
page,
|
||||
@ -104,6 +134,13 @@ test("Multiple elements in context", async ({ page }) => {
|
||||
await expect(page.getByTestId("file-move-multi")).toBeVisible();
|
||||
await expect(page.getByTestId("file-binary-export-multi")).toBeVisible();
|
||||
await expect(page.getByTestId("file-delete-multi")).toBeVisible();
|
||||
await expect(page.getByTestId("file-copy-link")).toHaveCount(0);
|
||||
|
||||
// A separator splits Move to from the download option.
|
||||
const previous = await page
|
||||
.getByTestId("file-binary-export-multi")
|
||||
.evaluate((el) => el.previousElementSibling?.getAttribute("role"));
|
||||
expect(previous).toBe("separator");
|
||||
});
|
||||
|
||||
test("User has create file button", async ({ page }) => {
|
||||
|
||||
@ -33,7 +33,8 @@ test("User can open a project's options menu from the \"...\" button", async ({
|
||||
const menu = page.getByRole("menu");
|
||||
await expect(menu.getByTestId("project-rename")).toBeVisible();
|
||||
await expect(menu.getByTestId("project-duplicate")).toBeVisible();
|
||||
await expect(menu.getByTestId("project-pin")).toBeVisible();
|
||||
await expect(menu.getByTestId("project-pin")).toHaveText("Pin");
|
||||
await expect(menu.getByTestId("project-copy-link")).toBeVisible();
|
||||
await expect(menu.getByTestId("project-delete")).toBeVisible();
|
||||
// project-move-to is covered separately below: it only renders once there
|
||||
// is at least one other team to move to, which the default single-team
|
||||
@ -72,6 +73,64 @@ test("The default Drafts project has a limited options menu", async ({
|
||||
await expect(menu.getByTestId("project-pin")).toHaveCount(0);
|
||||
await expect(menu.getByTestId("project-move-to")).toHaveCount(0);
|
||||
await expect(menu.getByTestId("project-delete")).toHaveCount(0);
|
||||
await expect(menu.getByTestId("project-copy-link")).toBeVisible();
|
||||
});
|
||||
|
||||
test("User can copy a project's link from the options menu", async ({
|
||||
page,
|
||||
}) => {
|
||||
const dashboardPage = new DashboardPage(page);
|
||||
await setupTwoProjects(dashboardPage);
|
||||
await dashboardPage.goToDashboard();
|
||||
|
||||
const row = projectRow(page, "New Project 1");
|
||||
await row.getByTestId("project-options").click();
|
||||
await page.getByTestId("project-copy-link").click();
|
||||
|
||||
await expect(
|
||||
page.getByRole("alert").filter({ hasText: "Link copied to clipboard" }),
|
||||
).toBeVisible();
|
||||
|
||||
const link = await dashboardPage.copiedLink();
|
||||
expect(`${link.origin}${link.pathname}`).toBe(new URL("/", page.url()).href);
|
||||
expect(link.searchParams.get("screen")).toBe("dashboard-files");
|
||||
expect(link.searchParams.get("team-id")).toBe(DashboardPage.anyTeamId);
|
||||
expect(link.searchParams.get("project-id")).toBe(
|
||||
"e5a24d1b-ef1e-812f-8004-52bab84be6f7",
|
||||
);
|
||||
});
|
||||
|
||||
test("A pinned project shows Unpin in the options menu", async ({ page }) => {
|
||||
const dashboardPage = new DashboardPage(page);
|
||||
await dashboardPage.mockRPC(
|
||||
"get-projects?team-id=*",
|
||||
"dashboard/get-projects-pinned.json",
|
||||
);
|
||||
await dashboardPage.setupDrafts();
|
||||
await dashboardPage.goToDashboard();
|
||||
|
||||
const row = projectRow(page, "New Project 1");
|
||||
await row.getByTestId("project-options").click();
|
||||
|
||||
await expect(page.getByTestId("project-pin")).toHaveText("Unpin");
|
||||
});
|
||||
|
||||
test("User can open a pinned project's menu from the sidebar", async ({
|
||||
page,
|
||||
}) => {
|
||||
const dashboardPage = new DashboardPage(page);
|
||||
await dashboardPage.mockRPC(
|
||||
"get-projects?team-id=*",
|
||||
"dashboard/get-projects-pinned.json",
|
||||
);
|
||||
await dashboardPage.goToDashboard();
|
||||
|
||||
await page
|
||||
.getByTestId("pinned-projects")
|
||||
.getByText("New Project 1")
|
||||
.click({ button: "right" });
|
||||
|
||||
await expect(page.getByTestId("project-copy-link")).toBeVisible();
|
||||
});
|
||||
|
||||
test("User can rename a project from the options menu", async ({ page }) => {
|
||||
|
||||
@ -27,7 +27,9 @@
|
||||
[app.main.data.team :as dtm]
|
||||
[app.main.data.websocket :as dws]
|
||||
[app.main.repo :as rp]
|
||||
[app.main.router :as rt]
|
||||
[app.main.store :as st]
|
||||
[app.util.clipboard :as clipboard]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[app.util.sse :as sse]
|
||||
[beicon.v2.core :as rx]
|
||||
@ -360,6 +362,26 @@
|
||||
(->> (rp/cmd! :update-project-pin params)
|
||||
(rx/ignore))))))
|
||||
|
||||
;; --- EVENT: copy-link
|
||||
|
||||
(defn copy-link
|
||||
"Copy the absolute URL of the route `id` with `params` to the
|
||||
clipboard and confirm it with a toast."
|
||||
[id params]
|
||||
(ptk/reify ::copy-link
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [url (rt/resolve-uri (:router state) id params)]
|
||||
(->> (rx/from (clipboard/to-clipboard url))
|
||||
(rx/map (fn [_]
|
||||
(ntf/success (tr "dashboard.success-copy-link"))))
|
||||
(rx/catch (fn [cause]
|
||||
(let [message (clipboard/error-message cause)]
|
||||
(when-not message
|
||||
(log/error :hint "unable to copy link" :cause cause))
|
||||
(rx/of (ntf/error (or message (tr "errors.generic"))
|
||||
{:timeout ntf/default-timeout}))))))))))
|
||||
|
||||
;; --- EVENT: rename-project
|
||||
|
||||
(defn rename-project
|
||||
|
||||
@ -96,11 +96,14 @@
|
||||
(dissoc state :notification)))))
|
||||
|
||||
(defn error
|
||||
([content]
|
||||
(show {:content content
|
||||
:level :error
|
||||
:type :toast
|
||||
:position :fixed})))
|
||||
([content] (error content {}))
|
||||
([content {:keys [timeout]}]
|
||||
(show (d/without-nils
|
||||
{:content content
|
||||
:level :error
|
||||
:type :toast
|
||||
:position :fixed
|
||||
:timeout timeout}))))
|
||||
|
||||
(defn info
|
||||
([content] (info content {}))
|
||||
|
||||
@ -118,6 +118,11 @@
|
||||
{:file-id (:id file)
|
||||
::rt/new-window true})))
|
||||
|
||||
on-copy-link
|
||||
(fn []
|
||||
(st/emit! (dd/copy-link :workspace {:team-id current-team-id
|
||||
:file-id (:id file)})))
|
||||
|
||||
on-duplicate
|
||||
(fn []
|
||||
(st/emit! (dd/duplicate-files files)))
|
||||
@ -274,6 +279,10 @@
|
||||
:current-team-id current-team-id
|
||||
:on-move on-move}]])
|
||||
|
||||
;; Without edit rights nothing comes above it.
|
||||
(when can-edit
|
||||
[:> menu-separator*])
|
||||
|
||||
[:> menu-item* {:id "file-binary-export-multi" :on-action on-export-binary-files}
|
||||
(tr "dashboard.export-binary-multi" file-count)]
|
||||
|
||||
@ -310,6 +319,9 @@
|
||||
:current-team-id current-team-id
|
||||
:on-move on-move}]])
|
||||
|
||||
[:> menu-item* {:id "file-copy-link" :on-action on-copy-link}
|
||||
(tr "dashboard.copy-link")]
|
||||
|
||||
(when (and (not is-search-page?) can-edit)
|
||||
;; Same id in both branches: :is-shared can flip while this menu
|
||||
;; instance stays mounted (the on-add-shared/on-del-shared action
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
(assert (fn? on-edit) "missing `on-edit` prop")
|
||||
|
||||
(let [is-default? (:is-default project)
|
||||
is-pinned? (:is-pinned project)
|
||||
|
||||
current-team-id (mf/use-ctx ctx/current-team-id)
|
||||
teams (mf/deref refs/teams)
|
||||
@ -57,6 +58,11 @@
|
||||
(fn []
|
||||
(st/emit! (dd/toggle-project-pin project)))
|
||||
|
||||
on-copy-link
|
||||
(fn []
|
||||
(st/emit! (dd/copy-link :dashboard-files {:team-id (:team-id project)
|
||||
:project-id (:id project)})))
|
||||
|
||||
on-move-success
|
||||
(fn [team-id]
|
||||
(st/emit! (dcm/go-to-dashboard-recent :team-id team-id)))
|
||||
@ -93,9 +99,13 @@
|
||||
[:> menu-item* {:id "project-duplicate" :on-action on-duplicate}
|
||||
(tr "dashboard.duplicate")])
|
||||
|
||||
;; Same id in both branches, as file-menu's shared toggle: the label
|
||||
;; flips with :is-pinned, the item does not.
|
||||
(when-not is-default?
|
||||
[:> menu-item* {:id "project-pin" :on-action toggle-pin}
|
||||
(tr "dashboard.pin-unpin")])
|
||||
(if is-pinned?
|
||||
(tr "dashboard.unpin")
|
||||
(tr "dashboard.pin"))])
|
||||
|
||||
(when (and (seq other-teams) (not is-default?))
|
||||
[:> sub-menu* {:id "project-move-to" :trigger (tr "dashboard.move-to") :variant "drilldown"}
|
||||
@ -105,9 +115,14 @@
|
||||
:on-action (on-move (:id team))}
|
||||
(:name team)])])
|
||||
|
||||
[:> menu-item* {:id "project-copy-link" :on-action on-copy-link}
|
||||
(tr "dashboard.copy-link")]
|
||||
|
||||
(when (some? on-import-click)
|
||||
[:> menu-item* {:id "file-import" :on-action on-import-click}
|
||||
(tr "dashboard.import")])
|
||||
[:*
|
||||
[:> menu-separator*]
|
||||
[:> menu-item* {:id "file-import" :on-action on-import-click}
|
||||
(tr "dashboard.import")]])
|
||||
|
||||
(when-not is-default?
|
||||
[:*
|
||||
|
||||
@ -57,7 +57,7 @@
|
||||
|
||||
(mf/defc sidebar-project*
|
||||
{::mf/private true}
|
||||
[{:keys [item is-selected]}]
|
||||
[{:keys [item is-selected can-edit]}]
|
||||
(let [dstate (mf/deref refs/dashboard-local)
|
||||
selected-files (:selected-files dstate)
|
||||
selected-project (:selected-project dstate)
|
||||
@ -141,6 +141,7 @@
|
||||
(st/emit! (dd/move-files (with-meta data mdata)))))))]
|
||||
|
||||
[:> context-menu* {:aria-label (tr "dashboard.options")
|
||||
:is-disabled (not can-edit)
|
||||
:trigger
|
||||
(mf/html
|
||||
[:li {:tab-index "0"
|
||||
@ -150,7 +151,7 @@
|
||||
:dragging (:dragging? local))
|
||||
:on-click on-click
|
||||
:on-key-down on-key-down
|
||||
:on-double-click on-edit-open
|
||||
:on-double-click (when can-edit on-edit-open)
|
||||
:on-drag-enter on-drag-enter
|
||||
:on-drag-over on-drag-over
|
||||
:on-drag-leave on-drag-leave
|
||||
@ -385,7 +386,8 @@
|
||||
:key (dm/str (:id item))
|
||||
:id (:id item)
|
||||
:team-id (:id team)
|
||||
:is-selected (= (:id item) (:id project))}])]
|
||||
:is-selected (= (:id item) (:id project))
|
||||
:can-edit (-> team :permissions :can-edit)}])]
|
||||
[:div {:class (stl/css :sidebar-empty-placeholder)}
|
||||
[:> icon* {:icon-id i/pin
|
||||
:size "s"
|
||||
|
||||
@ -16,9 +16,11 @@
|
||||
[app.main.data.websocket :as dws]
|
||||
[app.main.repo :as rp]
|
||||
[app.main.router :as rt]
|
||||
[app.util.clipboard :as clipboard]
|
||||
[app.util.i18n :as i18n]
|
||||
[beicon.v2.core :as rx]
|
||||
[cljs.test :as t :include-macros true]
|
||||
[cuerdas.core :as str]
|
||||
[frontend-tests.helpers.async :as async]
|
||||
[frontend-tests.helpers.mock :as mock]
|
||||
[potok.v2.core :as ptk]))
|
||||
@ -298,3 +300,51 @@
|
||||
(await (async/wait-for #(seq @errors) "the copy fails"))
|
||||
(await (async/settle))
|
||||
(t/is (nil? (:notification @store)))))))
|
||||
|
||||
(defn- run-copy-link
|
||||
"Runs copy-link for the workspace of a new file with `to-clipboard`
|
||||
mocked, and returns the copied text and the resulting notification."
|
||||
[to-clipboard]
|
||||
(let [team-id (uuid/next)
|
||||
file-id (uuid/next)
|
||||
copied (atom nil)
|
||||
result (atom {:router #{:workspace}})
|
||||
event (dd/copy-link :workspace {:team-id team-id :file-id file-id})]
|
||||
(-> (mock/with-mocks*
|
||||
{clipboard/to-clipboard (mock/stub (fn [text]
|
||||
(reset! copied text)
|
||||
(to-clipboard text)))}
|
||||
(await (async/observe (ptk/watch event @result nil)
|
||||
:on-next #(swap! result (partial ptk/update %)))))
|
||||
(.then (fn [_]
|
||||
{:team-id team-id
|
||||
:file-id file-id
|
||||
:copied @copied
|
||||
:notification (:notification @result)})))))
|
||||
|
||||
(t/deftest ^:async copy-link-copies-the-route-url-and-confirms
|
||||
(let [{:keys [team-id file-id copied notification]}
|
||||
(await (run-copy-link (fn [_] (js/Promise.resolve nil))))]
|
||||
(t/is (str/includes? copied "screen=workspace"))
|
||||
(t/is (str/includes? copied (str "team-id=" team-id)))
|
||||
(t/is (str/includes? copied (str "file-id=" file-id)))
|
||||
(t/is (= :success (:level notification)))
|
||||
(t/is (= (i18n/tr "dashboard.success-copy-link") (:content notification)))))
|
||||
|
||||
(t/deftest ^:async copy-link-reports-an-unavailable-clipboard
|
||||
(let [{:keys [notification]}
|
||||
(await (run-copy-link
|
||||
(fn [_]
|
||||
(js/Promise.reject
|
||||
(js/Error. "Clipboard API is unavailable. Serve over HTTPS.")))))]
|
||||
(t/is (= :error (:level notification)))
|
||||
(t/is (= (i18n/tr "errors.clipboard-api-unavailable") (:content notification)))
|
||||
(t/is (= ntf/default-timeout (:timeout notification)))))
|
||||
|
||||
(t/deftest ^:async copy-link-reports-an-unknown-error
|
||||
(let [{:keys [notification]}
|
||||
(await (run-copy-link
|
||||
(fn [_] (js/Promise.reject (js/Error. "unexpected")))))]
|
||||
(t/is (= :error (:level notification)))
|
||||
(t/is (= (i18n/tr "errors.generic") (:content notification)))
|
||||
(t/is (= ntf/default-timeout (:timeout notification)))))
|
||||
|
||||
@ -364,6 +364,10 @@ msgstr "Clear search"
|
||||
msgid "dashboard.clear-trash-button"
|
||||
msgstr "Clear trash"
|
||||
|
||||
#: src/app/main/ui/dashboard/file_menu.cljs:323, src/app/main/ui/dashboard/project_menu.cljs:119
|
||||
msgid "dashboard.copy-link"
|
||||
msgstr "Copy link"
|
||||
|
||||
#: src/app/main/data/dashboard.cljs:318, src/app/main/data/dashboard.cljs:568, src/app/main/data/workspace/pages.cljs:206
|
||||
msgid "dashboard.copy-suffix"
|
||||
msgstr "(copy)"
|
||||
@ -1011,9 +1015,9 @@ msgstr "View notifications"
|
||||
msgid "dashboard.num-of-members"
|
||||
msgstr "%s members"
|
||||
|
||||
#: src/app/main/ui/dashboard/file_menu.cljs:293
|
||||
#: src/app/main/ui/dashboard/file_menu.cljs:302
|
||||
msgid "dashboard.open-in-new-tab"
|
||||
msgstr "Open file in a new tab"
|
||||
msgstr "Open in new tab"
|
||||
|
||||
#: src/app/main/ui/dashboard/deleted.cljs:167, src/app/main/ui/dashboard/files.cljs:153, src/app/main/ui/dashboard/grid.cljs:441, src/app/main/ui/dashboard/grid.cljs:452, src/app/main/ui/dashboard/grid.cljs:494, src/app/main/ui/dashboard/projects.cljs:226, src/app/main/ui/dashboard/projects.cljs:283, src/app/main/ui/dashboard/sidebar.cljs:143
|
||||
msgid "dashboard.options"
|
||||
@ -1059,7 +1063,11 @@ msgstr "You are now a viewer on this team."
|
||||
msgid "dashboard.personal-projects"
|
||||
msgstr "Personal Projects"
|
||||
|
||||
#: src/app/main/ui/dashboard/files.cljs:132, src/app/main/ui/dashboard/project_menu.cljs:98, src/app/main/ui/dashboard/projects.cljs:260
|
||||
#: src/app/main/ui/dashboard/project_menu.cljs:108
|
||||
msgid "dashboard.pin"
|
||||
msgstr "Pin"
|
||||
|
||||
#: src/app/main/ui/dashboard/files.cljs:132, src/app/main/ui/dashboard/projects.cljs:269
|
||||
msgid "dashboard.pin-unpin"
|
||||
msgstr "Pin/Unpin"
|
||||
|
||||
@ -1281,6 +1289,10 @@ msgstr "Show all files"
|
||||
msgid "dashboard.show-version-history"
|
||||
msgstr "Version history"
|
||||
|
||||
#: src/app/main/data/dashboard.cljs:377
|
||||
msgid "dashboard.success-copy-link"
|
||||
msgstr "Link copied to clipboard"
|
||||
|
||||
#: src/app/main/ui/dashboard/file_menu.cljs:128
|
||||
msgid "dashboard.success-delete-file"
|
||||
msgid_plural "dashboard.success-delete-file"
|
||||
@ -1401,6 +1413,10 @@ msgstr ""
|
||||
msgid "dashboard.type-something"
|
||||
msgstr "Type to search results"
|
||||
|
||||
#: src/app/main/ui/dashboard/project_menu.cljs:107
|
||||
msgid "dashboard.unpin"
|
||||
msgstr "Unpin"
|
||||
|
||||
#: src/app/main/ui/dashboard/file_menu.cljs:321, src/app/main/ui/workspace/main_menu.cljs:693
|
||||
msgid "dashboard.unpublish-shared"
|
||||
msgstr "Unpublish Library"
|
||||
|
||||
@ -370,6 +370,10 @@ msgstr "Borrar búsqueda"
|
||||
msgid "dashboard.clear-trash-button"
|
||||
msgstr "Vaciar papelera"
|
||||
|
||||
#: src/app/main/ui/dashboard/file_menu.cljs:323, src/app/main/ui/dashboard/project_menu.cljs:119
|
||||
msgid "dashboard.copy-link"
|
||||
msgstr "Copiar enlace"
|
||||
|
||||
#: src/app/main/data/dashboard.cljs:318, src/app/main/data/dashboard.cljs:568, src/app/main/data/workspace/pages.cljs:206
|
||||
msgid "dashboard.copy-suffix"
|
||||
msgstr "(copia)"
|
||||
@ -1030,7 +1034,7 @@ msgstr "Ver notificaciones"
|
||||
msgid "dashboard.num-of-members"
|
||||
msgstr "%s integrantes"
|
||||
|
||||
#: src/app/main/ui/dashboard/file_menu.cljs:293
|
||||
#: src/app/main/ui/dashboard/file_menu.cljs:302
|
||||
msgid "dashboard.open-in-new-tab"
|
||||
msgstr "Abrir en una pestaña nueva"
|
||||
|
||||
@ -1078,7 +1082,11 @@ msgstr "Ahora eres lector del equipo."
|
||||
msgid "dashboard.personal-projects"
|
||||
msgstr "Proyectos Personales"
|
||||
|
||||
#: src/app/main/ui/dashboard/files.cljs:132, src/app/main/ui/dashboard/project_menu.cljs:98, src/app/main/ui/dashboard/projects.cljs:260
|
||||
#: src/app/main/ui/dashboard/project_menu.cljs:108
|
||||
msgid "dashboard.pin"
|
||||
msgstr "Anclar"
|
||||
|
||||
#: src/app/main/ui/dashboard/files.cljs:132, src/app/main/ui/dashboard/projects.cljs:269
|
||||
msgid "dashboard.pin-unpin"
|
||||
msgstr "Anclar/Desanclar"
|
||||
|
||||
@ -1301,6 +1309,10 @@ msgstr "Ver todos los archivos"
|
||||
msgid "dashboard.show-version-history"
|
||||
msgstr "Histórico de versiones"
|
||||
|
||||
#: src/app/main/data/dashboard.cljs:377
|
||||
msgid "dashboard.success-copy-link"
|
||||
msgstr "Enlace copiado al portapapeles"
|
||||
|
||||
#: src/app/main/ui/dashboard/file_menu.cljs:128
|
||||
msgid "dashboard.success-delete-file"
|
||||
msgid_plural "dashboard.success-delete-file"
|
||||
@ -1421,6 +1433,10 @@ msgstr ""
|
||||
msgid "dashboard.type-something"
|
||||
msgstr "Escribe algo para buscar"
|
||||
|
||||
#: src/app/main/ui/dashboard/project_menu.cljs:107
|
||||
msgid "dashboard.unpin"
|
||||
msgstr "Desanclar"
|
||||
|
||||
#: src/app/main/ui/dashboard/file_menu.cljs:321, src/app/main/ui/workspace/main_menu.cljs:693
|
||||
msgid "dashboard.unpublish-shared"
|
||||
msgstr "Despublicar Biblioteca"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user