Skip to content

A platform for community discussion. Free, open, simple.

UX: open user cards from workflow creator and editor avatars (#44765)

David Battersby3d2aef50633e
diff --git a/plugins/discourse-workflows/admin/assets/javascripts/admin/components/workflows/index.gjs b/plugins/discourse-workflows/admin/assets/javascripts/admin/components/workflows/index.gjs
index 7cb9115e07f..ff1d06a12ec 100644
--- a/plugins/discourse-workflows/admin/assets/javascripts/admin/components/workflows/index.gjs
+++ b/plugins/discourse-workflows/admin/assets/javascripts/admin/components/workflows/index.gjs
@@ -19,6 +19,7 @@ import DButton from "discourse/ui-kit/d-button";
import DFilterInput from "discourse/ui-kit/d-filter-input";
import DMultiSelect from "discourse/ui-kit/d-multi-select";
import DPageSubheader from "discourse/ui-kit/d-page-subheader";
+import DUserLink from "discourse/ui-kit/d-user-link";
import dAvatar from "discourse/ui-kit/helpers/d-avatar";
import dConcatClass from "discourse/ui-kit/helpers/d-concat-class";
import dFormatDate from "discourse/ui-kit/helpers/d-format-date";
@@ -333,12 +334,12 @@ export default class WorkflowsIndex extends Component {
{{i18n "discourse_workflows.creator"}}
</div>
{{#if workflow.createdBy}}
- <a
+ <DUserLink
class="workflows-index__creator-link"
- href={{workflow.createdBy.path}}
+ @user={{workflow.createdBy}}
>
{{dAvatar workflow.createdBy imageSize="tiny"}}
- </a>
+ </DUserLink>
{{/if}}
</td>
<td class="d-table__cell --overview workflows-index__name">
@@ -383,13 +384,13 @@ export default class WorkflowsIndex extends Component {
{{i18n "discourse_workflows.last_editor"}}
</div>
{{#if workflow.updatedBy}}
- <a
+ <DUserLink
class="workflows-index__last-editor-link"
- href={{workflow.updatedBy.path}}
+ @user={{workflow.updatedBy}}
>
{{dAvatar workflow.updatedBy imageSize="tiny"}}
<span>{{workflow.updatedBy.username}}</span>
- </a>
+ </DUserLink>
{{/if}}
</td>
<td class="d-table__cell --detail workflows-index__last-update">
diff --git a/plugins/discourse-workflows/admin/assets/javascripts/admin/components/workflows/variable/manager.gjs b/plugins/discourse-workflows/admin/assets/javascripts/admin/components/workflows/variable/manager.gjs
index 8b393de0e2f..1d86b8088b8 100644
--- a/plugins/discourse-workflows/admin/assets/javascripts/admin/components/workflows/variable/manager.gjs
+++ b/plugins/discourse-workflows/admin/assets/javascripts/admin/components/workflows/variable/manager.gjs
@@ -4,10 +4,10 @@ import { service } from "@ember/service";
import DMenu from "discourse/float-kit/components/d-menu";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
-import { userPath } from "discourse/lib/url";
import { clipboardCopy } from "discourse/lib/utilities";
import DButton from "discourse/ui-kit/d-button";
import DDropdownMenu from "discourse/ui-kit/d-dropdown-menu";
+import DUserLink from "discourse/ui-kit/d-user-link";
import dAvatar from "discourse/ui-kit/helpers/d-avatar";
import { i18n } from "discourse-i18n";
import AdminTable from "../admin-table.gjs";
@@ -149,13 +149,13 @@ export default class VariablesManager extends PaginatedListManager {
<div class="d-table__mobile-label">
{{i18n "discourse_workflows.variables.creator"}}
</div>
- <a
+ <DUserLink
class="workflows-variables__creator"
- href={{userPath variable.created_by.username}}
+ @user={{variable.created_by}}
>
{{dAvatar variable.created_by imageSize="tiny"}}
<span>{{variable.created_by.username}}</span>
- </a>
+ </DUserLink>
</td>
<td class="d-table__cell --detail">
<div class="d-table__mobile-label">
diff --git a/plugins/discourse-workflows/admin/assets/javascripts/admin/components/workflows/version/manager.gjs b/plugins/discourse-workflows/admin/assets/javascripts/admin/components/workflows/version/manager.gjs
index 807e63b37b3..f2568b00214 100644
--- a/plugins/discourse-workflows/admin/assets/javascripts/admin/components/workflows/version/manager.gjs
+++ b/plugins/discourse-workflows/admin/assets/javascripts/admin/components/workflows/version/manager.gjs
@@ -3,8 +3,8 @@ import { action } from "@ember/object";
import { service } from "@ember/service";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
-import { userPath } from "discourse/lib/url";
import DButton from "discourse/ui-kit/d-button";
+import DUserLink from "discourse/ui-kit/d-user-link";
import dAvatar from "discourse/ui-kit/helpers/d-avatar";
import dFormatDate from "discourse/ui-kit/helpers/d-format-date";
import { i18n } from "discourse-i18n";
@@ -112,13 +112,13 @@ export default class VersionsManager extends PaginatedListManager {
{{i18n "discourse_workflows.versions.author"}}
</div>
{{#if version.created_by}}
- <a
+ <DUserLink
class="workflows-versions__author"
- href={{userPath version.created_by.username}}
+ @user={{version.created_by}}
>
{{dAvatar version.created_by imageSize="tiny"}}
<span>{{version.created_by.username}}</span>
- </a>
+ </DUserLink>
{{/if}}
</td>
<td class="d-table__cell --detail">
diff --git a/plugins/discourse-workflows/spec/system/page_objects/pages/workflows.rb b/plugins/discourse-workflows/spec/system/page_objects/pages/workflows.rb
index 2ca860004fe..48bd26c9e93 100644
--- a/plugins/discourse-workflows/spec/system/page_objects/pages/workflows.rb
+++ b/plugins/discourse-workflows/spec/system/page_objects/pages/workflows.rb
@@ -70,6 +70,20 @@ module PageObjects
find(".workflows-index__name", text: name).find("a").click
self
end
+
+ def click_creator(workflow)
+ find(
+ ".workflows-index__row[data-item-id='#{workflow.id}'] .workflows-index__creator-link",
+ ).click
+ self
+ end
+
+ def click_last_editor(workflow)
+ find(
+ ".workflows-index__row[data-item-id='#{workflow.id}'] .workflows-index__last-editor-link",
+ ).click
+ self
+ end
end
end
end
diff --git a/plugins/discourse-workflows/spec/system/workflows_spec.rb b/plugins/discourse-workflows/spec/system/workflows_spec.rb
index d69fb067058..34d7da79edb 100644
--- a/plugins/discourse-workflows/spec/system/workflows_spec.rb
+++ b/plugins/discourse-workflows/spec/system/workflows_spec.rb
@@ -181,6 +181,23 @@ RSpec.describe "Discourse Workflows" do
expect(workflows_page).to have_no_failed_workflow(recovered_workflow)
end
+ it "opens a user card from the creator and last editor avatars" do
+ creator = Fabricate(:user)
+ editor = Fabricate(:user)
+ workflow = Fabricate(:discourse_workflows_workflow, created_by: creator)
+ workflow.update!(updated_by: editor)
+ user_card = PageObjects::Components::UserCard.new
+
+ workflows_page.visit_index
+
+ workflows_page.click_creator(workflow)
+ expect(user_card).to be_showing_user(creator.username)
+
+ page.send_keys(:escape)
+ workflows_page.click_last_editor(workflow)
+ expect(user_card).to be_showing_user(editor.username)
+ end
+
context "with workflow tags" do
fab!(:ops_workflow) do
Fabricate(