diff --git a/client/src/components/Page/PageList.test.js b/client/src/components/Page/PageList.test.js index 5bbce2dc08e4..ef61d1f07397 100644 --- a/client/src/components/Page/PageList.test.js +++ b/client/src/components/Page/PageList.test.js @@ -5,6 +5,7 @@ import MockAdapter from "axios-mock-adapter"; import { formatDistanceToNow, parseISO } from "date-fns"; import flushPromises from "flush-promises"; import { PiniaVuePlugin } from "pinia"; +import { useUserStore } from "stores/userStore"; import { getLocalVue, wait } from "tests/jest/helpers"; import PageList from "./PageList.vue"; @@ -98,16 +99,29 @@ describe("PgeList.vue", () => { const mockPublishedPageData = [publishedPage]; const mockTwoPageData = [privatePage, pageA]; - function mountPersonalGrid() { + function mountGrid(propsData) { + const pinia = createTestingPinia(); + const userStore = useUserStore(); + userStore.currentUser = { username: "jimmyPage", tags_used: [] }; + wrapper = mount(PageList, { - propsData: propsDataPersonalGrid, + propsData, localVue, + pinia, stubs: { icon: { template: "
" }, }, }); } + function mountPersonalGrid() { + mountGrid(propsDataPersonalGrid); + } + + function mountPublishedGrid() { + mountGrid(propsDataPublishedGrid); + } + describe(" with empty page list", () => { beforeEach(async () => { axiosMock.onAny().reply(200, [], { total_matches: "0" }); @@ -145,14 +159,7 @@ describe("PgeList.vue", () => { jest.spyOn(PageList.methods, "decorateData").mockImplementation((page) => { page.shared = false; }); - wrapper = mount(PageList, { - propsData: propsDataPersonalGrid, - localVue, - pinia: createTestingPinia(), - stubs: { - icon: { template: "" }, - }, - }); + mountPersonalGrid(); await flushPromises(); }); @@ -215,14 +222,7 @@ describe("PgeList.vue", () => { jest.spyOn(PageList.methods, "decorateData").mockImplementation((page) => { page.shared = true; }); - wrapper = mount(PageList, { - propsData: propsDataPersonalGrid, - localVue, - pinia: createTestingPinia(), - stubs: { - icon: { template: "" }, - }, - }); + mountPersonalGrid(); await flushPromises(); }); it("updates filter when published icon is clicked", async () => { @@ -257,14 +257,7 @@ describe("PgeList.vue", () => { jest.spyOn(PageList.methods, "decorateData").mockImplementation((page) => { page.shared = false; }); - wrapper = mount(PageList, { - propsData: propsDataPublishedGrid, - localVue, - pinia: createTestingPinia(), - stubs: { - icon: { template: "" }, - }, - }); + mountPublishedGrid(); await flushPromises(); }); @@ -301,14 +294,7 @@ describe("PgeList.vue", () => { jest.spyOn(PageList.methods, "decorateData").mockImplementation((page) => { page.shared = false; }); - wrapper = mount(PageList, { - propsData: propsDataPublishedGrid, - localVue, - pinia: createTestingPinia(), - stubs: { - icon: { template: "" }, - }, - }); + mountPublishedGrid(); await flushPromises(); }); diff --git a/client/src/components/Page/PageList.vue b/client/src/components/Page/PageList.vue index 619bb0067139..2f941d190b5a 100644 --- a/client/src/components/Page/PageList.vue +++ b/client/src/components/Page/PageList.vue @@ -50,7 +50,7 @@ clickable :value="row.item.tags" :index="row.index" - :disabled="published" + :disabled="published || !currentUserOwnsItem(row.item)" @input="(tags) => onTags(tags, row.index)" @tag-click="(tag) => applyFilter('tag', tag, true)" /> @@ -100,11 +100,13 @@ import StatelessTags from "components/TagsMultiselect/StatelessTags"; import UtcDate from "components/UtcDate"; import paginationMixin from "components/Workflow/paginationMixin"; import { getAppRoot } from "onload/loadConfig"; +import { storeToRefs } from "pinia"; import Filtering, { contains, equals, expandNameTag, toBool } from "utils/filtering"; import _l from "utils/localization"; import { useRouter } from "vue-router/composables"; import { updateTags } from "@/api/tags"; +import { useUserStore } from "@/stores/userStore"; import { absPath } from "@/utils/redirect"; import PageDropdown from "./PageDropdown"; @@ -224,8 +226,10 @@ export default { }, setup() { const router = useRouter(); + const { currentUser } = storeToRefs(useUserStore()); return { router, + currentUser, }; }, data() { @@ -304,6 +308,9 @@ export default { shareLink: function (item) { this.router.push(`sharing?id=${item.id}`); }, + currentUserOwnsItem: function (item) { + return item.username === this.currentUser.username; + }, decorateData(page) { const Galaxy = getGalaxyInstance(); page.shared = page.username !== Galaxy.user.attributes.username; diff --git a/client/src/components/Workflow/Editor/Index.vue b/client/src/components/Workflow/Editor/Index.vue index e36b50df1d29..6393f55200e3 100644 --- a/client/src/components/Workflow/Editor/Index.vue +++ b/client/src/components/Workflow/Editor/Index.vue @@ -689,11 +689,15 @@ export default { const runUrl = `/workflows/run?id=${this.id}`; this.onNavigate(runUrl); }, - onNavigate(url) { - this.onSave(true).then(() => { - this.hasChanges = false; - this.$router.push(url); - }); + async onNavigate(url) { + if (this.isNewTempWorkflow) { + await this.onCreate(); + } else { + await this.onSave(true); + } + + this.hasChanges = false; + this.$router.push(url); }, onSave(hideProgress = false) { if (!this.nameValidate()) { diff --git a/client/src/entry/analysis/App.vue b/client/src/entry/analysis/App.vue index 927ac0578c8c..f9a04516a80a 100644 --- a/client/src/entry/analysis/App.vue +++ b/client/src/entry/analysis/App.vue @@ -2,44 +2,49 @@