Skip to content

Commit 9f7f77b

Browse files
committed
Add Japanese translation of Steps from Apps documents
1 parent ee7befd commit 9f7f77b

7 files changed

+222
-2
lines changed

docs/_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ t:
3737
contribute: Contributing
3838
ja-jp:
3939
basic: 基本的な概念
40-
# steps: ワークフローステップ
40+
steps: ワークフローステップ
4141
# advanced: 応用コンセプト
4242
start: Bolt 入門ガイド
4343
# contribute: 貢献

docs/_steps/adding_editing_workflow_step.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ order: 3
99

1010
When a builder adds (or later edits) your step in their workflow, your app will receive a [`workflow_step_edit` event](https://api.slack.com/reference/workflows/workflow_step_edit). The `edit` callback in your `WorkflowStep` configuration will be run when this event is received.
1111

12-
Whether a builder is adding or editing a step, you need to send them a [workflow step configuration modal](https://api.slack.com/reference/workflows/configuration-view). This modal is where step-specific settings are chosen, and it has more restrictions than typical modals—most notably, it cannot include `title`, `submit`, or `close` properties. By default, the configuration modal's `callback_id` will be the same as the workflow step.
12+
Whether a builder is adding or editing a step, you need to send them a [workflow step configuration modal](https://api.slack.com/reference/workflows/configuration-view). This modal is where step-specific settings are chosen, and it has more restrictions than typical modals—most notably, it cannot include `title`, `submit`, or `close` properties. By default, the configuration modal's `callback_id` will be the same as the workflow step.
1313

1414
Within the `edit` callback, the `configure()` utility can be used to easily open your step's configuration modal by passing in the view's blocks with the corresponding `blocks` argument. To disable saving the configuration before certain conditions are met, you can also pass in `submit_disabled` with a value of `True`.
1515

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: ステップの追加・編集
3+
lang: ja-jp
4+
slug: adding-editing-steps
5+
order: 3
6+
---
7+
8+
<div class='section-content'>
9+
10+
作成したワークフローステップがワークフローに追加またはその設定を変更されるタイミングで、[`workflow_step_edit` イベントがアプリに送信されます](https://api.slack.com/reference/workflows/workflow_step_edit)。このイベントがアプリに届くと、`WorkflowStep` で設定した `edit` コールバックが実行されます。
11+
12+
ステップの追加と編集のどちらが行われるときも、[ワークフローステップの設定モーダル](https://api.slack.com/reference/workflows/configuration-view)をビルダーに送信する必要があります。このモーダルは、そのステップ独自の設定を選択するための場所です。通常のモーダルより制限が強く、例えば `title``submit``close` のプロパティを含めることができません。設定モーダルの `callback_id` は、デフォルトではワークフローステップと同じものになります。
13+
14+
`edit` コールバック内で `configure()` ユーティリティを使用すると、対応する `blocks` 引数にビューのblocks 部分だけを渡して、ステップの設定モーダルを簡単に表示させることができます。必要な入力内容が揃うまで設定の保存を無効にするには、`True` の値をセットした `submit_disabled` を渡します。
15+
16+
設定モーダルの開き方について詳しくは、[ドキュメントを参照してください](https://api.slack.com/workflows/steps#handle_config_view)
17+
18+
</div>
19+
20+
```python
21+
def edit(ack, step, configure):
22+
ack()
23+
24+
blocks = [
25+
{
26+
"type": "input",
27+
"block_id": "task_name_input",
28+
"element": {
29+
"type": "plain_text_input",
30+
"action_id": "name",
31+
"placeholder": {"type": "plain_text", "text":"Add a task name"},
32+
},
33+
"label": {"type": "plain_text", "text":"Task name"},
34+
},
35+
{
36+
"type": "input",
37+
"block_id": "task_description_input",
38+
"element": {
39+
"type": "plain_text_input",
40+
"action_id": "description",
41+
"placeholder": {"type": "plain_text", "text":"Add a task description"},
42+
},
43+
"label": {"type": "plain_text", "text":"Task description"},
44+
},
45+
]
46+
configure(blocks=blocks)
47+
48+
ws = WorkflowStep(
49+
callback_id="add_task",
50+
edit=edit,
51+
save=save,
52+
execute=execute,
53+
)
54+
app.step(ws)
55+
```
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: ステップの定義
3+
lang: ja-jp
4+
slug: creating-steps
5+
order: 2
6+
---
7+
8+
<div class='section-content'>
9+
10+
ワークフローステップの作成には、Bolt が提供する `WorkflowStep` クラスを利用します。
11+
12+
ステップの `callback_id` と設定オブジェクトを指定して、`WorkflowStep` の新しいインスタンスを作成します。
13+
14+
設定オブジェクトは、`edit``save``execute` という 3 つのキーを持ちます。それぞれのキーは、単一のコールバック、またはコールバックのリストである必要があります。すべてのコールバックは、ワークフローステップのイベントに関する情報を保持する `step` オブジェクトにアクセスできます。
15+
16+
`WorkflowStep` のインスタンスを作成したら、それを`app.step()` メソッドに渡します。これによって、アプリがワークフローステップのイベントをリッスンし、設定オブジェクトで指定されたコールバックを使ってそれに応答できるようになります。
17+
18+
</div>
19+
20+
```python
21+
import os
22+
from slack_bolt import App
23+
from slack_bolt.workflows.step import WorkflowStep
24+
25+
# いつも通りBolt アプリを起動する
26+
app = App(
27+
token=os.environ.get("SLACK_BOT_TOKEN"),
28+
signing_secret=os.environ.get("SLACK_SIGNING_SECRET")
29+
)
30+
31+
def edit(ack, step, configure):
32+
pass
33+
34+
def save(ack, view, update):
35+
pass
36+
37+
def execute(step, complete, fail):
38+
pass
39+
40+
# WorkflowStep の新しいインスタンスを作成する
41+
ws = WorkflowStep(
42+
callback_id="add_task",
43+
edit=edit,
44+
save=save,
45+
execute=execute,
46+
)
47+
# ワークフローステップを渡してリスナーを設定する
48+
app.step(ws)
49+
```
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: ステップの実行
3+
lang: ja-jp
4+
slug: executing-steps
5+
order: 5
6+
---
7+
8+
<div class="section-content">
9+
10+
エンドユーザーがワークフローステップを実行すると、アプリに [`workflow_step_execute` イベントが送信されます](https://api.slack.com/events/workflow_step_execute)。このイベントがアプリに届くと、`WorkflowStep` で設定した `execute` コールバックが実行されます。
11+
12+
`save` コールバックで取り出した `inputs` を使って、サードパーティの API を呼び出す、情報をデータベースに保存する、ユーザーのホームタブを更新するといった処理を実行することができます。また、ワークフローの後続のステップで利用する出力値を `outputs` オブジェクトに設定します。
13+
14+
`execute` コールバック内では、`complete()` を呼び出してステップの実行が成功したことを示すか、`fail()` を呼び出してステップの実行が失敗したことを示す必要があります。
15+
16+
</div>
17+
18+
```python
19+
def execute(step, complete, fail):
20+
inputs = step["inputs"]
21+
# すべての処理が成功した場合
22+
outputs = {
23+
"task_name": inputs["task_name"]["value"],
24+
"task_description": inputs["task_description"]["value"],
25+
}
26+
complete(outputs=outputs)
27+
28+
# 失敗した処理がある場合
29+
error = {"message":"Just testing step failure!"}
30+
fail(error=error)
31+
32+
ws = WorkflowStep(
33+
callback_id="add_task",
34+
edit=edit,
35+
save=save,
36+
execute=execute,
37+
)
38+
app.step(ws)
39+
```
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: ステップの設定の保存
3+
lang: ja-jp
4+
slug: saving-steps
5+
order: 4
6+
---
7+
8+
<div class='section-content'>
9+
10+
設定モーダルを開いた後、アプリは `view_submission` イベントをリッスンします。このイベントがアプリに届くと、`WorkflowStep` で設定した `save` コールバックが実行されます。
11+
12+
`save` コールバック内では、`update()` メソッドを使って、ワークフローに追加されたステップの設定を保存することができます。このメソッドには次の引数を指定します。
13+
14+
- `inputs` : ユーザーがワークフローステップを実行したときにアプリが受け取る予定のデータを表す辞書型の値です。
15+
- `outputs` : ワークフローステップの完了時にアプリが出力するデータが設定されたオブジェクトのリストです。この outputs は、ワークフローの後続のステップで利用することができます。
16+
- `step_name` : ステップのデフォルトの名前をオーバーライドします。
17+
- `step_image_url` : ステップのデフォルトの画像をオーバーライドします。
18+
19+
これらのパラメータの構成方法について詳しくは、[ドキュメントを参照してください](https://api.slack.com/reference/workflows/workflow_step)
20+
21+
</div>
22+
23+
```python
24+
def save(ack, view, update):
25+
ack()
26+
27+
values = view["state"]["values"]
28+
task_name = values["task_name_input"]["name"]
29+
task_description = values["task_description_input"]["description"]
30+
31+
inputs = {
32+
"task_name": {"value": task_name["value"]},
33+
"task_description": {"value": task_description["value"]}
34+
}
35+
outputs = [
36+
{
37+
"type": "text",
38+
"name": "task_name",
39+
"label":"Task name",
40+
},
41+
{
42+
"type": "text",
43+
"name": "task_description",
44+
"label":"Task description",
45+
}
46+
]
47+
update(inputs=inputs, outputs=outputs)
48+
49+
ws = WorkflowStep(
50+
callback_id="add_task",
51+
edit=edit,
52+
save=save,
53+
execute=execute,
54+
)
55+
app.step(ws)
56+
```
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: ワークフローステップの概要
3+
lang: ja-jp
4+
slug: steps-overview
5+
order: 1
6+
---
7+
8+
<div class="section-content">
9+
(アプリによる)ワークフローステップでは、処理をアプリ側で行うカスタムのワークフローステップを提供することができます。ユーザーは[ワークフロービルダー](https://api.slack.com/workflows)を使ってこれらのステップをワークフローに追加できます。
10+
11+
ワークフローステップは、次の 3 つのユーザーイベントで構成されます。
12+
13+
- ワークフローステップをワークフローに追加・変更する
14+
- ワークフロー内のステップの設定内容を更新する
15+
- エンドユーザーがそのステップを実行する
16+
17+
ワークフローステップを機能させるためには、これら 3 つのイベントすべてに対応する必要があります。
18+
19+
アプリを使ったワークフローステップについて詳しくは、[API ドキュメント](https://api.slack.com/workflows/steps)を参照してください。
20+
21+
</div>

0 commit comments

Comments
 (0)