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

Dynamic warranty link for manufacturers' support urls #12906

Merged
merged 8 commits into from
Apr 26, 2023

Conversation

akemidx
Copy link
Collaborator

@akemidx akemidx commented Apr 25, 2023

A way to dynamically produce a manufacturur's warranty link has been added.

Instead of building out code per individual manufacturer which is unscalable, this method will allow any manufacturer to have a warranty link be customized for use.

SupportURLs can now be written with {LOCALE} and {SERIAL} tags in them. Using these tags, the system will automatically replace {LOCALE} with the localization variable selected in settings. {SERIAL} will be replaced with the serial number of the asset being viewed.

For example:
Screenshot 2023-04-24 at 8 30 55 PM

-strict URL validation has been removed.
-urls must have :// in them to validate.
-Other special characters are now allowed as long as :// is in the link.
-No existing urls or presaved links should be affected, but will need to have :// if the manufacturer is edited in the future.
-urls are free to not use the tags
-the individual icons for manufacturers have been changed to a default "outside link" icon next to the warranty months

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Tested in local. on existing manufacturers and with newly created manufacturers.

Checklist:

@shortcut-integration
Copy link

This pull request has been linked to Shortcut Story #20622: Dynamic manufacturer link.

@what-the-diff
Copy link

what-the-diff bot commented Apr 25, 2023

PR Summary

  • Added SaveManufacturerRequest.php file
    A new file to handle saving manufacturer requests.
  • Update support_url rule in Manufacturer model
    Changed the validation to use regex instead of only accepting URLs.
  • Dynamic URL in AssetPresenter class
    The view method now returns a dynamic URL with serial number and locale for the manufacturer's support_url field, if it exists. Otherwise, it returns false (as before).
  • Improved support URL handling in hardware/view template
    Replaced manufacturer-specific icons with a generic external link icon, and the link will directly point to the URL generated by $asset->present()->supportUrl(). This adds flexibility for adding new manufacturers and allows users to use custom URLs for warranty lookup without relying on external sites.

@akemidx
Copy link
Collaborator Author

akemidx commented Apr 25, 2023

Additionally, a byproduct of this change will open up the support url field to be used for more diverse links/clickthroughs rather than strict web urls

$this->merge([
'support_url' => $this->input('support_url'),
]);
dd($this->all());
Copy link
Owner

Choose a reason for hiding this comment

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

We probably don't want to leave a dd() in there

'support_email' => 'email|nullable',
'support_url' => ['regex:/.+:\/\/.+/','nullable'],
Copy link
Owner

@snipe snipe Apr 26, 2023

Choose a reason for hiding this comment

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

As I mentioned on the dev call, we might be able to simplify this a bit, using the starts_with validation.

'support_url' => 'nullable|starts_with:http://,https://',afp://,facetime://,file://,irc://'

Copy link
Owner

@snipe snipe left a comment

Choose a reason for hiding this comment

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

This looks really good - just a few changes!

@snipe snipe mentioned this pull request Apr 26, 2023
10 tasks
@snipe snipe changed the title [FEATURE] Dynamic warranty link for manufacturers' support urls Dynamic warranty link for manufacturers' support urls Apr 26, 2023
'support_email' => 'email|nullable',
'support_url' => ['starts_with:http://,https://,afp://,facetime://,file://,irc://','nullable'],
Copy link
Owner

Choose a reason for hiding this comment

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

Do we need to use brackets here? I don't think we do - just

'support_url' => 'nullable|starts_with:http://,https://,afp://,facetime://,file://,irc://',

should do it, no? I'd prefer that for consistency if it works.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

all set

@@ -3,6 +3,7 @@
namespace App\Http\Controllers;

use App\Http\Requests\ImageUploadRequest;
use App\Http\Requests\SaveManufacturerRequest;
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think we need this anymore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

all set

@snipe snipe merged commit 5eac314 into snipe:develop Apr 26, 2023
4 checks passed
@akemidx akemidx deleted the feature/sc-20622 branch April 23, 2024 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants