Skip to content

Commit cd157b4

Browse files
Support Nova 4 (#46)
* Update dependencies * Wip * Fix tests * Wip * Changelog * Readme * Screenshot * Wip * Fix
1 parent 45f4567 commit cd157b4

38 files changed

+356
-840
lines changed

.github/workflows/main.yaml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
11
name: CI
2-
32
on:
43
pull_request:
54
push:
6-
brances: [main]
7-
5+
branches: [1.x, 2.x]
86
jobs:
97
test:
108
name: Tests
119
runs-on: ubuntu-latest
1210
steps:
13-
- uses: actions/checkout@v1
11+
- uses: actions/checkout@v2
12+
- uses: shivammathur/setup-php@v2
1413
with:
15-
fetch-depth: 1
16-
- env:
14+
php-version: 8.0
15+
- run: composer config http-basic.nova.laravel.com $NOVA_USERNAME $NOVA_PASSWORD
16+
env:
1717
NOVA_USERNAME: ${{ secrets.NOVA_USERNAME }}
1818
NOVA_PASSWORD: ${{ secrets.NOVA_PASSWORD }}
19-
run: |
20-
composer config http-basic.nova.laravel.com $NOVA_USERNAME $NOVA_PASSWORD
21-
composer install -n --prefer-dist --no-ansi --no-progress --no-suggest --no-scripts
19+
- uses: ramsey/composer-install@v2
2220
- run: vendor/bin/phpunit --testdox --colors=always
23-
- run: |
24-
npm install
25-
npm run test

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to `nova-settings-tool` will be documented in this file.
44

5+
## 2.0.0 – 2022-04-16
6+
7+
- Add support for Nova 4
8+
59
## 1.1.3 – 2021-08-05
610

711
- Default Settings tool page title to `Settings` and make it translatable

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Install the package via Composer in any Laravel app using [Nova](https://nova.la
1818
composer require bakerkretzmar/nova-settings-tool
1919
```
2020

21+
> Nova Settings Tool currently requires Nova 4—for older versions of Nova, use v1 of this package.
22+
2123
Publish the default configuration file to `config/nova-settings-tool.php`:
2224

2325
```bash

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
}
2323
],
2424
"require": {
25-
"php": "^7.1|^8.0",
26-
"laravel/nova": "^1.0|^2.0|^3.0",
27-
"spatie/valuestore": "^1.2"
25+
"php": "^7.3|^8.0",
26+
"laravel/nova": "^4.0",
27+
"spatie/valuestore": "^1.3"
2828
},
2929
"require-dev": {
30-
"orchestra/testbench": "^6.4",
31-
"phpunit/phpunit": "^9.4"
30+
"orchestra/testbench": "^7.4",
31+
"phpunit/phpunit": "^9.5"
3232
},
3333
"autoload": {
3434
"psr-4": {
@@ -48,6 +48,7 @@
4848
}
4949
},
5050
"config": {
51+
"optimize-autoloader": true,
5152
"sort-packages": true
5253
},
5354
"minimum-stability": "dev",

dist/js/tool.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/mix-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"/js/tool.js": "/js/tool.js"
3-
}
3+
}

package.json

