Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] Add Support for Custom Periods #411

Closed

Conversation

devajmeireles
Copy link
Contributor

This PR aims to introduce support for custom periods via config file.

Demonstration

The config file:

/*
|--------------------------------------------------------------------------
| Pulse Periods
|--------------------------------------------------------------------------
|
| The following array lists the "periods" that will be available to select
| from the Pulse dashboard. You may modify this array as you wish, but
| ensure that the key is the period and the value is the hours.
|
*/

'periods' => [
    '1h' => 1,
    '6h' => 6,
    '24h' => 24,
    '7d' => 168,

    // customs 👇🏻 

    '30d' => 720,
    '7w' => 1_176,
],

The dashboard:

CleanShot 2024-09-30 at 21 05 46

Note

Although with this PR the name of the period-related prefixes will be changed, for example: 6_hours to 6h, I don't believe there will be any breaking changes. Also, we have the "default" period saved internally, to make this PR be compatible with published configuration files.

Tests

I haven't been able to identify an exact way to test this. All current tests continue to pass so I think this is sufficient. I'm open to suggestions on how to introduce tests.

| Pulse Periods
|--------------------------------------------------------------------------
|
| The following array lists the "periods" that will be available to select
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this description should be updated for better clarification.

return View::make('pulse::livewire.period-selector');
return View::make('pulse::livewire.period-selector', [
'periods' => $this->periods(),
'current' => $this->period,
Copy link
Contributor Author

@devajmeireles devajmeireles Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I preferred to send the current $period as $current to Blade so there is no name conflict here

@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants