Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@sanity/dashboard
Advanced tools
Dashboard is a Sanity Content Studio Tool which picks up and renders any widgets which implement part:@sanity/dashboard/widget
. Install this plugin in your Studio to display stats about your project, recently edited documents, etc.
The Dashboard tool has been designed to be as generic as possible, making few assumptions about its widgets. The Dashboard itself is mostly concerned about the layout of the configured widgets.
cd
to your Content Studiosanity install @sanity/dashboard
. This will cause two things happen:
./node_modules
in your Studio@sanity/dashboard
is appended to the plugins
array in the sanity.json
file of your Studiosanity start
) and point your browser to http://localhost:3333/dashboard
Changing what is rendered on your Dashboard is easy. To take control, do the following:
sanity.json
file, append the following line to the parts
array:{
"implements": "part:@sanity/dashboard/config",
"path": "src/dashboardConfig.js"
}
src/dashboardConfig.js
and make sure it's shaped something like this:export default {
widgets: [{name: 'sanity-tutorials'}, {name: 'project-info'}, {name: 'project-users'}]
}
The widgets
array is how you tell the Dashboard which widgets to render. The ones mentioned in the above example are bundled with Sanity and require no separate installation.
src/dashboardConfig.js
. You can also duplicate them, should you want multiple instances of the same widget (see below).A widget’s size behavior can be defined by adding a layout
key to a the widget config. E.g.: {name: 'project-users', layout: {width: 'full', height: 'small'}}
. Accepted values are auto
, small
, medium
, large
and full
.
Install a Dashboard widget as you would any other Sanity Studio plugin.
E.g. if you want to install the cats example widget mentioned below, proceed as follows:
sanity install dashboard-widget-cats
in your terminal (this works because it's published on npm under the name sanity-plugin-dashboard-widget-cats
)src/dashboardConfig.js
file by adding {name: 'cats'}
to the widgets
arraySome widgets allow options to change aspects of their behavior. If you install the document-list widget mentioned below, it can be configured with:
{name: 'document-list', options: {title: 'Last edited books', order: '_updatedAt desc', types: ['book']}}
Thus, if you want your dashboard to display both newest documents across all document types and another widget showing the last edited books, your dashboardConfig would look like this:
export default {
widgets: [
{name: 'document-list', options: {title: 'New', order: '_createdAt desc'}},
{
name: 'document-list',
options: {title: 'Last edited books', order: '_updatedAt desc', types: ['book']}
}
]
}
Widgets are Sanity plugins that implement the part part:@sanity/dashboard/widget
. Stay tuned for a complete "Widget Authors Cookbook", but until then, have a look at some sample widgets: E.g. A document List or maybe some cats?
When writing your widget components, it's recommended to use the DashboardWidget
component from the Sanity Studio by importing it like so: import { DashboardWidget } from "@sanity/dashboard";
.
This gives you a typical widget component structure with basic styles, and the option of presenting your content in the header, footer, or body of the widget.
If you need something more flexible you can create your own component.
Setting up the widget with the default setup will give you a basic widget that looks something like this:
<DashboardWidget
header="A cat"
footer={
<Flex direction="column" align="stretch">
<Button
flex={1}
paddingX={2}
paddingY={4}
mode="bleed"
tone="primary"
text="Get new cat"
/>
</Flex>
}
>
<figure>
<img src="https://placekitten.com/300/450" />
</figure>
</DashboardWidget>
You can study the source code of these widgets to get a sense of how you can approach fetching of documents, adding configuration, and so on:
FAQs
Tool for rendering dashboard widgets
The npm package @sanity/dashboard receives a total of 5,539 weekly downloads. As such, @sanity/dashboard popularity was classified as popular.
We found that @sanity/dashboard demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 61 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.