Strapi Hide Content Type - content-type

I've search for several hours how to hide a specific content type.
I found some post but they are too older and their solutions doesn't work in the actual's strapi.
For precisions, my collection type is declared inside a local plugin. I juste want to manage my collection inside the plugin page and I doesn't want it appear in the content type in the left menu.
If someone has a solution, it's can be really helpfull.

In new version of Strapi v3.6.6 — Community Edition there is an option in model
{
"kind": "collectionType",
"collectionName": "test",
"info": {
"name": "test"
},
"options": {
"increments": true,
"timestamps": true,
"draftAndPublish": true
},
**"pluginOptions": {
"content-manager": {
"visible": false
}
},**
"attributes": {
"name": {
"type": "string",
"required": true
},
}
}

They are working on this: https://github.com/strapi/rfcs/pull/22
But for now, based on official docs (plugin customization), you can overwrite file in content-manager plugin.
Be sure to check this file on strapi updates to avoid overwriting important code.
Copy file strapi-plugin-content-manager/services/data-mapper.js from your app node_modules into extensions/content-manager/services/
Now edit this file in your project and add your content type to array HIDDEN_CONTENT_TYPES following this pattern: plugins::[plugin-name].[content-type]
For example: plugins::ecommerce.product
...
const HIDDEN_CONTENT_TYPES = [
'plugins::upload.file',
'plugins::users-permissions.permission',
'plugins::users-permissions.role',
'plugins::ecommerce.product',
];
...

You can extend the plugin to make updates to the content-type's schema.
Copy the content-type schema from the plugin to your src folder.
In my case, I copied /strapi-plugin-navigation/server/content-types/audience/schema.json to /src/extensions/navigation/content-types/audience/schema.json (notice that the strapi-plugin- part of the folder name is removed) and added the following to it to hide the "Audience" content type from the content manager and content-type builder:
"pluginOptions": {
"content-manager": {
"visible": false
},
"content-type-builder": {
"visible": false
}
},
Official documentation here.

In Strapi v4 it is "visible": false
{
"kind": "collectionType",
"collectionName": "bookmark",
"info": {
"singularName": "bookmark",
"pluralName": "bookmarks",
"displayName": "Bookmark",
"description": ""
},
"options": {
"increments": true,
"timestamps": true,
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"index": {
"type": "integer",
"unique": false,
"visible": false
},
}
}

Related

How to inject CSS with user origin in a browser extension?

I have a very simple extension:
{
"manifest_version": 2,
"name": "User Style Sheet Workaround",
"version": "1",
"content_scripts": [
{
"matches": ["<all_urls>"],
"css": ["default.css"]
}
]
}
I want default.css to be injected as user origin, not as author origin. How can I do it?
Use chrome.tabs.insertCSS with cssOrigin: 'user' in the background script's URL change event.
For example, chrome.webNavigation.onCommitted (requires webNavigation permission) or chrome.tabs.onUpdated (doesn't require any special permissions).
The target sites to allow CSS injection should be added to permissions.
manifest.json:
{
"manifest_version": 2,
"name": "User Style Sheet Workaround",
"version": "1",
"background": {
"scripts": ["bg.js"]
},
"permissions": ["<all_urls>"]
}
bg.js:
chrome.tabs.onUpdated.addListener((tabId, info) => {
if (info.status === 'loading') {
chrome.tabs.insertCSS(tabId, {
file: 'style.css',
cssOrigin: 'user',
runAt: 'document_start',
// allFrames: true,
// matchAboutBlank: true,
}, () => chrome.runtime.lastError); // ignoring errors
}
});

Conditionally add site property using ARM templates

I have a situation where I sometimes want my site to have a hostNameSslStates property. I have been trying to figure out how to do this without having seperate deployments for sites with a hostNameSslState and sites without.
This is how I would add a site today, I then add slots, config, certifcates, roles etc so the total ARM file is much larger.
{
"name": "[parameters('appServiceName')]",
"type": "Microsoft.Web/sites",
"apiVersion": "2018-11-01",
"location": "[parameters('location')]",
"tags": {
"displayName": "AppService"
},
"identity": {
"type": "SystemAssigned"
},
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]",
"siteConfig": "[variables('siteConfig')]",
"hostNameSslStates": [
{
"name": "[parameters('websiteCustomDomainName')]",
"sslState": "SniEnabled",
"thumbprint": "[reference(resourceId('Microsoft.Web/certificates', variables('certificateName'))).Thumbprint]",
"toUpdate": true
}
]
}
}
The problem is that some app services does not have a custom domain and does not need a hostNameSslStates property and I am not able to find a solution to how to implement this in the template. I can have a variable that is "hostNameSslState" but I am not able to condition the property. If I could specify hostNameSslStates as a seperate resource then that would solve my issue but I have not been able to figure it out.
you can do this:
"hostNameSslStates": "[if(something, variables('sslStuff'), json('[]'))]"
and then in your variables define sslStuff:
"sslStuff": [
{
"name": "[parameters('websiteCustomDomainName')]",
"sslState": "SniEnabled",
"thumbprint": "[reference(resourceId('Microsoft.Web/certificates', variables('certificateName'))).Thumbprint]",
"toUpdate": true
}
}

