-
Notifications
You must be signed in to change notification settings - Fork 328
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
Assistants page #559
Draft
drnic
wants to merge
8
commits into
AllYourBot:main
Choose a base branch
from
drnic:assistants-page
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Assistants page #559
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
96e2da6
Home page is now a list of assistants
drnic 1902730
Dedicated assistants page is a feature
drnic 90163f5
Include a simple description for each default Assistant
drnic d5adddd
More whitespace on header
drnic 8deec94
Less flakey export tests
drnic fa3cdcd
Rename partials
drnic 17c91d3
Less flakey export tests
drnic e75584d
Improvements to sticky top nav item
drnic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
class AssistantsController < ApplicationController | ||
before_action :set_nav_conversations | ||
before_action :set_nav_assistants | ||
|
||
def index | ||
assistant = Current.user.assistants.ordered.first | ||
redirect_to new_assistant_message_path(assistant), status: :see_other | ||
unless Feature.assistants_page? | ||
best_assistant = @nav_assistants.first | ||
redirect_to new_assistant_message_path(best_assistant), status: :see_other | ||
return | ||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div class="relative flex items-start space-x-3 rounded-lg border border-gray-300 bg-white px-6 py-5 shadow-sm focus-within:ring-2 focus-within:ring-indigo-500 focus-within:ring-offset-2 hover:border-gray-400"> | ||
<div class="w-7"> | ||
<%= render partial: "layouts/assistant_avatar", locals: { assistant:, size: 7, classes: "border-none" } %> | ||
</div> | ||
<div class="min-w-0 flex-1"> | ||
<%= link_to new_assistant_message_path(assistant), data: { role: "name" } do %> | ||
<span class="absolute inset-0" aria-hidden="true"></span> | ||
<p class="text-sm font-medium text-gray-900"><%= assistant.name %></p> | ||
<p class="text-sm text-gray-500"><%= assistant.description %></p> | ||
<% end %> | ||
</div> | ||
</div> |
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,11 @@ | ||
<%= content_for :nav_column do %> | ||
<%= render 'messages/nav_column' %> | ||
<% end %> | ||
|
||
<div class="container mx-[2rem] my-[4rem]"> | ||
<h1 class="text-2xl mb-4 font-semibold tracking-tighter">Assistants</h1> | ||
|
||
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3"> | ||
<%= render partial: "assistant_index", collection: @nav_assistants, as: :assistant %> | ||
</div> | ||
</div> |
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 |
---|---|---|
|
@@ -22,11 +22,12 @@ class UsersControllerTest < ActionDispatch::IntegrationTest | |
end | ||
|
||
test "should create user" do | ||
post users_url, params: { person: { personable_type: "User", email: "[email protected]", personable_attributes: user_attr } } | ||
assert_response :redirect | ||
follow_redirect! | ||
follow_redirect! # intentionally two redirects | ||
assert_response :success | ||
stub_features(assistants_page: true) do | ||
post users_url, params: { person: { personable_type: "User", email: "[email protected]", personable_attributes: user_attr } } | ||
assert_response :redirect | ||
follow_redirect! | ||
assert_response :success | ||
end | ||
end | ||
|
||
test "should redirect back when the email address is already in use" do | ||
|
@@ -51,19 +52,38 @@ class UsersControllerTest < ActionDispatch::IntegrationTest | |
assert_match "Email can't be blank", response.body | ||
end | ||
|
||
test "after create, an account should be bootstrapped and taken to a conversation" do | ||
email = "fake_email#{rand(1000)}@example.com" | ||
post users_url, params: { person: { personable_type: "User", email: email, personable_attributes: user_attr } } | ||
test "after create, an account should be bootstrapped and redirect to new conversation if assistants_page is disabled" do | ||
stub_features(assistants_page: false) do | ||
email = "fake_email#{rand(1000)}@example.com" | ||
post users_url, params: { person: { personable_type: "User", email: email, personable_attributes: user_attr } } | ||
|
||
user = Person.find_by(email: email).user | ||
assert_equal "John", user.first_name | ||
assert_equal "Doe", user.last_name | ||
assert_equal 3, user.assistants.count, "This new user did not get the expected number of assistants" | ||
|
||
user = Person.find_by(email: email).user | ||
assert_equal "John", user.first_name | ||
assert_equal "Doe", user.last_name | ||
assert_equal 3, user.assistants.count, "This new user did not get the expected number of assistants" | ||
assert_redirected_to root_path | ||
follow_redirect! | ||
assistant = user.assistants.ordered.first | ||
assert_redirected_to new_assistant_message_path(assistant) | ||
end | ||
end | ||
|
||
test "after create, an account should be bootstrapped and shown assistants if assistants_page is enabled" do | ||
stub_features(assistants_page: true) do | ||
email = "fake_email#{rand(1000)}@example.com" | ||
post users_url, params: { person: { personable_type: "User", email: email, personable_attributes: user_attr } } | ||
|
||
assistant = user.assistants.ordered.first | ||
user = Person.find_by(email: email).user | ||
assert_equal "John", user.first_name | ||
assert_equal "Doe", user.last_name | ||
assert_equal 3, user.assistants.count, "This new user did not get the expected number of assistants" | ||
|
||
follow_redirect! | ||
assert_redirected_to new_assistant_message_path(assistant) | ||
assert_redirected_to root_path | ||
follow_redirect! | ||
assert_response :success | ||
assert_select "h1", "Assistants" | ||
end | ||
end | ||
|
||
test "updates user preferences" do | ||
|
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed you removed this pt-14 and you within the _assistant_sidebar partial, you removed the
first
hack:I remember this being some tricky css to get the sidebar to make the first assistant sticky as the other items scrolled underneath it. Were you able to solve it a different way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I think this idea was getting in my way (since I wanted an "Assistants" header as the first thing) so I dropped it and assumed I'd come back to it later. I'll investigate this.