Lines changed: 14 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,22 @@
11
{
22
"private": true,
33
"scripts": {
4-
"dev": "NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
5-
"watch": "NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
6-
"prod": "NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
7-
"test": "jest --verbose"
4+
"dev": "mix",
5+
"watch": "mix watch",
6+
"prod": "mix --production"
87
},
98
"devDependencies": {
10-
"@vue/test-utils": "^1.0.0-beta.29",
11-
"codemirror": "^5.49.0",
12-
"cross-env": "^6.0.0",
13-
"jest": "^24.8.0",
14-
"laravel-mix": "^1.0",
15-
"vue-jest": "^3.0.4"
9+
"@vue/compiler-sfc": "^3.2.22",
10+
"codemirror": "^5.65.2",
11+
"laravel-mix": "^6.0.41",
12+
"lodash": "^4.17.21",
13+
"prettier": "^2.6.2",
14+
"vue": "^3.2.33",
15+
"vue-loader": "^17.0.0"
1616
},
17-
"dependencies": {
18-
"vue": "^2.5.0"
19-
},
20-
"jest": {
21-
"moduleFileExtensions": [
22-
"js",
23-
"vue"
24-
],
25-
"moduleNameMapper": {
26-
"^@/(.*)$": "<rootDir>/resources/js/$1"
27-
},
28-
"transform": {
29-
"^.+\\.js$": "babel-jest",
30-
"^.+\\.vue$": "vue-jest"
31-
},
32-
"testMatch": [
33-
"<rootDir>/tests/js/**/*.spec.js"
34-
]
35-
},
36-
"babel": {
37-
"env": {
38-
"test": {
39-
"presets": [
40-
[
41-
"env",
42-
{
43-
"targets": {
44-
"node": "current"
45-
}
46-
}
47-
]
48-
]
49-
}
50-
}
17+
"prettier": {
18+
"printWidth": 140,
19+
"tabWidth": 4,
20+
"singleQuote": true
5121
}
5222
}

phpunit.xml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
4-
bootstrap="vendor/autoload.php"
5-
colors="true">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true">
63
<testsuites>
7-
<testsuite name="Nova Settings Tool Tests">
4+
<testsuite name="Nova Settings Tool">
85
<directory>./tests</directory>
96
</testsuite>
107
</testsuites>
11-
<coverage processUncoveredFiles="true">
12-
<include>
13-
<directory suffix=".php">./src</directory>
14-
</include>
15-
</coverage>
168
</phpunit>

resources/js/CodeSetting.vue

Lines changed: 41 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,75 @@
11
<template>
2-
<default-setting :setting="setting" :errors="errors || []">
3-
4-
<template slot="setting">
5-
6-
<div class="form-input-bordered px-0 overflow-hidden">
7-
<textarea ref="textarea" :id="setting.key"/>
8-
</div>
9-
10-
</template>
11-
12-
</default-setting>
2+
<DefaultSetting :setting="setting" :errors="errors || []">
3+
<div class="form-input form-input-bordered px-0 overflow-hidden">
4+
<textarea ref="txt" :id="setting.key" />
5+
</div>
6+
</DefaultSetting>
137
</template>
148

159
<script>
16-
import DefaultSetting from './DefaultSetting'
17-
18-
import CodeMirror from 'codemirror'
19-
import 'codemirror/mode/php/php'
20-
import 'codemirror/mode/javascript/javascript'
21-
import 'codemirror/mode/css/css'
22-
import 'codemirror/mode/htmlmixed/htmlmixed'
23-
import 'codemirror/mode/markdown/markdown'
24-
import 'codemirror/mode/yaml/yaml'
25-
import 'codemirror/mode/shell/shell'
10+
import CodeMirror from 'codemirror';
11+
import 'codemirror/keymap/vim';
12+
import 'codemirror/mode/css/css';
13+
import 'codemirror/mode/dockerfile/dockerfile';
14+
import 'codemirror/mode/htmlmixed/htmlmixed';
15+
import 'codemirror/mode/javascript/javascript';
16+
import 'codemirror/mode/markdown/markdown';
17+
import 'codemirror/mode/nginx/nginx';
18+
import 'codemirror/mode/php/php';
19+
import 'codemirror/mode/shell/shell';
20+
import 'codemirror/mode/sql/sql';
21+
import 'codemirror/mode/vue/vue';
22+
import 'codemirror/mode/xml/xml';
23+
import 'codemirror/mode/yaml/yaml';
24+
import 'codemirror/mode/yaml-frontmatter/yaml-frontmatter';
25+
import DefaultSetting from './DefaultSetting.vue';
2626
2727
export default {
28-
components: { DefaultSetting },
29-
28+
components: {
29+
DefaultSetting,
30+
},
3031
props: {
3132
setting: Object,
3233
errors: Array,
3334
},
34-
35-
data: () => ({
36-
codemirror: null,
37-
}),
38-
39-
computed: {
40-
doc() {
41-
return this.codemirror.getDoc()
42-
},
43-
},
44-
35+
emits: ['update'],
36+
codemirror: null,
4537
mounted() {
46-
this.codemirror = CodeMirror.fromTextArea(this.$refs.textarea, {
38+
this.codemirror = CodeMirror.fromTextArea(this.$refs.txt, {
4739
indentUnit: 4,
4840
lineNumbers: true,
4941
mode: this.setting.language,
5042
theme: 'solarized light',
5143
viewportMargin: Infinity,
52-
})
53-
54-
this.doc.setValue(this.setting.value || '')
55-
56-
this.doc.on('change', (cm, change) => {
44+
});
45+
this.codemirror?.getDoc()?.on('change', (cm, changeObj) => {
5746
this.$emit('update', {
5847
key: this.setting.key,
5948
value: cm.getValue(),
60-
})
61-
})
49+
});
50+
});
51+
this.codemirror?.getDoc()?.setValue(this.setting.value);
52+
this.codemirror?.setSize('100%');
6253
},
63-
}
54+
};
6455
</script>
6556
66-
<style src="codemirror/lib/codemirror.css"/>
67-
<style src="codemirror/theme/solarized.css"/>
68-
6957
<style>
58+
@import 'codemirror/lib/codemirror.css';
59+
@import 'codemirror/theme/solarized.css';
7060
@import url(https://cdn.jsdelivr.net/gh/tonsky/FiraCode@1.206/distr/fira_code.css);
7161
7262
.CodeMirror {
73-
font-family: "Fira Code", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
63+
font-family: 'Fira Code', Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
7464
font-size: 14px;
7565
line-height: 1.75;
7666
font-weight: 500;
7767
-moz-box-shadow: none !important;
7868
-webkit-box-shadow: none !important;
7969
box-shadow: none !important;
8070
}
71+
.cm-s-solarized.cm-s-light {
72+
background-color: #fdf6e3 !important;
73+
color: #657b83 !important;
74+
}
8175
</style>

resources/js/DefaultSetting.vue

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,33 @@
11
<template>
2-
<setting-wrapper :stacked="setting.stacked">
3-
4-
<div class="w-1/5 px-8" :class="setting.stacked ? 'pt-6' : 'py-6'">
5-
6-
<setting-label :label-for="setting.key" :class="{ 'mb-2': setting.help }">
2+
<SettingWrapper :stacked="setting.stacked">
3+
<div class="px-8 mt-2 md:mt-0" :class="setting.stacked ? 'md:pt-5 w-full' : 'w-full md:w-1/5 md:py-5'">
4+
<SettingLabel :label-for="setting.key" :class="{ 'mb-2': setting.help }">
75
{{ __(setting.label) }}
8-
</setting-label>
9-
6+
</SettingLabel>
107
</div>
11-
12-
<div class="py-6 px-8" :class="settingClasses">
13-
14-
<slot name="setting"/>
15-
16-
<setting-help class="error-text text-danger" v-if="errors.length">
17-
{{ errors[0] }}
18-
</setting-help>
19-
20-
<setting-help v-if="setting.help">
21-
{{ __(setting.help) }}
22-
</setting-help>
23-
8+
<div class="mt-1 md:mt-0 pb-5 px-8" :class="setting.stacked ? 'md:pt-5 w-full' : 'w-full md:w-3/5 md:py-5'">
9+
<slot />
10+
<SettingHelp class="mt-2 help-text-error" v-if="errors.length">{{ errors[0] }}</SettingHelp>
11+
<SettingHelp class="mt-2 help-text" v-if="setting.help" v-html="__(setting.help)" />
2412
</div>
25-
26-
</setting-wrapper>
13+
</SettingWrapper>
2714
</template>
2815

2916
<script>
30-
import SettingHelp from './SettingHelp'
31-
import SettingLabel from './SettingLabel'
32-
import SettingWrapper from './SettingWrapper'
17+
import SettingHelp from './SettingHelp.vue';
18+
import SettingLabel from './SettingLabel.vue';
19+
import SettingWrapper from './SettingWrapper.vue';
3320
3421
export default {
35-
components: { SettingHelp, SettingLabel, SettingWrapper },
36-
22+
components: {
23+
SettingHelp,
24+
SettingLabel,
25+
SettingWrapper,
26+
},
3727
props: {
3828
setting: Object,
3929
fullWidth: Boolean,
4030
errors: Array,
4131
},
42-
43-
computed: {
44-
settingClasses() {
45-
return this.fullWidth ? (this.setting.stacked ? 'w-full' : 'w-4/5') : 'w-1/2'
46-
},
47-
},
48-
}
32+
};
4933
</script>

0 commit comments

Comments
 (0)