mirror of
https://github.com/outline/outline.git
synced 2026-11-30 17:10:36 +03:00
fix: Correct updatedAt on document data attributes
This commit is contained in:
1 parent
6a29e91ddf
commit
3db5462db7
7 files changed
+40
-27
No files matched your search
@@ -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"),
|
||||
|
||||
@@ -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 (
|
||||
<Scene
|
||||
title={t("Data Attributes")}
|
||||
icon={<DatabaseIcon />}
|
||||
icon={<DigitalIcon />}
|
||||
actions={
|
||||
<>
|
||||
{can.createDataAttribute && (
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -225,6 +225,11 @@ export default class DeliverWebhookTask extends BaseTask<Props> {
|
||||
case "userMemberships.update":
|
||||
// Ignored
|
||||
return;
|
||||
case "dataAttributes.create":
|
||||
case "dataAttributes.update":
|
||||
case "dataAttributes.delete":
|
||||
// Ignored
|
||||
return;
|
||||
default:
|
||||
assertUnreachable(event);
|
||||
}
|
||||
|
||||
@@ -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<DocumentDataAttribute, "updatedAt">[];
|
||||
/** 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"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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<string, any>[];
|
||||
dataAttributes: DocumentDataAttribute[];
|
||||
|
||||
/**
|
||||
* The content of the document as Markdown.
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in new issue
Block a user