Skip to content

Commit

Permalink
Fix old profile/token route in views/partials/head.php
Browse files Browse the repository at this point in the history
Remove commented out code
Furiously trying to get ziggy-js to pass typechecks
Generate ziggy types in Docker build
Fix all type errors on default bootstrap.js
  • Loading branch information
mosen committed Dec 11, 2023
1 parent 8a1a026 commit 1c29e98
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 37 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ RUN mkdir -p app/db && \

RUN cp .env.example .env

RUN php please ziggy:generate --types

# Laravel storage items such as logs, caches, rendered views, etc.
VOLUME /var/munkireport/storage

Expand Down
1 change: 1 addition & 0 deletions compatibility/Unserializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Based on the python unserializer
* Does not convert objects
*
* @todo Replace with eg. xkerman/restricted-unserialize
*/
class Unserializer
{
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"rodneyrehm/plist": "^2.0",
"socialiteproviders/microsoft-azure": "^5.1.0",
"symfony/yaml": "^5.4",
"tightenco/ziggy": "^1.0",
"tightenco/ziggy": "^1.8",
"wikimedia/composer-merge-plugin": "^2.0",
"xkerman/restricted-unserialize": "^1.1",
"zircote/swagger-php": "^4.7"
Expand Down
65 changes: 46 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,16 @@
"vue": "^3.3.4",
"vue-codemirror6": "^1.1.27",
"whatwg-fetch": "^3.6.2",
"ziggy-js": "^1.5.0"
"ziggy-js": "^1.8.1"
},
"devDependencies": {
"@graphql-codegen/cli": "^4.0.1",
"@graphql-codegen/client-preset": "^4.1.0",
"@tailwindcss/forms": "^0.5.2",
"@tailwindcss/typography": "^0.5.2",
"@types/ziggy-js": "^1.3.3",
"@types/bootstrap": "^5.2.10",
"@types/jquery": "^3.5.29",
"@types/lodash": "^4.14.202",
"@vitejs/plugin-basic-ssl": "^1.0.0",
"@vitejs/plugin-vue": "^4.0.0",
"@vue/tsconfig": "^0.4.0",
Expand Down
32 changes: 24 additions & 8 deletions resources/js/app.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import {createApp, h} from 'vue'
import type {DefineComponent} from 'vue'
import { createInertiaApp } from '@inertiajs/vue3'
import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m'
import { Ziggy } from './ziggy'
import routeFn from 'ziggy-js'
//import { ZiggyVue } from 'ziggy-js/dist/vue.m.js'
//import { Ziggy } from './ziggy.js'
import i18next from 'i18next'
import I18NextVue from 'i18next-vue'
import Fetch from 'i18next-fetch-backend';
import urql, { cacheExchange, fetchExchange } from '@urql/vue';



declare global {
var route: typeof routeFn;
}

i18next
.use(Fetch)
.init({
Expand All @@ -25,25 +33,33 @@ i18next
})

createInertiaApp({
resolve: name => {
resolve: (name: string): DefineComponent | Promise<DefineComponent> | { default: DefineComponent; } => {
const pages = import.meta.glob('./Pages/**/*.vue', { eager: true })
// @ts-ignore
return pages[`./Pages/${name}.vue`]
},
setup({ el, App, props, plugin }) {
createApp({ render: () => h(App, props) })
.use(plugin)
.use(ZiggyVue, Ziggy)
// .use(ZiggyVue, Ziggy)
.use(I18NextVue, {i18next})
.use(urql, {
url: '/graphql',
exchanges: [cacheExchange, fetchExchange],
fetchOptions: () => {
const csrfToken = document.querySelector('meta[name="csrf-token"]').content
return {
headers: {
'X-CSRF-TOKEN': csrfToken
const csrfTokenMeta = document.querySelector('meta[name="csrf-token"]')
if (!csrfTokenMeta) {
console.log('No CSRF token was found on the current view, this should be an error');
return {}
} else {
const csrfToken = (<HTMLMetaElement>csrfTokenMeta).content
return {
headers: {
'X-CSRF-TOKEN': csrfToken
}
}
}

}
})
.mount(el)
Expand Down
12 changes: 12 additions & 0 deletions resources/js/bootstrap.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type jquery from "jquery"
import type axios from "axios"
import type popper from "popper.js"

declare global {
interface Window {
$: jquery;
jQuery: jquery;
axios: axios;
Popper: popper;
}
}
1 change: 1 addition & 0 deletions resources/js/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import jquery from 'jquery';

//try {

// @ts-ignore
window.Popper = popper;
window.$ = window.jQuery = jquery;
import bootstrap from 'bootstrap';
Expand Down
4 changes: 2 additions & 2 deletions resources/views/partials/head.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@
</a>

<div class="dropdown-menu" aria-labelledby="userMenuLink">
<a class="dropdown-item" href="<?php echo url('/me/profile'); ?>" data-i18n="nav.user.profile">My Profile</a>
<a class="dropdown-item" href="<?php echo url('/me/tokens'); ?>" data-i18n="nav.user.tokens">My API Tokens</a>
<a class="dropdown-item" href="<?php echo url('/user/profile'); ?>" data-i18n="nav.user.profile">My Profile</a>
<a class="dropdown-item" href="<?php echo url('/user/api-tokens'); ?>" data-i18n="nav.user.tokens">My API Tokens</a>
<div class="dropdown-divider"></div>

<form action="<?php echo route('logout'); ?>" method="POST">
Expand Down
4 changes: 0 additions & 4 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@

//Route::get('/search/{model}/{query}', 'Api\SearchController@searchModel')->where('query', '.*');

// Laravel JetStream-Alike Grafting
// Route::get('/user/profile', [UserProfileController::class, 'show'])
// ->name('profile.show');

// Developer-Only Routes (Should Never Be Visible in release)
if (App::environment('local')) {
Route::get('/test', 'TestController@index');
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"useDefineForClassFields": true,
"module": "ESNext",
"resolveJsonModule": true,
"noImplicitAny": false, // Temporarily required for graphql-codegen which generates an array of any
/**
* Typecheck JS in `.svelte` and `.js` files by default.
* Disable checkJs if you'd like to use dynamic types in JS.
Expand All @@ -16,7 +17,6 @@
"isolatedModules": true,
"types": [
"@types/node",
"@types/ziggy-js",
"vite/client"
],
"paths": {
Expand Down

0 comments on commit 1c29e98

Please sign in to comment.