Merge pull request #17343 from davelopez/merge_23.1_into_23.2

Merge 23.1 into 23.2
This commit is contained in:
John Davis
2024-01-23 09:44:37 -05:00
committed by GitHub
2 changed files with 28 additions and 35 deletions
+20 -34
View File
@@ -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: "<div></div>" },
},
});
}
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: "<div></div>" },
},
});
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: "<div></div>" },
},
});
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: "<div></div>" },
},
});
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: "<div></div>" },
},
});
mountPublishedGrid();
await flushPromises();
});
+8 -1
View File
@@ -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)" />
</template>
@@ -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;