Unverified Commit a237775e authored by Marius van den Beek's avatar Marius van den Beek Committed by GitHub
Browse files

Merge pull request #20385 from davelopez/25.0_fix_create_file_source_only_root

[25.0] Fix create file source button, show only at root
parents 8c2a2885 5558f985
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -256,8 +256,32 @@ describe("FilesDialog, file mode", () => {
        await utils.navigateBack();
        expect(utils.getRenderedRows().length).toBe(rootResponse.length);
    });
});

describe("FilesDialog, create new file source button", () => {
    let wrapper: Wrapper<any>;
    let utils: Utils;

    beforeEach(async () => {
        const hasTemplates = true;
        wrapper = await initComponent({ multiple: false }, hasTemplates);
        utils = new Utils(wrapper);
    });
    it("should not render create new button since file source templates are not defined", async () => {
        const hasTemplates = false;
        wrapper = await initComponent({ multiple: true }, hasTemplates);
        const createNewButton = wrapper.find("[data-description='create new file source button']");
        expect(createNewButton.exists()).toBe(false);
    });

    it("should render create new button since file source templates are defined and is at root", async () => {
        await utils.openRoot();
        const createNewButton = wrapper.find("[data-description='create new file source button']");
        expect(createNewButton.exists()).toBe(true);
    });

    it("should not render create new button inside folders", async () => {
        await utils.openRootDirectory();
        const createNewButton = wrapper.find("[data-description='create new file source button']");
        expect(createNewButton.exists()).toBe(false);
    });
+5 −1
Original line number Diff line number Diff line
@@ -107,6 +107,10 @@ const okButtonDisabled = computed(
    () => (fileMode.value && !hasValue.value) || isBusy.value || (!fileMode.value && urlTracker.value.atRoot())
);

const canCreateNewFileSource = computed(() => {
    return urlTracker.value.atRoot() && fileSourceTemplatesStore.hasTemplates;
});

const fileSourceTemplatesStore = useFileSourceTemplatesStore();
fileSourceTemplatesStore.ensureTemplates();

@@ -476,7 +480,7 @@ onMounted(() => {
        </template>
        <template v-slot:buttons>
            <GButton
                v-if="fileSourceTemplatesStore.hasTemplates"
                v-if="canCreateNewFileSource"
                tooltip
                size="small"
                title="Create a new remote file source"