Skip to content

IMPROVE: add workflow topic title link, restrict additional workflow list columns to desktop #2

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

Merged
merged 8 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ export default class WorkflowButtonsComponent extends Component {

<template>
<div class="workflow-action-button">
<DButton class="btn-transparent" @action={{this.showVisualisationModal}}>
<DButton
class="btn-transparent"
@action={{this.showVisualisationModal}}
@icon={{@icon}}
>
{{@label}}
</DButton>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* eslint-disable ember/no-empty-glimmer-component-classes */

import Component from "@glimmer/component";
import { i18n } from "discourse-i18n";
import WorkflowNameLink from "../../components/workflow-name-link";

export default class WorkflowLink extends Component {
get label() {
return i18n("discourse_workflow.workflow_link", {
workflow_name: this.args.outletArgs.topic.workflow_name,
workflow_step_name: this.args.outletArgs.topic.workflow_step_name,
});
}

<template>
{{#if @outletArgs.topic.workflow_name}}
<span class="workflow-after-title">
<WorkflowNameLink
@topic_id={{@outletArgs.topic.id}}
@workflow_name={{@outletArgs.topic.workflow_name}}
@label={{this.label}}
@icon="right-left"
/>
</span>
{{/if}}
</template>
}
86 changes: 48 additions & 38 deletions assets/javascripts/discourse/initializers/init-workflow.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export default {

initialize(container) {
const router = container.lookup("service:router");
const mobileView = container.lookup("service:site").mobileView;

withPluginApi("1.39.0", (api) => {
api.addAdminPluginConfigurationNav("discourse-workflow", [
Expand All @@ -89,47 +90,56 @@ export default {
href: "/workflow",
});

api.registerValueTransformer(
"topic-list-columns",
({ value: columns }) => {
if (WORKFLOW_LIST_ROUTES.includes(router.currentRouteName)) {
columns.add("workflow-name", {
header: workflowNameHeader,
item: workflowNameCell,
after: "activity",
});
}
return columns;
api.registerValueTransformer("topic-list-item-class", ({ value }) => {
if (WORKFLOW_LIST_ROUTES.includes(router.currentRouteName)) {
value.push("workflow-list");
}
);

api.registerValueTransformer(
"topic-list-columns",
({ value: columns }) => {
if (WORKFLOW_LIST_ROUTES.includes(router.currentRouteName)) {
columns.add("workflow-step-position", {
header: workflowStepPositionHeader,
item: workflowStepPositionCell,
after: "workflow-name",
});
return value;
});

if (!mobileView) {
api.registerValueTransformer(
"topic-list-columns",
({ value: columns }) => {
if (WORKFLOW_LIST_ROUTES.includes(router.currentRouteName)) {
columns.add("workflow-name", {
header: workflowNameHeader,
item: workflowNameCell,
after: "activity",
});
}
return columns;
}
return columns;
}
);

api.registerValueTransformer(
"topic-list-columns",
({ value: columns }) => {
if (WORKFLOW_LIST_ROUTES.includes(router.currentRouteName)) {
columns.add("workflow-step-name", {
header: workflowStepNameHeader,
item: workflowStepNameCell,
after: "workflow-step-position",
});
);

api.registerValueTransformer(
"topic-list-columns",
({ value: columns }) => {
if (WORKFLOW_LIST_ROUTES.includes(router.currentRouteName)) {
columns.add("workflow-step-position", {
header: workflowStepPositionHeader,
item: workflowStepPositionCell,
after: "workflow-name",
});
}
return columns;
}
return columns;
}
);
);

api.registerValueTransformer(
"topic-list-columns",
({ value: columns }) => {
if (WORKFLOW_LIST_ROUTES.includes(router.currentRouteName)) {
columns.add("workflow-step-name", {
header: workflowStepNameHeader,
item: workflowStepNameCell,
after: "workflow-step-position",
});
}
return columns;
}
);
}

api.addPostSmallActionIcon("workflow_transition", "right-left");
});
Expand Down
14 changes: 14 additions & 0 deletions assets/stylesheets/common/workflow_common.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
.topic-list {
.workflow-after-title .workflow-action-button {
font-size: 0.8em;
button {
padding-left: 0px;
}
}

td.workflow-step-position .workflow-action-button {
justify-content: center;
display: flex;
}
}

body.workflow-topic {
&:not(.staff) {
.edit-category__wrapper {
Expand Down
4 changes: 4 additions & 0 deletions assets/stylesheets/desktop/workflow_desktop.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.workflow-list .workflow-after-title .workflow-action-button {
display: none;
}

.workflow-visualisation-modal {
max-height: 800px;
width: 100%;
Expand Down
1 change: 1 addition & 0 deletions config/locales/client.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ en:
title: "Workflow"
help: "topics involved in a workflow"
discourse_workflow:
workflow_link: "%{workflow_name}: %{workflow_step_name}"
topic_banner:
title: "Discourse Workflow"
step_title: "Step:"
Expand Down
2 changes: 1 addition & 1 deletion plugin.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
# name: discourse-workflow
# about: A topic-based workflow engine for Discourse
# version: 0.0.6
# version: 0.0.7
# authors: Robert Barrow
# contact_emails: robert@pavilion.tech
# url: https://github.com/merefield/discourse-workflow
Expand Down