Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hidden: true is not working on saneShopifyConfig #174

Open
agonsgd opened this issue Jul 2, 2021 · 7 comments
Open

Hidden: true is not working on saneShopifyConfig #174

agonsgd opened this issue Jul 2, 2021 · 7 comments
Labels
bug Something isn't working

Comments

@agonsgd
Copy link

agonsgd commented Jul 2, 2021

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.

@agonsgd agonsgd added the bug Something isn't working label Jul 2, 2021
@synim-sogody
Copy link

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
Copy link
Owner

@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
Copy link
Owner

@allcontributors please add @synim-sogody for bug

@allcontributors
Copy link
Contributor

@good-idea

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

@good-idea
Copy link
Owner

@allcontributors please add @agonsgd for bug

@allcontributors
Copy link
Contributor

@good-idea

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

@agonsgd
Copy link
Author

agonsgd commented Jul 5, 2021

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants