Skip to content

Commit ddd6c29

Browse files
authored
Merge pull request #2 from merefield/refine_mobile_view
IMPROVE: add workflow topic title link, restrict workflow list to desktop
2 parents 0fd4ab8 + 64c3ba7 commit ddd6c29

File tree

7 files changed

+100
-40
lines changed

7 files changed

+100
-40
lines changed

assets/javascripts/discourse/components/workflow-name-link.gjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ export default class WorkflowButtonsComponent extends Component {
1919

2020
<template>
2121
<div class="workflow-action-button">
22-
<DButton class="btn-transparent" @action={{this.showVisualisationModal}}>
22+
<DButton
23+
class="btn-transparent"
24+
@action={{this.showVisualisationModal}}
25+
@icon={{@icon}}
26+
>
2327
{{@label}}
2428
</DButton>
2529
</div>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* eslint-disable ember/no-empty-glimmer-component-classes */
2+
3+
import Component from "@glimmer/component";
4+
import { i18n } from "discourse-i18n";
5+
import WorkflowNameLink from "../../components/workflow-name-link";
6+
7+
export default class WorkflowLink extends Component {
8+
get label() {
9+
return i18n("discourse_workflow.workflow_link", {
10+
workflow_name: this.args.outletArgs.topic.workflow_name,
11+
workflow_step_name: this.args.outletArgs.topic.workflow_step_name,
12+
});
13+
}
14+
15+
<template>
16+
{{#if @outletArgs.topic.workflow_name}}
17+
<span class="workflow-after-title">
18+
<WorkflowNameLink
19+
@topic_id={{@outletArgs.topic.id}}
20+
@workflow_name={{@outletArgs.topic.workflow_name}}
21+
@label={{this.label}}
22+
@icon="right-left"
23+
/>
24+
</span>
25+
{{/if}}
26+
</template>
27+
}

assets/javascripts/discourse/initializers/init-workflow.gjs

Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export default {
7575

7676
initialize(container) {
7777
const router = container.lookup("service:router");
78+
const mobileView = container.lookup("service:site").mobileView;
7879

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

92-
api.registerValueTransformer(
93-
"topic-list-columns",
94-
({ value: columns }) => {
95-
if (WORKFLOW_LIST_ROUTES.includes(router.currentRouteName)) {
96-
columns.add("workflow-name", {
97-
header: workflowNameHeader,
98-
item: workflowNameCell,
99-
after: "activity",
100-
});
101-
}
102-
return columns;
93+
api.registerValueTransformer("topic-list-item-class", ({ value }) => {
94+
if (WORKFLOW_LIST_ROUTES.includes(router.currentRouteName)) {
95+
value.push("workflow-list");
10396
}
104-
);
105-
106-
api.registerValueTransformer(
107-
"topic-list-columns",
108-
({ value: columns }) => {
109-
if (WORKFLOW_LIST_ROUTES.includes(router.currentRouteName)) {
110-
columns.add("workflow-step-position", {
111-
header: workflowStepPositionHeader,
112-
item: workflowStepPositionCell,
113-
after: "workflow-name",
114-
});
97+
return value;
98+
});
99+
100+
if (!mobileView) {
101+
api.registerValueTransformer(
102+
"topic-list-columns",
103+
({ value: columns }) => {
104+
if (WORKFLOW_LIST_ROUTES.includes(router.currentRouteName)) {
105+
columns.add("workflow-name", {
106+
header: workflowNameHeader,
107+
item: workflowNameCell,
108+
after: "activity",
109+
});
110+
}
111+
return columns;
115112
}
116-
return columns;
117-
}
118-
);
119-
120-
api.registerValueTransformer(
121-
"topic-list-columns",
122-
({ value: columns }) => {
123-
if (WORKFLOW_LIST_ROUTES.includes(router.currentRouteName)) {
124-
columns.add("workflow-step-name", {
125-
header: workflowStepNameHeader,
126-
item: workflowStepNameCell,
127-
after: "workflow-step-position",
128-
});
113+
);
114+
115+
api.registerValueTransformer(
116+
"topic-list-columns",
117+
({ value: columns }) => {
118+
if (WORKFLOW_LIST_ROUTES.includes(router.currentRouteName)) {
119+
columns.add("workflow-step-position", {
120+
header: workflowStepPositionHeader,
121+
item: workflowStepPositionCell,
122+
after: "workflow-name",
123+
});
124+
}
125+
return columns;
129126
}
130-
return columns;
131-
}
132-
);
127+
);
128+
129+
api.registerValueTransformer(
130+
"topic-list-columns",
131+
({ value: columns }) => {
132+
if (WORKFLOW_LIST_ROUTES.includes(router.currentRouteName)) {
133+
columns.add("workflow-step-name", {
134+
header: workflowStepNameHeader,
135+
item: workflowStepNameCell,
136+
after: "workflow-step-position",
137+
});
138+
}
139+
return columns;
140+
}
141+
);
142+
}
133143

134144
api.addPostSmallActionIcon("workflow_transition", "right-left");
135145
});

assets/stylesheets/common/workflow_common.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
.topic-list {
2+
.workflow-after-title .workflow-action-button {
3+
font-size: 0.8em;
4+
button {
5+
padding-left: 0px;
6+
}
7+
}
8+
9+
td.workflow-step-position .workflow-action-button {
10+
justify-content: center;
11+
display: flex;
12+
}
13+
}
14+
115
body.workflow-topic {
216
&:not(.staff) {
317
.edit-category__wrapper {

assets/stylesheets/desktop/workflow_desktop.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.workflow-list .workflow-after-title .workflow-action-button {
2+
display: none;
3+
}
4+
15
.workflow-visualisation-modal {
26
max-height: 800px;
37
width: 100%;

config/locales/client.en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ en:
3131
title: "Workflow"
3232
help: "topics involved in a workflow"
3333
discourse_workflow:
34+
workflow_link: "%{workflow_name}: %{workflow_step_name}"
3435
topic_banner:
3536
title: "Discourse Workflow"
3637
step_title: "Step:"

plugin.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22
# name: discourse-workflow
33
# about: A topic-based workflow engine for Discourse
4-
# version: 0.0.6
4+
# version: 0.0.7
55
# authors: Robert Barrow
66
# contact_emails: robert@pavilion.tech
77
# url: https://github.com/merefield/discourse-workflow

0 commit comments

Comments
 (0)