Skip to content

Commit afbd913

Browse files
committed
feat: support link cells in Views
1 parent 06b644d commit afbd913

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/dashboard/Data/Views/Views.react.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,13 @@ class Views extends TableView {
132132
if (text === undefined) {
133133
text = '';
134134
} else if (text && typeof text === 'object') {
135-
text = text.__type === 'Date' && text.iso ? text.iso : JSON.stringify(text);
135+
if (text.__type === 'Date' && text.iso) {
136+
text = text.iso;
137+
} else if (text.__type === 'Link' && text.text) {
138+
text = text.text;
139+
} else {
140+
text = JSON.stringify(text);
141+
}
136142
}
137143
text = String(text);
138144
if (typeof document !== 'undefined') {
@@ -166,6 +172,8 @@ class Views extends TableView {
166172
type = 'File';
167173
} else if (val.__type === 'GeoPoint') {
168174
type = 'GeoPoint';
175+
} else if (val.__type === 'Link') {
176+
type = 'Link';
169177
} else {
170178
type = 'Object';
171179
}
@@ -285,6 +293,8 @@ class Views extends TableView {
285293
type = 'File';
286294
} else if (value.__type === 'GeoPoint') {
287295
type = 'GeoPoint';
296+
} else if (value.__type === 'Link') {
297+
type = 'Link';
288298
} else {
289299
type = 'Object';
290300
}
@@ -306,6 +316,15 @@ class Views extends TableView {
306316
content = JSON.stringify(value);
307317
} else if (type === 'Date') {
308318
content = value && value.iso ? value.iso : String(value);
319+
} else if (type === 'Link') {
320+
const url = value.isRelativeUrl
321+
? `apps/${this.context.slug}/${value.url}`
322+
: value.url;
323+
content = (
324+
<a href={url} target="_blank" rel="noreferrer">
325+
{value.text}
326+
</a>
327+
);
309328
} else if (value === undefined) {
310329
content = '';
311330
} else {

0 commit comments

Comments
 (0)