Skip to content

Commit 7d3d17a

Browse files
committed
feat(declarativeui): use relative URLs only, icon is a URL to the icon file
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
1 parent 8feaa1a commit 7d3d17a

File tree

2 files changed

+11
-24
lines changed

2 files changed

+11
-24
lines changed

lib/Capabilities.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ public function __construct(
4545
* url: string,
4646
* method: string,
4747
* mimetype_filters: string,
48-
* android_icon: string,
49-
* desktop_icon: string,
50-
* ios_icon: string,
48+
* icon: string,
5149
* }>
5250
* }>,
5351
* }
@@ -96,15 +94,14 @@ public function getCapabilities(): array {
9694
'fileId' => '123456789',
9795
'taskTypeId' => TextToTextSummary::ID,
9896
]);
97+
$url = str_replace($this->urlGenerator->getBaseUrl(), '', $url);
9998
$url = str_replace('123456789', '{fileId}', $url);
10099
$endpoint = [
101100
'name' => $this->l->t('Summarize'),
102101
'url' => $url,
103102
'method' => 'POST',
104103
'mimetype_filters' => implode(', ', $textMimeTypes),
105-
'android_icon' => 'creation',
106-
'ios_icon' => 'creation',
107-
'desktop_icon' => 'creation',
104+
'icon' => $this->urlGenerator->imagePath(Application::APP_ID, 'declarativeui/summarize.svg'),
108105
];
109106
$capabilities['declarativeui'][Application::APP_ID]['context-menu'][] = $endpoint;
110107
}
@@ -113,17 +110,16 @@ public function getCapabilities(): array {
113110
$url = $this->urlGenerator->linkToOCSRouteAbsolute(Application::APP_ID . '.assistantApi.runFileAction', [
114111
'apiVersion' => 'v1',
115112
'fileId' => '123456789',
116-
'taskTypeId' => \OCP\TaskProcessing\TaskTypes\TextToSpeech::ID,
113+
'taskTypeId' => AudioToText::ID,
117114
]);
115+
$url = str_replace($this->urlGenerator->getBaseUrl(), '', $url);
118116
$url = str_replace('123456789', '{fileId}', $url);
119117
$endpoint = [
120118
'name' => $this->l->t('Transcribe audio'),
121119
'url' => $url,
122120
'method' => 'POST',
123121
'mimetype_filters' => 'audio/',
124-
'android_icon' => 'speech_to_text',
125-
'ios_icon' => 'speech_to_text',
126-
'desktop_icon' => 'speech_to_text',
122+
'icon' => $this->urlGenerator->imagePath(Application::APP_ID, 'declarativeui/speech_to_text.svg'),
127123
];
128124
$capabilities['declarativeui'][Application::APP_ID]['context-menu'][] = $endpoint;
129125
}
@@ -132,17 +128,16 @@ public function getCapabilities(): array {
132128
$url = $this->urlGenerator->linkToOCSRouteAbsolute(Application::APP_ID . '.assistantApi.runFileAction', [
133129
'apiVersion' => 'v1',
134130
'fileId' => '123456789',
135-
'taskTypeId' => AudioToText::ID,
131+
'taskTypeId' => \OCP\TaskProcessing\TaskTypes\TextToSpeech::ID,
136132
]);
133+
$url = str_replace($this->urlGenerator->getBaseUrl(), '', $url);
137134
$url = str_replace('123456789', '{fileId}', $url);
138135
$endpoint = [
139136
'name' => $this->l->t('Text to speech'),
140137
'url' => $url,
141138
'method' => 'POST',
142139
'mimetype_filters' => implode(', ', $textMimeTypes),
143-
'android_icon' => 'text_to_speech',
144-
'ios_icon' => 'text_to_speech',
145-
'desktop_icon' => 'text_to_speech',
140+
'icon' => $this->urlGenerator->imagePath(Application::APP_ID, 'declarativeui/text_to_speech.svg'),
146141
];
147142
$capabilities['declarativeui'][Application::APP_ID]['context-menu'][] = $endpoint;
148143
}

openapi.json

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,7 @@
230230
"url",
231231
"method",
232232
"mimetype_filters",
233-
"android_icon",
234-
"desktop_icon",
235-
"ios_icon"
233+
"icon"
236234
],
237235
"properties": {
238236
"name": {
@@ -247,13 +245,7 @@
247245
"mimetype_filters": {
248246
"type": "string"
249247
},
250-
"android_icon": {
251-
"type": "string"
252-
},
253-
"desktop_icon": {
254-
"type": "string"
255-
},
256-
"ios_icon": {
248+
"icon": {
257249
"type": "string"
258250
}
259251
}

0 commit comments

Comments
 (0)