View not displaying Model Data from Manifest.json

I'm trying to setup my app descriptor file (manifest.json) to include a named model, 'inputs' in its "models" object. From my understanding, after doing so, the model should be available throughout the app when provided the correct path (see XML View).
The reason I'd like to setup this manifest.json is because it's a best practice to configure all models in here.
In the controller, I'd like to get and then set the 'inputs' Model defined in the manifest.json --but how can this be done?
manifest.json (Where I have configured the 'inputs' model)
{
"_version": "1.1.0",
"sap.app": {
"_version": "1.1.0",
"id": "pricingTool",
"type": "application",
"applicationVersion": {
"version": "1.0.0"
},
"title": "{{appTitle}}",
"description": "{{appDescription}}",
"ach": "ach",
"resources": "resources.json",
"sourceTemplate": {
"id": "ui5template.basicSAPUI5ApplicationProject",
"version": "1.30.3"
},
},
"sap.ui": {
"_version": "1.1.0",
"technology": "UI5",
"icons": {
"icon": "",
"favIcon": "",
"phone": "",
"phone#2": "",
"tablet": "",
"tablet#2": ""
},
"deviceTypes": {
"desktop": true,
"tablet": true,
"phone": true
},
"supportedThemes": [
"sap_hcb",
"sap_bluecrystal"
]
},
"sap.ui5": {
"_version": "1.1.0",
"rootView": {
"viewName": "pricingTool.view.Main",
"type": "XML"
},
"dependencies": {
"minUI5Version": "1.30.0",
"libs": {
"sap.ui.core": {},
"sap.m": {},
"sap.ui.layout": {}
}
},
},
"contentDensities": {
"compact": true,
"cozy": true
},
"models": {
"inputs": {
"type": "sap.ui.model.json.JSONModel",
"uri": "model/inputs.json"
},
},
}
Main.controller.js (where the 'inputs' model should be set from the manifest file)
sap.ui.define([
'jquery.sap.global',
'sap/ui/core/mvc/Controller',
'sap/ui/model/json/JSONModel',
'sap/ui/model/Filter',
'sap/ui/model/FilterOperator',
'sap/m/MessageToast',
'pricingTool/model/viewControls',
'pricingTool/model/formatter',
'pricingTool/model/Utility',
'sap/ui/core/util/Export',
'sap/ui/core/util/ExportTypeCSV',
],
function (jQuery, Controller, JSONModel, Filter, FilterOperator, MessageToast, viewControls, formatter, Utility, Export, ExportTypeCSV) {
"use strict";
var mainController = Controller.extend("pricingTool.controller.Main", {
onInit: function(oEvent) {
//define named/default model(s)
var inputs = new JSONModel("./model/inputs.json");
//set model(s) to current xml view
this.getView().setModel(inputs, "inputs");
//this is one solution I have tried, but doesn't do anything:
// this.getView().setModel(this.getOwnerComponent().getModel("inputs"), "inputs");
//another solution I have tried:
//var inputs = this.getModel('input') <--I was hoping this would find the inputs defined in the manifest.json, but this doesn't work either
// this.getView().setModel(inputs, "inputs");
},
...
inputs.json
{
"propA" : "testVal"
}
XML View
<Button text="{inputs>propA}"></Button>
Components.js (Not sure what to do in the Component.js)
sap.ui.define([
'sap/ui/core/UIComponent'
],
function(UIComponent) {
"use strict";
var Component = UIComponent.extend("pricingTool.Component", {
metadata : {
metadata : {
manifest: "json"
},
rootView : "pricingTool.view.Main",
dependencies : {
libs : [
"sap.m",
"sap.ui.layout"
]
},
config : {
sample : {
files : [
"Main.view.xml",
"Main.controller.js"
]
}
}
},
init : function () {
// call the init function of the parent
UIComponent.prototype.init.apply(this, arguments);
}
});
return Component;
});
The problem is that the model property ("propA") is not displaying when I test it on a button control. Can anyone tell me why the model is not displaying in the app?
Summarizing Question
How can I define a model in manifest.json, and then set that model in the controller so I can use it in my xml view?
try putting a forward slash before your property name...
<Button text="{inputs>/propA}"></Button>
...and update your manifest file so that your model definition points to your dataSource defined under sap.app as follows...
{
"_version": "1.1.0",
"sap.app": {
"_version": "1.1.0",
"id": "pricingTool",
"type": "application",
"applicationVersion": {
"version": "1.0.0"
},
"title": "{{appTitle}}",
"description": "{{appDescription}}",
"ach": "ach",
"resources": "resources.json",
"sourceTemplate": {
"id": "ui5template.basicSAPUI5ApplicationProject",
"version": "1.30.3"
},
"dataSources": {
"inputsData": {
"type" : "JSON",
"uri": "model/inputs.json"
}
}
},
"sap.ui": {
"_version": "1.1.0",
"technology": "UI5",
"icons": {
"icon": "",
"favIcon": "",
"phone": "",
"phone#2": "",
"tablet": "",
"tablet#2": ""
},
"deviceTypes": {
"desktop": true,
"tablet": true,
"phone": true
},
"supportedThemes": [
"sap_hcb",
"sap_bluecrystal"
]
},
"sap.ui5": {
"_version": "1.1.0",
"rootView": {
"viewName": "pricingTool.view.Main",
"type": "XML"
},
"dependencies": {
"minUI5Version": "1.30.0",
"libs": {
"sap.ui.core": {},
"sap.m": {},
"sap.ui.layout": {}
}
},
"contentDensities": {
"compact": true,
"cozy": true
},
"models": {
"products": {
"type": "sap.ui.model.json.JSONModel",
"uri": "model/products.json"
},
"inputs": {
"type": "sap.ui.model.json.JSONModel",
"dataSource" : "inputsData"
}
}
}
}
...change your Component.js file to point to your manifest file...
sap.ui.define([
'sap/ui/core/UIComponent'
],
function(UIComponent) {
"use strict";
var Component = UIComponent.extend("pricingTool.Component", {
metadata : {
manifest: "json",
},
init : function () {
// call the init function of the parent
UIComponent.prototype.init.apply(this, arguments);
}
});
});
... and remove the onInit logic within your controller to set the model (this is handled by the component)
Those models you define in the manifest.json file are created in the Component context (if your app based on Component). To make it available in the XML view you have to obtain it from Component and then attach to the view. The code snippet you can use in onInit controller event looks like this:
this.getView().setModel(this.getOwnerComponent().getModel("<your_model_name>"), "<your_model_name>");
if you are using standard template then most likely you have a BaseController as an ancestor, in that case the code can look shorter:
this.setModel(this.getComponentModel("<your_model_name>"), "<your_model_name>");
Here is a minimal example of what you'd like to achieve: https://embed.plnkr.co/l1XF5O/
Models defined in manifest.json (aka. "app descriptor") will be set to the component (since v1.30).
If a descriptor is used, almost all properties of your component's metadata other than manifest: "json" are deprecated and should be avoided. Deprecated properties are listed here.
Views (and their controls inside) inside the root view instantiated by your component inherit models automatically from the component. Thus, setting models to your view explicitly is not needed anymore. Your view already knows the model that is set to the component.*
The binding syntax should be used correctly according to your situation:
Use relative binding syntax (modelName>property) only if a parent control has already a context bound (e.g. the parent control uses aggregation binding, or element binding).
In other cases, use absolute binding syntax. It starts with a slash (modelName>/property), so that the control doesn't look for the binding context of its parent.
*Although the model, which is set on the component, can be used seamlessly in the XMLView, retrieving the component model by calling view.getModel inside the onInit handler will return undefined. More about this: https://stackoverflow.com/a/43941380/5846045

Passing Parameter Values to DSC Configuration from ARM Template

I have a simple DSC Config file that contains a credential and string input parameter. I want this DSC configuration deployed with a VM deployed in an ARM template but am missing the concept of how to pass these two parameters securely. How do I accomplish this?
I was receiving the same error but, after some shenanigans, it is working for me. The important part is the settings/Properties/SqlAgentCred/password reference to protectedSettings/Items/AgentPassword. Below is the properties node under my Powershell.DSC extension resource in my template.
"properties": {
"publisher": "Microsoft.Powershell",
"type": "DSC",
"typeHandlerVersion": "2.17",
"autoUpgradeMinorVersion": false,
"settings": {
"ModulesUrl": "https://blobstore.blob.core.windows.net/windows-powershell-dsc/DBServer.ps1.zip",
"ConfigurationFunction": "DBServer.ps1\\DBServer",
"Properties": {
"SqlAgentCred": {
"userName": "user#domain.com",
"password": "PrivateSettingsRef:AgentPassword"
}
},
"WmfVersion": "latest",
"Privacy": {
"DataCollection": "Disable"
}
},
"protectedSettings": {
"Items": {
"AgentPassword": "Pa$$word"
},
"DataBlobUri": ""
}
}
You will specify protected settings under protectedsettings section. Anything under ProtectedSettings are sent encrypted. Check https://blogs.msdn.microsoft.com/powershell/2016/02/26/arm-dsc-extension-settings/ for details.

Alfresco Restful API to get custom metadata

We are moving to Alfresco Content Management system and there is no direct documentation for retrieving custom metadata.
Is there a way to get custom metadata/ custom properties that I have added to Record category in Alfresco Records Management File plan? Custom metadata is basically the data fields that are in scanned document like name, dob, form id, etc.
Eg: I have created RM site and added the following file plan.
TestCategory
|
--TestFolder1
|
--Record1
--Record2
|
--TestFolder2
|
--Record1
--Record2
These records contains uploaded form(scanned document) along with metadata (custom).
To Retrieve metadata, am using
http://127.0.0.1:8090/alfresco/service/api/metadata/node/workspace/SpacesStore/ed6e2cc6-6dc5-4bfb-bf9d-b450f68863dd?alf_ticket=TICKET_06265902898618fe5a46e67992e07a9d4b72701a
It is returning 405-Method not allowed (GET not supported).
To Retrieve all the subfolders/documents in Folders, m using
http://127.0.0.1:8090/alfresco/service/slingshot/doclib/doclist/documents/site/rm/documentLibrary/TestCat1/TestFolder2
Above one returns
{
"totalRecords": 1,
"startIndex": 0,
"metadata": {
"repositoryId": "3b9d4f67-dc84-4531-b8b2-4dbcef15e25a",
"container": "workspace://SpacesStore/7d1349bb-5289-4709-9055-c75c03ab5481",
"parent": {
"nodeRef": "workspace://SpacesStore/5d40660e-64d9-4bc4-a75e-ae4ae8b2201a",
"permissions": {
"userAccess": {
"create": true,
"edit": true,
"delete": true,
"cancel-checkout": false,
"permissions": true
}
}
},
"onlineEditing": true,
"itemCounts": {
"folders": 0,
"documents": 1
}
},
"items": [
{
"nodeRef": "workspace://SpacesStore/65b9b52b-3418-4a85-98b0-d4770cf9399d",
"nodeType": "cm:content",
"type": "document",
"mimetype": "application/pdf",
"isFolder": false,
"isLink": false,
"fileName": "BO (2016-1464237424392).pdf",
"displayName": "BO (2016-1464237424392).pdf",
"status": "",
"title": "þÿ",
"description": "test description",
"author": "",
"createdOn": "2016-05-26T00:37:04.350-04:00",
"createdBy": "Administrator",
"createdByUser": "admin",
"modifiedOn": "2016-05-31T15:50:21.269-04:00",
"modifiedBy": "Administrator",
"modifiedByUser": "admin",
"lastThumbnailModification": "doclib:1464237426243",
"lockedBy": "",
"lockedByUser": "",
"size": "156702",
"version": "1.0",
"contentUrl": "api/node/content/workspace/SpacesStore/65b9b52b-3418-4a85-98b0-d4770cf9399d/BO%20(2016-1464237424392).pdf",
"webdavUrl": "/webdav/Sites/rm/documentLibrary/TestCat1/TestFolder2/BO%20(2016-1464237424392).pdf",
"actionSet": "document",
"tags": [],
"activeWorkflows": "",
"isFavourite": false,
"likes": {
"isLiked": false,
"totalLikes": 0
},
"location": {
"repositoryId": "3b9d4f67-dc84-4531-b8b2-4dbcef15e25a",
"site": "rm",
"siteTitle": "Records Management",
"container": "documentLibrary",
"path": "/TestCat1/TestFolder2",
"file": "BO (2016-1464237424392).pdf",
"parent": {
"nodeRef": "workspace://SpacesStore/5d40660e-64d9-4bc4-a75e-ae4ae8b2201a"
}
},
"permissions": {
"inherited": true,
"roles": [
"ALLOWED;ROLE_EXTENDED_READER;ReadRecords;INHERITED",
"ALLOWED;GROUP_Administrator7d1349bb-5289-4709-9055-c75c03ab5481;Filing;INHERITED",
"ALLOWED;ROLE_EXTENDED_WRITER;Filing;INHERITED"
],
"userAccess": {
"create": true,
"edit": true,
"delete": true,
"cancel-checkout": false,
"permissions": true
}
},
"custom": {},
"actionLabels": {}
}
]
}
Using PostMan chrome app to test rest api. TIA.
Another way to do this: I found it in Alfresco forums :
/alfresco/service/api/metadata?nodeRef=workspace://SpacesStore/a2a6c249- c55d-4d29-8692-3e9cb1f811a8 [GET service]
This should do it. Example request.
http://localhost:8080/alfresco/service/slingshot/doclib2/node/workspace/SpacesStore/f558838b-24fa-4ea3-bb2a-602c7b4cec41
Give it a shot, it will return everything you need, not only metadata but for example aspects too.
If the response you are getting is overwhelming for anyone like me, in the accepted (great) answer/solution given by Lista, here is a simpler way:
HTTP GET:
http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/dc2d0a1b-a78d-47a9-aaab-31df0f09e8fb
Need some more details? Try this:
http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/dc2d0a1b-a78d-47a9-aaab-31df0f09e8fb?include=association,path,permissions
You will get a response similar to this:
{"entry":{"isFile":true,"createdByUser":{"id":"admin","displayName":"Administrator"},"modifiedAt":"2020-12-16T00:01:56.615+0000","nodeType":"cm:content","content":{"mimeType":"application/pdf","mimeTypeName":"Adobe PDF Document","sizeInBytes":8037,"encoding":"UTF-8"},"parentId":"c250f9c5-d3f9-4c9e-83c6-2d239f8c2237","aspectNames":["cm:versionable","cm:titled","cm:auditable","cm:taggable","cm:author"],"createdAt":"2020-12-13T16:48:27.600+0000","isFolder":false,"modifiedByUser":{"id":"admin","displayName":"Administrator"},"name":"fileName","id":"dc2d0a1b-a78d-47a9-aaab-31df0f09e8fb","properties":{"cm:title":"titletest","cm:versionType":"MAJOR","cm:versionLabel":"1.0","cm:description":"descriptiontest"}}}
And with include options the response will look similar to this -
{"entry":{"isFile":true,"createdByUser":{"id":"admin","displayName":"Administrator"},"modifiedAt":"2020-12-16T00:01:56.615+0000","association":{"isPrimary":true,"assocType":"cm:contains"},"nodeType":"cm:content","content":{"mimeType":"application/pdf","mimeTypeName":"Adobe PDF Document","sizeInBytes":8037,"encoding":"UTF-8"},"parentId":"c250f9c5-d3f9-4c9e-83c6-2d239f8c2237","aspectNames":["cm:versionable","cm:titled","cm:auditable","cm:taggable","cm:author"],"createdAt":"2020-12-13T16:48:27.600+0000","path":{"name":"/Company Home/Sites/site1/documentLibrary/Employee/Test","isComplete":true,"elements":[{"id":"3ac0f350-a3e0-4da4-8dfa-c8e74553b024","name":"Company Home","nodeType":"cm:folder","aspectNames":["cm:titled","cm:auditable","app:uifacets"]},{"id":"15d878c2-e880-4a3f-ac00-60596ba2dcd1","name":"Sites","nodeType":"st:sites","aspectNames":["cm:titled","cm:auditable","app:uifacets"]},{"id":"46c2a6b1-2839-4b25-ac5d-c7dd874aea1e","name":"site1","nodeType":"st:site","aspectNames":["cm:tagscope","cm:titled","cm:auditable"]},{"id":"e8bc3bfe-7b41-416e-aa6a-9ee1b4fc9779","name":"documentLibrary","nodeType":"cm:folder","aspectNames":["cm:tagscope","st:siteContainer","cm:ownable","cm:titled","cm:auditable"]},{"id":"d5027ba7-874c-4996-bcde-923c68ec4c5b","name":"Employee","nodeType":"cm:folder","aspectNames":["cm:titled","cm:auditable"]},{"id":"c250f9c5-d3f9-4c9e-83c6-2d239f8c2237","name":"Test","nodeType":"cm:folder","aspectNames":["cm:titled","cm:auditable"]}]},"isFolder":false,"permissions":{"inherited":[{"authorityId":"GROUP_EVERYONE","name":"SiteConsumer","accessStatus":"ALLOWED"},{"authorityId":"GROUP_EVERYONE","name":"ReadPermissions","accessStatus":"ALLOWED"},{"authorityId":"GROUP_site_site1_SiteConsumer","name":"SiteConsumer","accessStatus":"ALLOWED"},{"authorityId":"GROUP_site_site1_SiteManager","name":"SiteManager","accessStatus":"ALLOWED"},{"authorityId":"GROUP_site_site1_SiteCollaborator","name":"SiteCollaborator","accessStatus":"ALLOWED"},{"authorityId":"GROUP_site_site1_SiteContributor","name":"SiteContributor","accessStatus":"ALLOWED"}],"settable":["Contributor","Collaborator","Coordinator","Editor","Consumer"],"isInheritanceEnabled":true},"modifiedByUser":{"id":"admin","displayName":"Administrator"},"name":"fileName","id":"dc2d0a1b-a78d-47a9-aaab-31df0f09e8fb","properties":{"cm:title":"titletest","cm:versionType":"MAJOR","cm:versionLabel":"1.0","cm:description":"descriptiontest"}}}
Disclaimer: I am using Alfresco 6.2 Community Edition. But as per documentation (public rest-api link) it says:
Note: this endpoint is available in Alfresco 5.2 and newer versions.

Resources