good-idea / sane-shopify

MIT License
212 stars 15 forks source link

Hidden: true is not working on saneShopifyConfig #174

Open agonsgd opened 3 years ago

agonsgd commented 3 years ago

Hello, I am using the following code to hide some information that I don't need to be shown on Sanity studio

                        {
                name: "options",
                hidden: true,
            },
            {
                name: "title",
                hidden: true,
            },
            {
                name: "collections",
                hidden: true,
            },

But it does not work at all as those are still visible on the studio.

I am on version 0.22.0 and using WINDOWS 10

Thank you.

synim-sogody commented 3 years ago

Facing the same issue. However this is appearing not only on Windows, but production as well. @good-idea do you happen to know if this is only a recent problem or is the hidden feature limited to certain fields by design?

good-idea commented 3 years ago

@agonsgd @synim-sogody , odd, I'm not able to reproduce this. I have configs that look like this:

// ./schemas/saneShopify/product.js

export const product = {
  fields: [
    {
      name: 'sourceData',
      hidden: true,
    },
    {
      name: 'collections',
      hidden: true,
    },
    {
      title: 'Related',
      type: 'array',
      name: 'related',
      description: 'Link to a Page, Product, Collection, or URL',
      of: [
        {
          type: 'pageLink',
          options: {
            collections: false,
          },
        },
      ],
    },
  ],
}
// ./schemas/schema.js

import createSchema from 'part:@sanity/base/schema-creator'
import schemaTypes from 'all:part:@sanity/base/schema-type'
import { product } from './saneShopify/product'
import { collection } from './saneShopify/collection'
import { saneShopify } from '@sane-shopify/sanity-plugin'

const saneShopifySchema = saneShopify({
  product,
  collection,
})

import * as objects from './objects'
import * as documents from './documents'

// Then we give our schema to the builder and provide the result to Sanity
export default createSchema({
  name: 'default',
  // Then proceed to concatenate our our document type
  // to the ones provided by any plugins that are installed
  types: schemaTypes.concat([
    ...Object.values(objects),
    ...Object.values(documents),
    ...saneShopifySchema,
  ]),
})

Could you share your full config for the product/collection schemas and how you're adding them to createSchema?

good-idea commented 3 years ago

@allcontributors please add @synim-sogody for bug

allcontributors[bot] commented 3 years ago

@good-idea

I've put up a pull request to add @synim-sogody! :tada:

good-idea commented 3 years ago

@allcontributors please add @agonsgd for bug

allcontributors[bot] commented 3 years ago

@good-idea

I've put up a pull request to add @agonsgd! :tada:

agonsgd commented 3 years ago

@agonsgd @synim-sogody , odd, I'm not able to reproduce this. I have configs that look like this:

// ./schemas/saneShopify/product.js

export const product = {
  fields: [
    {
      name: 'sourceData',
      hidden: true,
    },
    {
      name: 'collections',
      hidden: true,
    },
    {
      title: 'Related',
      type: 'array',
      name: 'related',
      description: 'Link to a Page, Product, Collection, or URL',
      of: [
        {
          type: 'pageLink',
          options: {
            collections: false,
          },
        },
      ],
    },
  ],
}
// ./schemas/schema.js

import createSchema from 'part:@sanity/base/schema-creator'
import schemaTypes from 'all:part:@sanity/base/schema-type'
import { product } from './saneShopify/product'
import { collection } from './saneShopify/collection'
import { saneShopify } from '@sane-shopify/sanity-plugin'

const saneShopifySchema = saneShopify({
  product,
  collection,
})

import * as objects from './objects'
import * as documents from './documents'

// Then we give our schema to the builder and provide the result to Sanity
export default createSchema({
  name: 'default',
  // Then proceed to concatenate our our document type
  // to the ones provided by any plugins that are installed
  types: schemaTypes.concat([
    ...Object.values(objects),
    ...Object.values(documents),
    ...saneShopifySchema,
  ]),
})

Could you share your full config for the product/collection schemas and how you're adding them to createSchema?

const saneShopifyConfig = {
    product: {
        fieldsets: [
            {
                name: "shopifyInfo",
                title: "Shopify product information",
                options: {
                    collapsible: true,
                    collapsed: false,
                },
            },
            {
                name: "sanityInfo",
                title: "Page Meta",
                options: {
                    collapsible: true,
                    collapsed: true,
                },
            },
        ],
        fields: [
            //Hidden fields
            {
                name: 'sourceData',
                hidden: true,
              },
            {
                name: "options",
                hidden: true,
            },
            {
                name: "title",
                hidden: true,
            },
            {
                name: "collections",
                hidden: true,
            },

            {
                name: "variants",
                fieldset: "shopifyInfo",
            },

            {
                title: "Product template",
                type: "string",
                name: "pdpTemplate",
                options: {
                    list: [
                        { title: "Default", value: "default" },
                        { title: "Knife", value: "knife" },
                        { title: "Service", value: "service" },
                    ],
                    direction: "horizontal",
                    layout: "radio",
                },
                // initialValue: "default",
                fieldset: "shopifyInfo",
            },
            {
                title: "Product content",
                type: "array",
                name: "module",
                of: [{ type: "twoColumns" }, { type: "singleVideo" }, { type: "testimonial" }, { type: "videoTestimonial" }, { type: "mediaTab" }],
                options: {
                    layout: "list",
                },
                fieldset: "shopifyInfo",
            },

            {
                title: "Page meta",
                type: "metaTags",
                name: "seoSettings",
                fieldset: "sanityInfo",
            },
        ],

        preview: {
            //Create products preview
            select: {
                title: "title",
                subtitle: "minVariantPrice",
                media: "sourceData.media.edges[0].node.image.w100",
            },
            prepare(selection) {
                const { title, subtitle, media } = selection;
                return {
                    title: title,
                    subtitle: subtitle.toString() + "€",
                    media: <img src={media} />,
                };
            },
        },
    },
    productVariant: {
        fields: [
            {
                name: "variantImages",
                type: "array",
                title: "Variant images",
                of: [{ type: "image" }],
            },
            {
                title: "id",
                type: "string",
                name: "id",
                hidden: true,
            },
        ],
        preview: {
            //Create products preview
            select: {
                title: "title",
                subtitle: "minVariantPrice",
                media: "sourceData.image.w100",
            },
            prepare(selection) {
                const { title, media } = selection;
                return {
                    title: title,
                    media: <img src={media} />,
                };
            },
        },
    },
    // collection: {},
    // productOption: {},
    // productOptionValue: {},
};

Then I am using the default code for concat schemas:

export default createSchema({
    name: "default",
    types: schemaTypes.concat([
        ...saneShopifyTypes
    ]),
});

Thank you.