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

feature: discreet information #3592

Merged
merged 15 commits into from
Feb 28, 2025
Merged

feature: discreet information #3592

merged 15 commits into from
Feb 28, 2025

Conversation

adrianthedev
Copy link
Collaborator

@adrianthedev adrianthedev commented Jan 17, 2025

Description

This PR brings the ability to add some discreet information to your records' Show and Edit pages.

API

# 1. One item

# predefined item
self.discreet_information = :timestamps

# custom
self.discreet_information = {
  tooltip: -> { sanitize("Product is <strong>#{record.published_at ? "published" : "draft"}</strong>", tags: %w[strong]) },
  icon: -> { "heroicons/outline/#{record.published_at ? "eye" : "eye-slash"}" }
}

# 2. Multiple items
self.discreet_information = [
  :timestamps,
  {
    tooltip: -> { sanitize("Product is <strong>#{record.published_at ? "published" : "draft"}</strong>", tags: %w[strong]) },
    icon: -> { "heroicons/outline/#{record.published_at ? "eye" : "eye-slash"}" }
  },
  {
    label: -> { record.published_at ? "✅" : "🙄" },
    tooltip: -> { "Post is #{record.published_at ? "published" : "draft"}. Click to toggle." },
    url: -> {
      Avo::Actions::TogglePublished.path(
        resource: resource,
        arguments: {
          records: Array.wrap(record.id),
          no_confirmation: true
        }
      )
    },
    data: Avo::BaseAction::DATA_ATTRIBUTES
  }
]

Within the item object the user can customize:

  • tooltip
  • icon with what we have documented on icons
  • url with anothing they want
  • data with data attributes. I guess turbo_confirm and turbo_method should work...

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Screenshots & recording

CleanShot 2025-01-17 at 15 43 34@2x

Manual review steps

  1. Step 1
  2. Step 2

Manual reviewer: please leave a comment with output from the test if that's the case.

Copy link

codeclimate bot commented Jan 17, 2025

Code Climate has analyzed commit 31281b2 and detected 0 issues on this pull request.

View more on Code Climate.

@adrianthedev adrianthedev self-assigned this Jan 20, 2025
Copy link
Contributor

github-actions bot commented Feb 5, 2025

This PR has been marked as stale because there was no activity for the past 15 days.

@github-actions github-actions bot added the Stale label Feb 5, 2025
@Paul-Bob Paul-Bob removed the Stale label Feb 5, 2025
@Paul-Bob Paul-Bob marked this pull request as ready for review February 28, 2025 12:14
@Paul-Bob Paul-Bob merged commit 6a6d122 into main Feb 28, 2025
19 of 20 checks passed
@Paul-Bob Paul-Bob deleted the feature/discreet-information branch February 28, 2025 12:19
Copy link
Contributor

This PR has been merged into main. The functionality will be available in the next release.

Please check the release guide for more information.

@xeron
Copy link

xeron commented Mar 4, 2025

@adrianthedev not sure if intended but translations are missing for en.avo.created_at_timestamp and en.avo.updated_at_timestamp.

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.

3 participants