refactor(core): doc property (#8465)

doc property upgraded to use orm.

The visibility of the property are simplified to three types: `always show`, `always hide`, `hide when empty`, and the default is `always show`.

![CleanShot 2024-10-14 at 15 34 52](https://github.com/user-attachments/assets/748b8b80-061f-4d6a-8579-52e59df717c2)

Added a sidebar view to manage properties
![CleanShot 2024-10-14 at 15 35 58](https://github.com/user-attachments/assets/bffa9b1a-a1a5-4708-b2e8-4963120f3af9)

new property ui in workspace settings
![CleanShot 2024-10-14 at 15 36 44](https://github.com/user-attachments/assets/572d8dcc-9b3d-462a-9bcc-5f5fa8e622da)

Property lists can be collapsed
![CleanShot 2024-10-14 at 15 37 59](https://github.com/user-attachments/assets/2b20be1a-8141-478a-8fe7-405aff6d04fd)
This commit is contained in:
EYHN
2024-10-15 10:17:11 +00:00
parent 13b24eb823
commit 24e0c5797c
88 changed files with 3151 additions and 3617 deletions

View File

@@ -127,9 +127,7 @@ export const createPageWithTag = async (
await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('test page');
await page.getByTestId('page-info-collapse').click();
await page
.locator('[data-testid="page-property-row"][data-property="tags"]')
.click();
await page.locator('[data-testid="property-tags-value"]').click();
for (const name of options.tags) {
await createTag(page, name);
}

View File

@@ -1,9 +1,9 @@
import type { Page } from '@playwright/test';
import type { Locator, Page } from '@playwright/test';
import { expect } from '@playwright/test';
export const getPropertyValueLocator = (page: Page, property: string) => {
return page.locator(
`[data-testid="page-property-row-name"]:has-text("${property}") + *`
`[data-testid="doc-property-name"]:has-text("${property}") + *`
);
};
@@ -66,9 +66,12 @@ export const searchAndCreateTag = async (page: Page, name: string) => {
.click();
};
export const expectTagsVisible = async (page: Page, tags: string[]) => {
const tagListPanel = page
.getByTestId('page-property-row')
export const expectTagsVisible = async (
root: Locator | Page,
tags: string[]
) => {
const tagListPanel = root
.getByTestId('property-tags-value')
.getByTestId('inline-tags-list');
expect(await tagListPanel.locator('[data-tag-value]').count()).toBe(
@@ -82,8 +85,8 @@ export const expectTagsVisible = async (page: Page, tags: string[]) => {
}
};
export const clickAddPropertyButton = async (page: Page) => {
await page
export const clickAddPropertyButton = async (root: Locator | Page) => {
await root
.getByRole('button', {
name: 'Add property',
})
@@ -92,40 +95,17 @@ export const clickAddPropertyButton = async (page: Page) => {
export const addCustomProperty = async (
page: Page,
type: string,
inSettings?: boolean
root: Locator | Page,
type: string
) => {
await clickAddPropertyButton(page);
if (!inSettings) {
await expect(
page.getByRole('heading', {
name: 'Properties',
})
).toBeVisible();
await page
.getByRole('menuitem', {
name: 'Create property',
})
.click();
}
await expect(
page.getByRole('heading', {
name: 'Type',
})
).toBeVisible();
await clickAddPropertyButton(root);
await page
.getByRole('menuitem', {
name: type,
})
.locator(
`[data-testid="${'create-property-menu-item'}"][data-property-type="${type}"]`
)
.click();
if (!inSettings) {
await expect(
page
.getByRole('menuitem', {
name: type,
})
.locator('.selected')
).toBeVisible();
if (await page.getByTestId('edit-property-menu-item').isVisible()) {
// is edit property menu opened, close it
await page.keyboard.press('Escape');
}
await page.waitForTimeout(500);
@@ -184,12 +164,10 @@ export const changePropertyVisibility = async (
name: string,
option: string
) => {
await expect(page.getByTestId('page-info-show-more')).toBeVisible();
await page.click('[data-testid="page-info-show-more"]');
await expect(
page.getByRole('heading', {
name: 'customize properties',
})
).toBeVisible();
await selectVisibilitySelector(page, name, option);
await page
.locator(`[data-testid="doc-property-name"]:has-text("${name}")`)
.click();
await page.locator(`[data-property-visibility="${option}"]`).click();
await page.keyboard.press('Escape');
await page.waitForTimeout(500);
};