-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update JS dependencies * Wip * Set up javascript tests * Some refactoring and some tests * Improve controller testing * Refactor and test Label * Update Toggle and related test * Refactor and add test for Text field * Wip * Extract shared styles into Nova-like wrapper * Extract DefaultSetting layout component and apply to TextSetting * Update partials and tests * Rename TextSetting and remove File for now * Rename config file to `nova-settings-tool` Technically, fixes #8 * Refactor reading of settings and related tests * Change package namespace and misc. wip * Begin refactoring components and related tests * Update TextareaSetting * Update ToggleSetting * Fix toggle setting and key SettingsController response by setting keys * Rename ambiguous `default` to `placeholder` * Update writing settings * Update Code setting and tests * Capitalize fallback setting labels * Re-implement panels * Readme and config updates * Wip * Remove File setting for now * Implement Number setting * Implement Select setting * Allow loading settings file from any disk * Set up GitHub actions * Assets * Apply fixes from StyleCI * Wip * Wip * Wip * Fix default config file * New screenshot * Wip
- Loading branch information
1 parent
3f4ed76
commit 6043966
Showing
50 changed files
with
1,142 additions
and
778 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: CI | ||
|
||
on: [push] | ||
|
||
jobs: | ||
test: | ||
name: Tests | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v1 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Setup | ||
env: | ||
NOVA_USERNAME: ${{ secrets.NOVA_USERNAME }} | ||
NOVA_PASSWORD: ${{ secrets.NOVA_PASSWORD }} | ||
run: | | ||
composer config http-basic.nova.laravel.com $NOVA_USERNAME $NOVA_PASSWORD | ||
composer install -n --prefer-dist --no-ansi --no-progress --no-suggest --no-scripts | ||
- name: PHPUnit | ||
run: vendor/bin/phpunit --testdox --colors=always | ||
|
||
- name: Jest | ||
run: | | ||
npm install | ||
npm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
/node_modules | ||
/scratch | ||
/vendor | ||
.DS_Store | ||
.phpunit.result.cache | ||
notes.md | ||
composer.lock | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,77 @@ | ||
A Laravel Nova tool to manage app settings | ||
========================================== | ||
Laravel Nova tool to manage app settings | ||
======================================== | ||
|
||
[![Latest Version on Packagist](https://img.shields.io/packagist/v/bakerkretzmar/nova-settings-tool.svg?style=flat-square)](https://packagist.org/packages/bakerkretzmar/nova-settings-tool) | ||
[![Total Downloads](https://img.shields.io/packagist/dt/bakerkretzmar/nova-settings-tool.svg?style=flat-square)](https://packagist.org/packages/bakerkretzmar/nova-settings-tool) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT) | ||
[![StyleCI](https://github.styleci.io/repos/165178010/shield?branch=master)](https://github.styleci.io/repos/165178010)<!-- Coverage?? --> | ||
[![Latest Version on Packagist](https://img.shields.io/packagist/v/bakerkretzmar/nova-settings-tool.svg?style=flat)](https://packagist.org/packages/bakerkretzmar/nova-settings-tool) | ||
[![Total Downloads](https://img.shields.io/packagist/dt/bakerkretzmar/nova-settings-tool.svg?style=flat)](https://packagist.org/packages/bakerkretzmar/nova-settings-tool) | ||
[![Build](https://github.com/bakerkretzmar/nova-settings-tool/workflows/CI/badge.svg)](https://github.com/bakerkretzmar/nova-settings-tool/actions) | ||
[![StyleCI](https://github.styleci.io/repos/165178010/shield?branch=master&style=flat)](https://github.styleci.io/repos/165178010) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat)](https://opensource.org/licenses/MIT) | ||
|
||
Store and edit simple app-wide settings right in Nova. Settings are stored as JSON using [`spatie/valuestore`](https://github.com/spatie/valuestore), making them really easy to [pull in and use everywhere else in your app](https://laravel-news.com/global-application-settings). | ||
|
||
![Settings Tool screenshot](settings-tool.png) | ||
|
||
## Installation | ||
|
||
Install the package in any Laravel app that uses [Nova](https://nova.laravel.com) via composer: | ||
Install the package via Composer in any Laravel app using [Nova](https://nova.laravel.com): | ||
|
||
```bash | ||
```shell | ||
composer require bakerkretzmar/nova-settings-tool | ||
``` | ||
|
||
Publish the included default configuration file to `config/settings.php` (optional, see below): | ||
Publish the default configuration file to `config/nova-settings-tool.php`: | ||
|
||
```bash | ||
php artisan vendor:publish --tag="settings-tool" | ||
```shell | ||
php artisan vendor:publish --tag="nova-settings-tool" | ||
``` | ||
|
||
Register the tool with Nova in the `tools` method of your `NovaServiceProvider`: | ||
|
||
```php | ||
// in app/Providers/NovaServiceProvider.php | ||
|
||
use Bakerkretzmar\SettingsTool\SettingsTool; | ||
use Bakerkretzmar\NovaSettingsTool\SettingsTool; | ||
|
||
// ... | ||
// ... | ||
|
||
public function tools() | ||
{ | ||
return [ | ||
new SettingsTool, | ||
]; | ||
} | ||
public function tools() | ||
{ | ||
return [ | ||
new SettingsTool, | ||
]; | ||
} | ||
``` | ||
|
||
## Usage | ||
|
||
Settings can be declared using a `settings.php` file in your app's `config` folder. This file lets you specify where your settings are stored, what the tool's title is in Nova's sidebar, the layout of the settings page, and information about the settings themselves. | ||
Settings are declared in a `nova-settings-tool.php` config file. This file specifies where settings are stored, what the tool’s title is in Nova’s sidebar, the layout of the settings page, and metadata about the settings themselves. | ||
|
||
This package includes a default config file that you can publish and use as a starting point: | ||
A [default config file with some helpful examples](config/nova-settings-tool.php) is included as a starting point: | ||
|
||
```bash | ||
php artisan vendor:publish --tag="settings-tool" | ||
``` | ||
|
||
The [default config](config/settings.php) contains examples that should be pretty self-explanatory, and lots of comments in case they aren't. | ||
|
||
Each item in the `panels` array is rendered as its own 'group' of settings, like a panel on one of Nova's detail views. Each panel has a name and contains some settings. Each setting can optionally have a description and a link to more information (e.g. docs). Only the setting's key and value are actually stored in your `settings.json` file. | ||
|
||
There are four available setting types: | ||
|
||
| Type... | ...displays | | ||
| :--------- | :--------------------- | | ||
| `toggle` | Boolean | | ||
| `text` | Single-line text input | | ||
| `textarea` | Multi-line text input | | ||
| `code` | Code snippet editor | | ||
| `file` | Single file input | | ||
|
||
All the strings hard-coded in this package (like in the "Save" button), as well as any you pass to it (like the `name` of any of your settings), can easily be translated using [Laravel's built-in localization features](https://laravel.com/docs/localization#using-translation-strings-as-keys). | ||
|
||
## Testing | ||
|
||
```bash | ||
composer test | ||
``` | ||
Each item in the `settings` array is rendered as an input with a label and help text, similar to one of Nova’s fields. Settings can also be grouped into panels, to separate them visually. | ||
|
||
I'm new to testing and would welcome testing-related PRs. | ||
The settings’ actual values are stored as JSON at the location specified in the config file—`storage/app/settings.json` by default. | ||
|
||
## Changelog | ||
There are currently six available setting types: | ||
|
||
Please see the [CHANGELOG](CHANGELOG.md) for information about what has changed recently. | ||
- `text`: Single-line text input | ||
- `textarea`: Multi-line text input | ||
- `toggle`: Boolean switch | ||
- `code`: [CodeMirror](https://codemirror.net/) text editor | ||
- `number`: Number input | ||
- `select`: Single-select dropdown | ||
|
||
## Contributing | ||
All strings in this package, and any you pass to it, can easily be translated using [Laravel’s built-in localization features](https://laravel.com/docs/localization#using-translation-strings-as-keys). | ||
|
||
Please see [CONTRIBUTING](CONTRIBUTING.md) for details. | ||
## Roadmap | ||
|
||
## Security | ||
The following features are planned or in development: | ||
|
||
If you discover any security related issues, please email <[email protected]> instead of using the issue tracker. | ||
- `color` setting type | ||
- `date` setting type | ||
- `file` setting type | ||
- setting validation | ||
|
||
## License | ||
--- | ||
|
||
This package is licensed under the MIT License (MIT). Please see the [LICENSE](LICENSE.md) for details. | ||
[CHANGELOG](CHANGELOG.md) • [CONTRIBUTING](CONTRIBUTING.md) • [LICENSE](LICENSE.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Settings Path | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Path to the JSON file where settings are stored. | ||
| | ||
*/ | ||
|
||
'path' => storage_path('app/settings.json'), | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Sidebar Label | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The text that Nova displays for this tool in the navigation sidebar. | ||
| | ||
*/ | ||
|
||
'sidebar-label' => 'Settings', | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Settings | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The good stuff :). Each setting defined here will render a field in the | ||
| tool. The only required key is `key`, other available keys include `type`, | ||
| `label`, `help`, `placeholder`, `language`, and `panel`. | ||
| | ||
*/ | ||
|
||
'settings' => [ | ||
|
||
[ | ||
'key' => 'twitter_url', | ||
'label' => 'Twitter Profile', | ||
'panel' => 'Social', | ||
], | ||
|
||
[ | ||
'key' => 'feature_42', | ||
'label' => 'Feature 42', | ||
'type' => 'toggle', | ||
'help' => 'For the upcoming release. <a href="/docs#feature_42">Read more here.</a>', | ||
], | ||
|
||
[ | ||
'key' => 'welcome', | ||
'label' => 'Welcome Message', | ||
'type' => 'textarea', | ||
'help' => 'Greeting for new users on their first login.', | ||
], | ||
|
||
[ | ||
'key' => 'snippet', | ||
'label' => 'Tracking Snippet', | ||
'type' => 'code', | ||
'language' => 'htmlmixed', | ||
'help' => 'Analytics snippet to add to all marketing pages.', | ||
], | ||
|
||
[ | ||
'key' => 'theme', | ||
'label' => 'Default App Theme', | ||
'type' => 'select', | ||
'options' => [ | ||
'dark' => 'Dark theme', | ||
'light' => 'Light theme', | ||
], | ||
], | ||
|
||
[ | ||
'key' => 'timeout', | ||
'type' => 'Number', | ||
'label' => 'Timeout (min.)', | ||
], | ||
|
||
], | ||
|
||
]; |
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.