diff --git a/app/hooks/useSettingsConfig.ts b/app/hooks/useSettingsConfig.ts
index e3a8cc6279..0826079f85 100644
--- a/app/hooks/useSettingsConfig.ts
+++ b/app/hooks/useSettingsConfig.ts
@@ -14,7 +14,7 @@ import {
ImportIcon,
ShapesIcon,
Icon,
- DatabaseIcon,
+ DigitalIcon,
} from "outline-icons";
import React, { ComponentProps } from "react";
import { useTranslation } from "react-i18next";
@@ -122,6 +122,16 @@ const useSettingsConfig = () => {
group: t("Workspace"),
icon: BeakerIcon,
},
+ {
+ name: t("Data Attributes"),
+ path: settingsPath("attributes"),
+ component: DataAttributes,
+ enabled:
+ can.createDataAttribute &&
+ FeatureFlags.isEnabled(Feature.dataAttributes),
+ group: t("Workspace"),
+ icon: DigitalIcon,
+ },
{
name: t("Members"),
path: settingsPath("members"),
@@ -146,16 +156,6 @@ const useSettingsConfig = () => {
group: t("Workspace"),
icon: ShapesIcon,
},
- {
- name: t("Data Attributes"),
- path: settingsPath("attributes"),
- component: DataAttributes,
- enabled:
- can.createDataAttribute &&
- FeatureFlags.isEnabled(Feature.dataAttributes),
- group: t("Workspace"),
- icon: DatabaseIcon,
- },
{
name: t("Shared Links"),
path: settingsPath("shares"),
diff --git a/app/scenes/Settings/DataAttributes.tsx b/app/scenes/Settings/DataAttributes.tsx
index 603a8999f3..26534602f2 100644
--- a/app/scenes/Settings/DataAttributes.tsx
+++ b/app/scenes/Settings/DataAttributes.tsx
@@ -1,5 +1,5 @@
import { observer } from "mobx-react";
-import { DatabaseIcon } from "outline-icons";
+import { DigitalIcon } from "outline-icons";
import * as React from "react";
import { useTranslation, Trans } from "react-i18next";
import DataAttribute from "~/models/DataAttribute";
@@ -26,7 +26,7 @@ function DataAttributes() {
return (
}
+ icon={}
actions={
<>
{can.createDataAttribute && (
diff --git a/app/utils/DataAttributesHelper.tsx b/app/utils/DataAttributesHelper.tsx
index d2cfa0b6fb..eed5a18ea5 100644
--- a/app/utils/DataAttributesHelper.tsx
+++ b/app/utils/DataAttributesHelper.tsx
@@ -14,7 +14,7 @@ export class DataAttributesHelper {
public static getName(dataType: DataAttributeDataType, t: TFunction) {
switch (dataType) {
case DataAttributeDataType.Boolean:
- return t("True / False");
+ return t("Boolean");
case DataAttributeDataType.Number:
return t("Number");
case DataAttributeDataType.String:
diff --git a/plugins/webhooks/server/tasks/DeliverWebhookTask.ts b/plugins/webhooks/server/tasks/DeliverWebhookTask.ts
index 2a705d9db9..d93a1734c3 100644
--- a/plugins/webhooks/server/tasks/DeliverWebhookTask.ts
+++ b/plugins/webhooks/server/tasks/DeliverWebhookTask.ts
@@ -225,6 +225,11 @@ export default class DeliverWebhookTask extends BaseTask {
case "userMemberships.update":
// Ignored
return;
+ case "dataAttributes.create":
+ case "dataAttributes.update":
+ case "dataAttributes.delete":
+ // Ignored
+ return;
default:
assertUnreachable(event);
}
diff --git a/server/commands/documentUpdater.ts b/server/commands/documentUpdater.ts
index 7ce93e5193..106b7aca89 100644
--- a/server/commands/documentUpdater.ts
+++ b/server/commands/documentUpdater.ts
@@ -1,6 +1,6 @@
import uniqBy from "lodash/uniqBy";
import { Transaction } from "sequelize";
-import { Primitive } from "utility-types";
+import { DocumentDataAttribute } from "@shared/models/types";
import { Event, Document, User } from "@server/models";
import { DocumentHelper } from "@server/models/helpers/DocumentHelper";
@@ -10,10 +10,7 @@ type Props = {
/** The existing document */
document: Document;
/** TODO: Data attributes to apply to the document */
- dataAttributes?: {
- dataAttributeId: string;
- value: Primitive;
- }[];
+ dataAttributes?: Omit[];
/** The new title */
title?: string;
/** The document icon */
@@ -75,12 +72,22 @@ export default async function documentUpdater({
if (dataAttributes !== undefined) {
// TODO: Validate schema
+
document.dataAttributes = uniqBy(
- dataAttributes.map(({ dataAttributeId, value }) => ({
- dataAttributeId,
- value,
- updatedAt: new Date(),
- })),
+ dataAttributes.map(({ dataAttributeId, value }) => {
+ const existing = document.dataAttributes.find(
+ (da) => da.dataAttributeId === dataAttributeId
+ );
+ if (existing?.value === value) {
+ return existing as DocumentDataAttribute;
+ }
+
+ return {
+ dataAttributeId,
+ value,
+ updatedAt: new Date().toISOString(),
+ } as DocumentDataAttribute;
+ }),
"dataAttributeId"
);
}
diff --git a/server/models/Document.ts b/server/models/Document.ts
index 9c093caa8d..87cc514dc6 100644
--- a/server/models/Document.ts
+++ b/server/models/Document.ts
@@ -42,6 +42,7 @@ import {
} from "sequelize-typescript";
import isUUID from "validator/lib/isUUID";
import { ZodError } from "zod";
+import { DocumentDataAttribute } from "@shared/models/types";
import type {
NavigationNode,
ProsemirrorData,
@@ -283,7 +284,7 @@ class Document extends ParanoidModel<
// TODO
@Column(DataType.JSONB)
- dataAttributes: Record[];
+ dataAttributes: DocumentDataAttribute[];
/**
* The content of the document as Markdown.
diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json
index f0d763e615..9e119fbc18 100644
--- a/shared/i18n/locales/en_US/translation.json
+++ b/shared/i18n/locales/en_US/translation.json
@@ -463,9 +463,9 @@
"Details": "Details",
"Security": "Security",
"Features": "Features",
+ "Data Attributes": "Data Attributes",
"Members": "Members",
"Groups": "Groups",
- "Data Attributes": "Data Attributes",
"Shared Links": "Shared Links",
"Import": "Import",
"Self Hosted": "Self Hosted",
@@ -1003,7 +1003,7 @@
"A confirmation code has been sent to your email address, please enter the code below to permanently destroy your account.": "A confirmation code has been sent to your email address, please enter the code below to permanently destroy your account.",
"Are you sure? Deleting your account will destroy identifying data associated with your user and cannot be undone. You will be immediately logged out of {{appName}} and all your API tokens will be revoked.": "Are you sure? Deleting your account will destroy identifying data associated with your user and cannot be undone. You will be immediately logged out of {{appName}} and all your API tokens will be revoked.",
"Delete my account": "Delete my account",
- "True / False": "True / False",
+ "Boolean": "Boolean",
"Number": "Number",
"Text": "Text",
"List": "List",