-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from datlechin/feat/trigger-click-reset-tour-guide
feat: Trigger click & Reset tour guide
- Loading branch information
Showing
28 changed files
with
222 additions
and
52 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
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
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,4 +1,9 @@ | ||
import Extend from 'flarum/common/extenders'; | ||
import TourGuideStep from './models/TourGuideStep'; | ||
import User from 'flarum/common/models/User'; | ||
|
||
export default [new Extend.Store().add('tour-guide-steps', TourGuideStep)]; | ||
export default [ | ||
new Extend.Model(User).attribute<boolean>('tourGuideDismissedAt').attribute<boolean>('canResetTourGuide'), | ||
|
||
new Extend.Store().add('tour-guide-steps', TourGuideStep), | ||
]; |
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,32 @@ | ||
import app from 'flarum/forum/app'; | ||
import { extend } from 'flarum/common/extend'; | ||
import extractText from 'flarum/common/utils/extractText'; | ||
import UserControls from 'flarum/forum/utils/UserControls'; | ||
import ItemList from 'flarum/common/utils/ItemList'; | ||
import User from 'flarum/common/models/User'; | ||
import Button from 'flarum/common/components/Button'; | ||
|
||
export default function () { | ||
// @ts-ignore | ||
extend(UserControls, 'userControls', function (items: ItemList<import('mithril').Children>, user: User) { | ||
const actor = app.session.user; | ||
|
||
// @ts-ignore | ||
if (!actor.canResetTourGuide() || !user.attribute('tourGuideDismissedAt')) { | ||
return; | ||
} | ||
|
||
const resetTourGuide = (user: User) => { | ||
if (confirm(extractText(app.translator.trans('datlechin-simple-tour-guide.forum.user_controls.reset_tour_guide_confirmation')))) { | ||
user.save({ tourGuideDismissedAt: null }).then(() => m.redraw()); | ||
} | ||
}; | ||
|
||
items.add( | ||
'reset-tour-guide', | ||
<Button icon="fas fa-sync" onclick={() => resetTourGuide(user)}> | ||
{app.translator.trans('datlechin-simple-tour-guide.forum.user_controls.reset_tour_guide')} | ||
</Button> | ||
); | ||
}); | ||
} |
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
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
18 changes: 18 additions & 0 deletions
18
migrations/2024_06_13_000000_add_is_trigger_click_column_to_tour_guide_steps_table.php
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,18 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
|
||
use Illuminate\Database\Schema\Builder; | ||
|
||
return [ | ||
'up' => function (Builder $schema) { | ||
$schema->table('tour_guide_steps', function (Blueprint $table) { | ||
$table->boolean('is_trigger_click')->default(false); | ||
}); | ||
}, | ||
'down' => function (Builder $schema) { | ||
$schema->table('tour_guide_steps', function (Blueprint $table) { | ||
$table->dropColumn('is_trigger_click'); | ||
}); | ||
}, | ||
]; |
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,18 @@ | ||
<?php | ||
|
||
namespace Datlechin\FlarumSimpleTourGuide\Access; | ||
|
||
use Flarum\User\User; | ||
use Flarum\User\Access\AbstractPolicy; | ||
|
||
class UserPolicy extends AbstractPolicy | ||
{ | ||
public function resetTourGuide(User $actor, User $user) | ||
{ | ||
if ($user->hasPermission('resetTourGuide')) { | ||
return $this->allow(); | ||
} | ||
|
||
return $this->deny(); | ||
} | ||
} |
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
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
Oops, something went wrong.