Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(styles): rewrite block styles #868

Merged
merged 14 commits into from
Oct 25, 2024

Conversation

gene9831
Copy link
Collaborator

@gene9831 gene9831 commented Oct 22, 2024

English | 简体中文

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Built its own designer, fully self-validated

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Background and solution

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new image display component (PluginBlockItemImg) with optional checkbox functionality.
    • Enhanced block list display with a new header section and improved item rendering using the PluginBlockItemImg component.
  • Improvements

    • Improved filtering capabilities for selection options in the internationalization binding component.
    • Enhanced visual representation with SVG icons across various components.
    • Streamlined user interactions and error handling in several components, including block management and version selection.
    • Added new props for enhanced functionality in the block list component, allowing for multi-selection and layout customization.
    • Improved layout and error handling in the block group panel.
    • Enhanced user interaction by providing clearer feedback and improved layout for the folder settings interface.
    • Improved responsiveness and usability in the lifecycle management interface.
  • Bug Fixes

    • Simplified event handling by removing unnecessary tooltip components, enhancing clarity and maintainability.
  • Styling Updates

    • Adjusted styles for better layout and responsiveness across multiple components, including padding and flexbox adjustments.
    • Enhanced layout properties for improved presentation of block items and user interfaces.
    • Updated styles to improve the visual organization of components, including the block panel and tree structure.

@github-actions github-actions bot added the refactor-main refactor/develop branch feature label Oct 22, 2024
@gene9831 gene9831 marked this pull request as ready for review October 23, 2024 03:09
Copy link
Contributor

coderabbitai bot commented Oct 23, 2024

Walkthrough

The changes in this pull request involve multiple Vue components, enhancing their functionality, layout, and styling. Key modifications include the introduction of new props, restructuring templates, and improving user interactions through updated event handling. Notable components affected are BindI18n.vue, BlockDescription.vue, and PluginBlockItemImg.vue, among others. The overall aim is to streamline the user interface, improve responsiveness, and enhance the visual appeal of various components.

Changes

File Path Change Summary
packages/common/component/BindI18n.vue Modified template structure, script logic, and styles; added filter-method prop to tiny-select, updated paramsChange method, and adjusted styles for better layout.
packages/common/component/BlockDescription.vue Removed type attribute from meta-description, replaced text-based add icon with SVG, and introduced new layout styles.
packages/common/component/BlockLinkField.vue Updated template structure with new props for tiny-popover, restructured context menu items to include SVG icons, and refined styling for improved user interaction.
packages/common/component/ConfigItem.vue Adjusted layout and error handling; removed linked class, modified tiny-popover logic, and enhanced error message visibility.
packages/common/component/MetaListItem.vue Removed tiny-tooltip components, simplifying event handling for edit actions.
packages/common/component/PluginBlockItemImg.vue Introduced a new component for displaying images with optional checkbox; includes error handling for image loading.
packages/common/component/PluginBlockList.vue Added a new header section for block list display and integrated PluginBlockItemImg for item rendering; introduced new props for layout customization.
packages/plugins/block/src/BlockGroupArrange.vue Removed tiny-tooltip component, simplifying icon interactions.
packages/plugins/block/src/Main.vue Wrapped plugin-block-list in a new <div> for improved layout and styling adjustments.
packages/plugins/block/src/composable/useBlock.js Refactored check and cancelCheck functions for block selection management, enhancing code clarity.
packages/plugins/materials/src/meta/block/src/BlockGroupArrange.vue Removed tooltip component, adjusted layout for button icons.
packages/plugins/materials/src/meta/block/src/BlockGroupPanel.vue Enhanced functionality with new reactive reference for user data and improved error handling in block addition.
packages/plugins/materials/src/meta/block/src/BlockGroupTransfer.vue Replaced block-group-transfer-panel with block-list, updating selection logic and component structure.
packages/plugins/materials/src/meta/block/src/BlockList.vue Added new props for checkbox visibility and selection management; integrated props into the template.
packages/plugins/materials/src/meta/block/src/BlockPanel.vue Added a new wrapper for the block-list component to enhance layout without altering functionality.
packages/plugins/materials/src/meta/block/src/BlockVersionSelect.vue Removed version selection button, updated grid structure for version display, and introduced new methods for version handling.
packages/plugins/page/src/PageTree.vue Simplified template structure by removing conditional checks for folder icons and adjusting styling for better layout.
packages/settings/props/src/Main.vue Modified template and script for improved responsiveness; adjusted styles for the block description.

Possibly related PRs

Suggested reviewers

  • hexqi
  • chilingling

🐇 In the garden, changes bloom,
Components dance, dispelling gloom.
With icons bright and layouts neat,
A user-friendly, joyful feat!
So hop along, let’s celebrate,
These wondrous updates we create! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (25)
packages/common/component/BlockDescription.vue (1)

2-7: Consider internationalizing the text content

The Chinese text "设置区块暴露属性" should be moved to a translation file for better internationalization support.

-        <span>设置区块暴露属性</span>
+        <span>{{ $t('block.setExposedProperties') }}</span>
packages/plugins/block/src/BlockGroupArrange.vue (2)

18-18: Remove empty components option.

The empty components object is unnecessary and can be removed to improve code cleanliness.

-  components: {},

Line range hint 17-35: Consider migrating to TypeScript.

To improve type safety and developer experience, consider converting this component to TypeScript. This would allow for better type definitions for props and state.

Example TypeScript interface for the arrangeList items:

interface ArrangeItem {
  id: string;
  name: string;
  svgName: string;
}

// Props interface
interface Props {
  modelValue: string;
  arrangeList: ArrangeItem[];
}
packages/plugins/materials/src/meta/block/src/BlockGroupArrange.vue (2)

68-70: LGTM with a minor suggestion for consistency.

The flex layout and explicit dimensions improve the visual consistency of the component.

Consider consolidating the dimensions to CSS variables for better maintainability:

 :deep(.tiny-tabs.tiny-tabs .tiny-tabs__item) {
-    width: 24px;
-    height: 24px;
+    width: var(--ti-lowcode-tab-item-size, 24px);
+    height: var(--ti-lowcode-tab-item-size, 24px);
 }

Also applies to: 94-98


Line range hint 33-36: Consider extracting arrangement types to constants.

The default value 'grid' and the type checking in typeClick suggest these are predefined arrangements. Consider extracting these to a constants file for better maintainability and reusability.

Example implementation:

// constants.js
export const BLOCK_ARRANGEMENTS = {
  GRID: 'grid',
  LIST: 'list'
};

// In component
import { BLOCK_ARRANGEMENTS } from './constants';

// Props
modelValue: {
  type: String,
  default: BLOCK_ARRANGEMENTS.GRID,
  validator: (value) => Object.values(BLOCK_ARRANGEMENTS).includes(value)
}
packages/common/component/PluginBlockItemImg.vue (3)

6-12: Add accessibility attributes to improve screen reader support.

The image element should include appropriate accessibility attributes:

 <img
   v-if="item.screenshot"
   class="item-image"
   :src="item.screenshot || defaultImg"
+  :alt="item.name || 'Block preview image'"
+  role="img"
   draggable="false"
   @error="$event.target.src = defaultImg"
 />

40-44: Translate Chinese comment to English for consistency.

-    // 是否显示多选框
+    // Whether to display checkbox

76-76: Document CSS custom properties.

The component uses CSS custom properties for theming. Consider adding documentation for these variables:

// Add to the top of the style section:
/**
 * CSS Custom Properties used:
 * --ti-lowcode-component-block-list-item-active-bg: Background color for active block items
 * --te-common-bg-default: Default background color for icons
 */

Also applies to: 99-99

packages/plugins/materials/src/meta/block/src/BlockGroupTransfer.vue (2)

Line range hint 97-116: Improve error handling and code structure.

Several improvements could be made to this section:

  1. Error handling for the fetch call is missing
  2. The nested conditions could be simplified
  3. The error message is hardcoded and not internationalized
 const checkBlock = (block) => {
-  if (selectedBlockArray.value.some((item) => item.id === block.id)) {
-    cancelCheck(block)
-    return
-  }
+  const isSelected = selectedBlockArray.value.some((item) => item.id === block.id);
+  if (isSelected) {
+    return cancelCheck(block);
+  }
 
   // 添加区块时,默认添加区块最新版本
   if (!block.latestVersion) {
-    fetchBlockById(block.id).then((blockDetail) => {
-      const historyLength = blockDetail?.histories?.length || 0
-      if (historyLength <= 0) {
-        const { message } = useModal()
-        message({ message: `${blockDetail.label}区块缺少历史记录,请重新发布区块`, status: 'error' })
-      } else {
-        block.latestVersion = blockDetail?.histories[historyLength - 1]?.version
-        check(block)
-      }
-    })
+    try {
+      const blockDetail = await fetchBlockById(block.id);
+      const histories = blockDetail?.histories || [];
+      
+      if (histories.length === 0) {
+        const { message } = useModal();
+        message({ 
+          message: t('block.error.no_history', { label: blockDetail.label }),
+          status: 'error'
+        });
+        return;
+      }
+      
+      block.latestVersion = histories[histories.length - 1].version;
+      check(block);
+    } catch (error) {
+      const { message } = useModal();
+      message({ 
+        message: t('block.error.fetch_failed'),
+        status: 'error'
+      });
+    }
   } else {
     check(block)
   }
 }

158-159: Consider using CSS custom properties for magic numbers.

The height calculation uses a magic number (232px). Consider extracting this to a CSS custom property for better maintainability.

 .block-add-transfer {
   flex: 1;
   display: flex;
   flex-direction: column;
   justify-content: space-between;
-  height: calc(100% - 232px);
+  height: calc(100% - var(--block-transfer-offset, 232px));
 }
packages/plugins/materials/src/meta/block/src/BlockVersionSelect.vue (2)

4-4: Verify if the commented button code should be removed.

The commented-out button code should be removed if it's no longer needed, rather than leaving it as a comment.

-      <!-- <tiny-button type="primary" @click="selectVersion">确定</tiny-button> -->

Line range hint 75-117: Consider refactoring the version change logic for better maintainability.

While the implementation is functional, the nested promise chain could be simplified for better readability and maintenance.

Consider restructuring like this:

-    const handleChangeVersion = (selectedRow) => {
-      if (selectedRow) {
-        confirm({
-          title: '修改区块版本',
-          message: '您确定要修改区块版本吗?',
-          exec: () => {
-            const params = {
-              groupId: selectedBlock.value.groupId,
-              blockId: selectedRow.block_id,
-              blockVersion: selectedRow.version
-            }
-
-            requestGroupBlockVersion(params)
-              .then(() => {
-                isRefresh.value = true
-                closePanel()
-                confirm({
-                  title: '切换区块版本成功',
-                  message: `${selectedBlock.value.label}区块,已切换为${selectedRow.version}版本,修改版本后需要刷新页面才生效,是否刷新页面?`,
-                  exec: () => {
-                    window.location.reload()
-                  }
-                })
-              })
-              .catch((error) => {
-                message({
-                  message: `${selectedBlock.value.label}区块切换版本失败:${error.message || error}`,
-                  status: 'error'
-                })
-              })
-          }
-        })
-      }
-    }
+    const handleVersionChange = async (params) => {
+      try {
+        await requestGroupBlockVersion(params)
+        isRefresh.value = true
+        closePanel()
+        return true
+      } catch (error) {
+        message({
+          message: `${selectedBlock.value.label}区块切换版本失败:${error.message || error}`,
+          status: 'error'
+        })
+        return false
+      }
+    }
+
+    const handleChangeVersion = async (selectedRow) => {
+      if (!selectedRow) return
+
+      const confirmed = await confirm({
+        title: '修改区块版本',
+        message: '您确定要修改区块版本吗?'
+      })
+
+      if (!confirmed) return
+
+      const success = await handleVersionChange({
+        groupId: selectedBlock.value.groupId,
+        blockId: selectedRow.block_id,
+        blockVersion: selectedRow.version
+      })
+
+      if (success) {
+        const shouldRefresh = await confirm({
+          title: '切换区块版本成功',
+          message: `${selectedBlock.value.label}区块,已切换为${selectedRow.version}版本,修改版本后需要刷新页面才生效,是否刷新页面?`
+        })
+        
+        if (shouldRefresh) {
+          window.location.reload()
+        }
+      }
+    }
packages/plugins/materials/src/meta/block/src/BlockPanel.vue (1)

189-192: Consider using a CSS variable for padding value

While the styling changes look good, consider using a CSS variable for the padding value to maintain consistency across the application. This would make it easier to update spacing globally.

 .block-list {
-  padding: 12px;
+  padding: var(--ti-lowcode-block-list-padding, 12px);
   overflow-y: auto;
 }
packages/common/component/BindI18n.vue (4)

175-175: Style changes look good, with room for improvement.

The spacing and alignment changes improve the layout consistency. Consider these optional enhancements:

  1. Use CSS variables for consistent spacing:
.languageContent {
-  margin-bottom: 16px;
+  margin-bottom: var(--ti-spacing-16);
}
.addNewLanguage {
  .tiny-input {
-    padding: 0 8px;
+    padding: 0 var(--ti-spacing-8);
  }
}
  1. Make flex properties more explicit:
.tiny-input__inner {
-  flex: 1;
+  flex: 1 1 auto;
}

Also applies to: 200-205, 209-211, 214-214


Line range hint 8-13: Consider optimizing the filter method implementation.

The current filterMethod implementation could be more efficient by:

  1. Debouncing the filter operation
  2. Using case-insensitive comparison
<tiny-select
  ref="selectRef"
  v-model="selectValue"
  placeholder="请根据显示值搜索"
  filterable
  :filter-method="filterMethod"
  @change="selectI18n"
>

Add debouncing in the script section:

import { debounce } from 'lodash-es'

// In setup():
const filterMethod = debounce((value) => {
  const options = selectRef.value.state.cachedOptions
  const searchValue = value.toLowerCase()
  
  options.forEach((item) => {
    item.state.visible = value ? item.label.toLowerCase().includes(searchValue) : true
  })
}, 300)

Line range hint 92-108: Add type validation for parameters.

The paramsChange method should validate parameter values before emitting.

const paramsChange = () => {
  const params = {}
+ // Validate parameter values
+ const isValid = paramsForm.value.every(({ name, value }) => {
+   if (!name || typeof value === 'undefined') {
+     console.warn(`Invalid parameter: ${name}`)
+     return false
+   }
+   return true
+ })

+ if (!isValid) return

  paramsForm.value.forEach(({ name, value }) => {
    params[name] = value
  })
  emit('bind', { type: PROP_DATA_TYPE.I18N, key: selectValue.value, params })
}

Line range hint 110-116: Enhance editForm initialization.

The openCreateForm method could be more robust with proper type initialization.

const openCreateForm = () => {
-  Object.keys(editForm).forEach((key) => delete editForm[key])
+  // Reset form with default values
+  const defaultForm = {
+    key: `lowcode.${utils.guid()}`,
+    type: PROP_DATA_TYPE.I18N
+  }
+  
+  // Initialize language fields
+  props.locales.forEach(({ lang }) => {
+    defaultForm[lang] = ''
+  })
+  
+  Object.assign(editForm, defaultForm)
-  editForm.key = 'lowcode.' + utils.guid()
-  editForm.type = PROP_DATA_TYPE.I18N
   showEditItem.value = true
}
packages/plugins/materials/src/meta/block/src/BlockList.vue (1)

52-65: Standardize props documentation style

The props documentation style is inconsistent:

  • showBlockShot uses block comments
  • showCheckbox and checked use inline comments
  • gridColumns lacks documentation

Consider using block comments consistently for all props to improve maintainability.

    showBlockShot: {
      type: Boolean,
      default: true
    },
-    // 是否显示多选框
+    /*
+      是否显示多选框
+    */
    showCheckbox: {
      type: Boolean,
      default: false
    },
-    // 选中的区块
+    /*
+      选中的区块
+    */
    checked: {
      type: Array,
      default: () => []
    },
+    /*
+      网格列数
+    */
    gridColumns: {
      type: Number,
      default: 2
    }
packages/common/component/MetaListItem.vue (1)

39-46: Consider extracting modal logic into a composable.

The component handles multiple state variables (isShow, isVisible, showMask) for modal/popover management. Consider extracting this logic into a reusable composable function (e.g., useModal) to improve maintainability and reusability across similar components.

Example structure:

// useModal.ts
export function useModal() {
  const isVisible = ref(false)
  const showMask = ref(false)
  
  const show = () => {
    isVisible.value = true
    showMask.value = true
  }
  
  const hide = () => {
    isVisible.value = false
    showMask.value = false
  }
  
  return {
    isVisible,
    showMask,
    show,
    hide
  }
}
packages/plugins/materials/src/meta/block/src/BlockGroupPanel.vue (1)

Line range hint 117-141: Improve error handling in addBlocks method

While the changes improve the method with early returns and success notifications, the error handling could be enhanced.

Consider returning early after showing the error message to prevent continuing with panel closure:

 .catch((error) => {
   message({
     message: `添加区块失败: ${error.message || error}`,
     status: 'error'
   })
+  return
 })
 panelState.isBlockGroupPanel = false
 closePanel()
packages/plugins/page/src/PageTree.vue (2)

268-282: LGTM with a minor suggestion on class names

The refactored template structure is cleaner and more maintainable. However, consider using more semantic class names:

-          <SvgIcon name="text-page-common" class="icon-page"></SvgIcon>
+          <SvgIcon name="text-page-common" class="page-icon"></SvgIcon>

Line range hint 364-420: LGTM with style optimization suggestions

The style changes improve maintainability and visual consistency. Consider these optimizations:

 .app-manage-tree {
   :deep(.tiny-tree) {
     .tiny-tree-node__label {
       font-size: 12px;
       display: flex;
       align-items: center;
       flex: 1;
 
-      & > .svg-icon {
+      .svg-icon {
         margin-right: 4px;
       }
-      & .label {
+      .label {
         font-size: 12px;
         flex: 1;
       }
     }
 
     .tree-node-icon {
       margin-right: 0;
     }
 
-    .svg-icon {
-      width: 14px;
-      height: 14px;
-    }
+    .svg-icon {
+      width: 14px;
+      height: 14px;
+    }
 
     .icons {
       display: flex;
       align-items: center;
       gap: 4px;
     }
 
     .tiny-tree-node.is-leaf .tiny-tree-node__content {
       padding-left: 0;
     }
 
     .tiny-tree-node.is-current {
-      & > .tiny-tree-node__content {
-        & > div > .tiny-tree-node__content-box {
-          background-color: var(--te-common-bg-container);
-        }
+      .tiny-tree-node__content {
+        .tiny-tree-node__content-box {
+          background-color: var(--te-common-bg-container);
+        }
       }
     }
   }
 }

These changes:

  1. Remove unnecessary nesting with &
  2. Consolidate identical selectors
  3. Simplify the selector hierarchy
packages/plugins/block/src/composable/useBlock.js (1)

689-699: Well-structured refactoring of block selection logic.

The changes to both functions represent a good architectural improvement:

  • Simplified API by removing the unnecessary blockList parameter
  • Consistent use of immutable array operations
  • Proper integration with Vue's reactivity system

Consider documenting these functions with JSDoc comments to clarify:

  • Parameter types and requirements
  • Return values
  • Usage examples
packages/common/component/PluginBlockList.vue (2)

434-440: Update deprecated :deep() to ::v-deep in scoped CSS

The :deep() combinator is deprecated in Vue 3 in favor of ::v-deep. Updating to the new syntax ensures compatibility with future versions of Vue.

Apply this diff:

-.col-checkbox,
-.block-item-small-list:deep(.table-selection) {
+.col-checkbox,
+.block-item-small-list::v-deep(.table-selection) {
  width: 40px;
  text-align: center;
}
-.col-checkbox:deep(.tiny-checkbox__label) {
+.col-checkbox::v-deep(.tiny-checkbox__label) {
  padding: 0;
}

489-493: Use ::v-deep instead of :deep() for deep selectors

Consistently update all instances of :deep() to ::v-deep in your scoped CSS to align with Vue 3 conventions.

Apply this diff:

-  &:deep(.block-item-img) {
+  &::v-deep(.block-item-img) {
    width: 54px;
    height: 40px;
    flex: unset;
    margin-left: 8px;
  }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6a736b6 and 7c782bc.

⛔ Files ignored due to path filters (4)
  • packages/design-core/assets/block-add-prop.svg is excluded by !**/*.svg
  • packages/design-core/assets/block-bind-prop.svg is excluded by !**/*.svg
  • packages/design-core/assets/text-copy-page.svg is excluded by !**/*.svg
  • packages/design-core/assets/编辑2.svg is excluded by !**/*.svg
📒 Files selected for processing (18)
  • packages/common/component/BindI18n.vue (2 hunks)
  • packages/common/component/BlockDescription.vue (2 hunks)
  • packages/common/component/BlockLinkField.vue (3 hunks)
  • packages/common/component/ConfigItem.vue (1 hunks)
  • packages/common/component/MetaListItem.vue (1 hunks)
  • packages/common/component/PluginBlockItemImg.vue (1 hunks)
  • packages/common/component/PluginBlockList.vue (14 hunks)
  • packages/plugins/block/src/BlockGroupArrange.vue (1 hunks)
  • packages/plugins/block/src/Main.vue (2 hunks)
  • packages/plugins/block/src/composable/useBlock.js (1 hunks)
  • packages/plugins/materials/src/meta/block/src/BlockGroupArrange.vue (4 hunks)
  • packages/plugins/materials/src/meta/block/src/BlockGroupPanel.vue (6 hunks)
  • packages/plugins/materials/src/meta/block/src/BlockGroupTransfer.vue (6 hunks)
  • packages/plugins/materials/src/meta/block/src/BlockList.vue (2 hunks)
  • packages/plugins/materials/src/meta/block/src/BlockPanel.vue (2 hunks)
  • packages/plugins/materials/src/meta/block/src/BlockVersionSelect.vue (5 hunks)
  • packages/plugins/page/src/PageTree.vue (6 hunks)
  • packages/settings/props/src/Main.vue (1 hunks)
🧰 Additional context used
🔇 Additional comments (39)
packages/settings/props/src/Main.vue (3)

Line range hint 9-44: LGTM! Well-structured reactive logic

The script implementation follows Vue Composition API best practices with proper:

  • Reactive state management using ref and computed
  • Side effect handling with watchEffect
  • Clean component registration

45-47: Verify margin consistency with design system

The margin change from 10px to 12px should align with the design system's spacing scale.

Let's check for consistency in spacing values:

#!/bin/bash
# Description: Check for consistent margin usage across components
# Look for margin declarations in Vue files
rg "margin:\s+\d+px" --type vue

Line range hint 1-8: Verify Empty component implementation and user experience

The Empty component's visibility is controlled by showEmptyTips, but we should ensure this provides a good user experience when properties are empty.

Let's check the Empty component implementation:

✅ Verification successful

Let me try different search strategies to verify the Empty component implementation.

The previous command failed due to file type issues, so I'm using more generic searches to find the relevant files. This will help us verify:

  1. Where the Empty component is defined
  2. How showEmptyTips is used across the codebase
  3. Other instances of Empty component usage for consistency

Let me check the Empty component implementation to complete the verification.

This will help us verify:

  1. The implementation of the Empty component being used
  2. Whether it follows consistent patterns with other empty state components
  3. The proper handling of the showEmptyTips prop

Empty component implementation is properly handled and follows best practices

The Empty component implementation is well-designed and provides appropriate feedback:

  • It correctly uses the showEmptyTips prop to control visibility
  • It dynamically updates the message based on canvas state (empty canvas vs no selection)
  • It integrates with the broadcast channel system to react to schema changes
  • The styling is consistent with the design system using CSS variables

The implementation provides good user experience by:

  1. Showing different messages for different empty states
  2. Using appropriate styling for empty state messaging
  3. Reactively updating based on user interactions
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify Empty component implementation and usage patterns
# Look for other usages of Empty component and its showEmptyTips prop
rg -l "showEmptyTips" --type vue

Length of output: 162


Script:

#!/bin/bash
# Search for Empty component definition and usage
# First, find files containing "Empty" component references
rg -l "Empty"

# Then search for showEmptyTips prop usage
rg "showEmptyTips"

# Also look for Empty component definition
fd -e vue -e js -e ts Empty

Length of output: 2744


Script:

#!/bin/bash
# Check the Empty component implementation
cat packages/settings/props/src/components/Empty.vue

# Also check if there's any shared empty component implementation
cat packages/common/component/EmptyTip.vue

Length of output: 2158

packages/common/component/BlockDescription.vue (1)

39-60: Well-structured styling improvements

The style changes demonstrate good practices:

  • Proper use of design system variables
  • Modern layout techniques with flexbox
  • Consistent spacing and sizing
  • Clean nesting structure with Less
packages/plugins/materials/src/meta/block/src/BlockGroupArrange.vue (2)

6-8: Verify the UX impact of removing tooltips.

While removing the tooltip wrapper simplifies the code, consider whether this impacts user experience, especially for new users who might need guidance on what each icon represents.

Consider adding title attributes to maintain basic hover tooltips:

-          <span class="button-icon-item" @click="typeClick(item.id)">
+          <span class="button-icon-item" @click="typeClick(item.id)" :title="item.id">

17-17: LGTM!

The import statement is correctly updated to reflect the removal of the tooltip component.

packages/common/component/PluginBlockItemImg.vue (2)

51-63: Clean implementation of event handling.

The setup function follows Vue 3 Composition API best practices with proper computed property usage and event emission.


27-30: Verify component integration with PluginBlockList.

The component appears to be part of a larger refactoring effort. Let's verify its integration:

✅ Verification successful

Let me try a different approach to verify the component integration.

This should help us understand:

  1. Where PluginBlockItemImg is being used
  2. Where PluginBlockList exists and its relationship
  3. The usage pattern of Checkbox component
  4. The overall Vue component structure

Let me check the integration details between these components.

This will help us understand:

  1. How PluginBlockItemImg is integrated within PluginBlockList
  2. The relationship with BlockList.vue in materials plugin
  3. How these components are exported and made available to other parts of the application

Based on the gathered information, I can now provide a final response:

Component integration is properly structured and verified.

The verification shows that:

  1. PluginBlockItemImg is correctly imported and registered in PluginBlockList.vue
  2. The component is properly integrated within the common components ecosystem, with PluginBlockList being exported in the index.js
  3. The Checkbox import from @opentiny/vue is appropriate as there are no conflicting checkbox implementations in the common components
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of PluginBlockItemImg component
rg -l "PluginBlockItemImg" --type vue

# Check for any existing checkbox-related components that might conflict
ast-grep --pattern 'import { Checkbox } from "@opentiny/vue"'

Length of output: 129


Script:

#!/bin/bash
# Search for any file containing PluginBlockItemImg, without file type restriction
rg -l "PluginBlockItemImg"

# Search for files containing PluginBlockList to understand integration
rg -l "PluginBlockList"

# Look for Checkbox imports or usage patterns
rg -l "Checkbox"

# Find all Vue files in the repository
fd ".*\.vue$"

Length of output: 18802


Script:

#!/bin/bash
# Check the content of PluginBlockList.vue to understand how it uses PluginBlockItemImg
rg -A 10 "PluginBlockItemImg" "packages/common/component/PluginBlockList.vue"

# Check how BlockList.vue in materials plugin uses these components
rg -A 10 "PluginBlockItemImg" "packages/plugins/materials/src/meta/block/src/BlockList.vue"

# Check the exports in common/component/index.js
cat "packages/common/component/index.js"

Length of output: 5446

packages/plugins/materials/src/meta/block/src/BlockGroupTransfer.vue (3)

29-29: LGTM!

The import and registration of the BlockList component is clean and follows Vue best practices.

Also applies to: 36-36


141-142: LGTM!

The state management and exports are clean and well-structured.


11-21: Verify that this refactor maintains existing functionality.

The replacement of BlockGroupTransferPanel with BlockList introduces new behavioral props (trigger-check, show-block-shot, etc.) which suggest functional changes beyond the stated PR objective of style refactoring.

packages/plugins/materials/src/meta/block/src/BlockVersionSelect.vue (5)

8-26: LGTM! Improved grid structure with better user interaction.

The grid modifications improve the UX by:

  • Providing clear column headers
  • Adding direct per-row actions
  • Showing formatted dates

38-39: LGTM! Clean import organization.

The imports are properly organized and aligned with the component's needs.


118-120: LGTM! Clear and concise version check.

The isCurrentVersion method is well-implemented and serves its purpose effectively.


127-130: LGTM! Clean method exports.

The exports are well-organized and include all necessary methods.


145-153: LGTM! Well-structured button styles.

The styles are properly scoped and use appropriate CSS variables for theming.

packages/plugins/materials/src/meta/block/src/BlockPanel.vue (1)

7-9: LGTM: Clean structural improvement

The addition of the .block-list wrapper div improves the layout organization while maintaining the existing functionality. This change aligns well with the PR's style refactoring objective.

packages/common/component/BlockLinkField.vue (4)

15-22: LGTM: Improved menu item clarity.

The addition of icons and more descriptive text enhances the user experience by making actions more intuitive.


67-67: LGTM: Simplified dialog title.

The dialog title change makes it more concise while maintaining clarity.


2-2: Verify the absolute positioning of icons.

The template now uses absolutely positioned icons with z-index management. While this creates an interesting visual effect, it might cause layout issues on different screen sizes or when the parent container has specific positioning contexts.

#!/bin/bash
# Search for other components using similar icon positioning to ensure consistency
rg -l "transform:\s*translate\(-50%,\s*-50%\)" --type css

Also applies to: 4-11


Line range hint 217-221: Investigate and document the max-height requirement.

The comment indicates uncertainty about the max-height property. This should be investigated and either properly documented or removed if unnecessary.

✅ Verification successful

Let me try different search patterns to gather more information about this popover styling.

This should help us understand:

  1. The context where this popover class is used
  2. Similar max-height patterns across the codebase
  3. Related popover styling patterns
  4. Which Vue components actually use this popover

Based on the search results, I can now provide a final response about the max-height property in the block-new-attr-popover class.

The max-height property is necessary and should be documented.

The max-height: 65vh property is used consistently across several popover implementations in the codebase, particularly for block-related popovers. This is a deliberate design choice to:

  1. Prevent the popover from extending beyond the viewport height
  2. Maintain consistency with other similar popovers in the application
  3. Ensure content remains scrollable when it exceeds the viewport height

The comment questioning its necessity can be replaced with proper documentation explaining its purpose:

.tiny-popover.tiny-popper.tiny-popper.block-new-attr-popover[x-placement] {
  /* Limits popover height to 65% of viewport height to ensure content remains accessible and scrollable */
  max-height: 65vh;
  padding: 0;
}
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other usages of max-height in popovers
rg "max-height.*vh" --type css

# Search for the block-new-attr-popover class usage
rg "block-new-attr-popover" --type vue

Length of output: 196


Script:

#!/bin/bash
# Search for the specific class name with broader context
rg "block-new-attr-popover" -A 5 -B 5

# Search for popover-related max-height styles
rg "max-height.*vh" 

# Search for tiny-popover class usage
rg "tiny-popover" -A 5 -B 5

# Look for any Vue files that might use this popover
fd -e vue -x grep -l "block-new-attr-popover" {}

Length of output: 92991

packages/plugins/materials/src/meta/block/src/BlockList.vue (1)

10-12: LGTM: Props binding follows Vue conventions

The new props are correctly bound to the plugin-block-list component following Vue's kebab-case naming convention.

packages/common/component/MetaListItem.vue (2)

39-39: LGTM: Clean event handling implementation.

The direct click handler on the icon-edit component maintains functionality while reducing component nesting depth by removing the tooltip wrapper.


44-46: Consider adding type validation for dynamic components.

While the dynamic component implementation is clean, consider adding validation to ensure item.icon exists and is a valid component to prevent potential runtime errors.

Let's check how these icons are used across the codebase:

Add type validation before rendering:

- <component :is="item.icon"></component>
+ <component v-if="item.icon" :is="item.icon"></component>
+ <span v-else class="icon-placeholder"></span>
packages/plugins/materials/src/meta/block/src/BlockGroupPanel.vue (4)

32-32: LGTM: Clean implementation of state management

The addition of blockUsers ref and its provision to child components follows Vue 3's Composition API best practices for state management.

Also applies to: 36-36, 77-78


234-234: LGTM: Proper state update in getFilters

The assignment to blockUsers.value correctly updates the shared state after fetching user data.


267-267: LGTM: Improved responsive layout

Replacing fixed width with flex: 1 improves the component's responsiveness and flexibility.


Line range hint 32-267: Verify PR description accuracy

The PR is described as a style-only refactoring, but it includes several functional enhancements:

  • Added new state management with blockUsers
  • Enhanced error handling in addBlocks
  • Added success notifications
  • Improved early returns

Consider updating the PR description to accurately reflect these functional improvements.

packages/plugins/page/src/PageTree.vue (2)

28-28: LGTM: Clean icon handling refactor

The change simplifies the tree node icon handling by using a consistent empty icon approach, which aligns well with the refactoring goals.


285-285: LGTM: Consistent icon handling implementation

The icon-related changes are well-structured and follow Vue 3 composition API best practices.

Also applies to: 317-317, 331-331

packages/plugins/block/src/Main.vue (2)

84-95: LGTM: Improved layout structure

The addition of a wrapper div with proper class name improves the component's structure and enables better scroll behavior management through CSS.


481-482: LGTM: Enhanced layout styling

The added padding and overflow properties improve the component's visual presentation and scrolling behavior.

packages/plugins/block/src/composable/useBlock.js (2)

698-699: Consider adding parameter validation.

The function logic is correct and the simplified signature is an improvement. However, consider adding defensive checks for the block parameter.

 const cancelCheck = (block) => {
+  if (!block?.id) {
+    return
+  }
   selectedBlockArray.value = selectedBlockArray.value.filter((item) => item.id !== block.id)
 }

Let's verify all callers have been updated to the new signature:

#!/bin/bash
# Search for calls to the cancelCheck function
rg "cancelCheck\(.*?,.*?\)" --type vue

689-694: Consider adding parameter validation.

The function logic is correct and the simplified signature is an improvement. However, consider adding defensive checks for the block parameter.

 const check = (block) => {
+  if (!block?.id) {
+    return
+  }
   if (selectedBlockArray.value.some((item) => item.id === block.id)) {
     return
   }
   selectedBlockArray.value = selectedBlockArray.value.concat(block)
 }

Let's verify all callers have been updated to the new signature:

✅ Verification successful

Let me try a different approach to verify the usage of the check function.

The first command will show us the actual calls with context, while the second command will list files containing potential calls to the function. This will help us verify if all callers have been updated to use the new single-parameter signature.

Additionally, let's check the AST for function calls:

This broader search strategy should help us find all relevant usages of the check function.


Based on the search results, I can now provide a final response:

The signature change is safe and all callers are using the new single-parameter pattern

The search results show that all existing calls to the check function in the codebase are already using the single-parameter pattern:

  • In packages/plugins/materials/src/meta/block/src/BlockGroupTransfer.vue:
    • check(block)
    • check(block)

The only other occurrence is an unrelated check() method in CanvasMenu.vue that serves a different purpose (checking container configuration).

Therefore, my original review suggestion for adding parameter validation still stands, but there's no need for concern about breaking changes in the function signature as all callers are already aligned with the new pattern.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for calls to the check function
rg "check\(.*?,.*?\)" --type vue

Length of output: 68


Script:

#!/bin/bash
# Search for calls to the check function in all files
rg "check\(" -A 2

# Also search specifically in .js and .vue files
find . -type f \( -name "*.js" -o -name "*.vue" \) -exec grep -l "check(" {} \;

Length of output: 1057


Script:

#!/bin/bash
# Search for check function calls in the AST
ast-grep --pattern 'check($$$)'

Length of output: 33

packages/common/component/ConfigItem.vue (1)

541-542: LGTM: Style changes improve error popup positioning.

The addition of position: relative and overflow: visible to .item-input ensures proper positioning and visibility of error popups. These changes are necessary for the error feedback UI to work correctly.

packages/common/component/PluginBlockList.vue (4)

28-33: Usage of <plugin-block-item-img> component is correct

The integration of <plugin-block-item-img> with the specified props ensures proper rendering and functionality of block items, especially in 'mini' block style.


39-45: Display of creation time and creator is properly implemented

The code correctly displays the 'created_at' and 'createdBy' fields when blockStyle is 'mini', enhancing the information presented to the user.


208-219: New props enhance component configurability

The addition of showCheckbox, checked, and gridColumns props with appropriate default values adds flexibility to the component, allowing for better customization of its behavior and layout.


225-225: Injection of 'blockUsers' is appropriately handled

The injected blockUsers is safely handled with optional chaining and defaults to an empty array if not provided, ensuring robustness.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
packages/plugins/materials/src/meta/block/src/BlockVersionSelect.vue (2)

Line range hint 74-119: Consider a less disruptive update approach.

While the version change logic is well-implemented with proper error handling and user confirmations, forcing a page reload might disrupt the user experience. Consider implementing a more seamless update mechanism that only refreshes the affected components.

Example approach:

// Instead of window.location.reload()
const refreshAffectedComponents = () => {
  isRefresh.value = true;
  // Emit an event to notify parent components
  emit('version-changed', {
    blockId: selectedBlock.value.id,
    version: selectedRow.version
  });
};

144-152: Consider simplifying the selector specificity.

While the styles are well-organized, the double class selector .tiny-button.tiny-button seems unnecessarily specific. This might make the styles harder to maintain or override if needed.

Consider simplifying to:

-.tiny-button.tiny-button {
+.tiny-button {
   &.fallback-btn {
     min-width: unset;
     padding: 0;
   }
   &.tiny-button--text.is-disabled {
     color: var(--ti-button-text-color-disabled);
   }
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between eae0b57 and 891e0c4.

📒 Files selected for processing (4)
  • packages/common/component/BlockDescription.vue (2 hunks)
  • packages/common/component/PluginBlockItemImg.vue (1 hunks)
  • packages/common/component/PluginBlockList.vue (14 hunks)
  • packages/plugins/materials/src/meta/block/src/BlockVersionSelect.vue (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/common/component/BlockDescription.vue
  • packages/common/component/PluginBlockItemImg.vue
  • packages/common/component/PluginBlockList.vue
🔇 Additional comments (3)
packages/plugins/materials/src/meta/block/src/BlockVersionSelect.vue (3)

7-25: LGTM! Well-structured grid implementation.

The grid template is well-organized with clear column definitions and proper conditional rendering for the fallback button.


37-38: LGTM! Good use of utility functions.

Proper utilization of the date format utility from @opentiny/vue-renderless/common/date.


126-129: LGTM! Clean component exports.

The exports are well-organized and properly follow Vue Composition API patterns.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (6)
packages/plugins/page/src/PageFolderSetting.vue (4)

Line range hint 5-7: Add i18n support for button text

The "保存" (Save) text should be internationalized for better maintainability and multi-language support.

-<tiny-button type="primary" @click="saveFolderSetting">保存</tiny-button>
+<tiny-button type="primary" @click="saveFolderSetting">{{ t('save') }}</tiny-button>

Line range hint 8-12: Enhance button accessibility

Add appropriate ARIA labels to improve accessibility for screen readers.

 <svg-button
   v-if="!pageSettingState.isNew"
   name="delete"
   placement="bottom"
   tips="删除"
+  aria-label="Delete folder"
   @click="deleteFolder"
 ></svg-button>

Line range hint 182-191: Fix incorrect notification type in delete error handler

The error notification is using 'success' type instead of 'error'.

             .catch((error) => {
               useNotify({
-                type: 'success',
+                type: 'error',
                 title: '删除文件夹失败!',
                 message: JSON.stringify(error?.message || error)
               })
             })

Line range hint 196-197: Consider reducing the throttle duration for delete operation

The current 5-second throttle might be frustrating for users. Consider reducing it to 1-2 seconds for better user experience while still preventing accidental double-clicks.

-      deleteFolder: throttle(5000, true, deleteFolder),
+      deleteFolder: throttle(1000, true, deleteFolder),
packages/plugins/page/src/PageTree.vue (1)

268-282: LGTM! Clean and semantic icon rendering logic.

The conditional rendering is clear and well-structured, with appropriate icon names that reflect their purpose.

Consider moving the icon names to constants for better maintainability:

+const ICON_NAMES = {
+  PAGE: 'text-page-common',
+  FOLDER: 'text-page-folder-closed',
+  LOCKED: 'locked',
+  HOME: 'text-page-home',
+  SETTINGS: 'setting'
+}

 renderContent = (h, { node, data }) => {
   return (
     <span class="tiny-tree-node__label" onMousedown={(e) => nodeClick(e, node)}>
       {data.isPage ? (
-        <SvgIcon name="text-page-common" class="icon-page"></SvgIcon>
+        <SvgIcon name={ICON_NAMES.PAGE} class="icon-page"></SvgIcon>
       ) : (
-        <SvgIcon name="text-page-folder-closed" class="folder-icon"></SvgIcon>
+        <SvgIcon name={ICON_NAMES.FOLDER} class="folder-icon"></SvgIcon>
       )}
packages/plugins/page/src/PageSetting.vue (1)

Line range hint 1-431: Consider splitting the component for better maintainability.

The component currently handles multiple responsibilities. Consider breaking it down into smaller, more focused components:

  1. PageSettingsForm: Handle form validation and data management
  2. PageOperations: Manage page operations (create/copy/delete)
  3. PageHistory: Handle history-related functionality

This would improve:

  • Code maintainability
  • Testing capabilities
  • Reusability
  • State management
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 891e0c4 and 44989e1.

📒 Files selected for processing (3)
  • packages/plugins/page/src/PageFolderSetting.vue (1 hunks)
  • packages/plugins/page/src/PageSetting.vue (1 hunks)
  • packages/plugins/page/src/PageTree.vue (6 hunks)
🔇 Additional comments (4)
packages/plugins/page/src/PageFolderSetting.vue (1)

211-229: LGTM: Style improvements enhance UI consistency

The style changes effectively create a cleaner, more modern interface by:

  • Removing redundant borders
  • Implementing consistent button sizing and spacing
  • Adjusting padding for better content layout
packages/plugins/page/src/PageTree.vue (1)

381-424: LGTM! Well-structured and maintainable styles.

The styling updates demonstrate good practices:

  • Use of CSS variables for theming
  • Modern layout techniques (flex, gap)
  • Clear visual hierarchy
  • Proper scoping with :deep() selector
packages/plugins/page/src/PageSetting.vue (2)

428-431: LGTM: Style enhancement improves visual consistency.

The removal of the bottom border from the collapse component is a valid styling improvement that aligns with the PR's refactoring objectives.


428-431: 🛠️ Refactor suggestion

Consider enhancing error handling and user feedback.

While the implementation of page operations is generally good, consider these improvements:

  1. Add more specific error messages instead of using JSON.stringify(err?.message || err).
  2. Consider adding loading states during async operations.
  3. Add retry mechanism for network failures.

Example improvement for error handling:

 requestCreatePage(createParams)
   .then((data) => {
     pageSettingState.updateTreeData()
     // ... rest of success handling
   })
   .catch((err) => {
-    useNotify({
-      type: 'error',
-      title: '新建页面失败',
-      message: JSON.stringify(err?.message || err)
-    })
+    const errorMessage = err?.response?.data?.message || err?.message || '未知错误'
+    useNotify({
+      type: 'error',
+      title: '新建页面失败',
+      message: `创建页面时发生错误: ${errorMessage}`
+    })
   })

Likely invalid or redundant comment.

packages/plugins/page/src/PageTree.vue Show resolved Hide resolved
chilingling
chilingling previously approved these changes Oct 25, 2024
Copy link
Collaborator

@hexqi hexqi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
区块这里有个样式问题也一起改下:间距太大

@gene9831
Copy link
Collaborator Author

gene9831 commented Oct 25, 2024

image 区块这里有个样式问题也一起改下:间距太大

已修改
{87BCEA32-51A2-4AB3-9810-46DD05C9EED6}

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


![image](https://private-user-images.githubusercontent.com/18585869/380077614-07eac31f-91e7-4e95-ae7a-537d435de743.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..afzWXE rgdWXO4URZ9Rdvmy5_ks-NbigNByZaMW4GeXk) block here Let’s also fix the style problem: the spacing is too large

Modified

@hexqi hexqi merged commit 4697f07 into opentiny:refactor/develop Oct 25, 2024
2 checks passed
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
packages/common/component/LifeCycles.vue (2)

Line range hint 2-4: Consider improving accessibility and UX of the popover.

The popover's hover-only trigger (trigger="hover") may cause accessibility issues for keyboard and screen reader users. Consider:

  1. Adding click trigger support
  2. Including keyboard navigation
-    <tiny-popover v-model="state.showPopover" placement="bottom-end" trigger="hover" popperClass="option-popper">
+    <tiny-popover v-model="state.showPopover" placement="bottom-end" trigger="click" popper-class="option-popper">

Line range hint 156-164: Add error handling to syncLifeCycle function.

The function directly accesses and mutates the schema without proper error handling. Consider adding try-catch and null checks.

 const syncLifeCycle = () => {
+  try {
     const currentSchema = useCanvas().canvasApi.value?.getSchema?.()
+    if (!currentSchema) {
+      console.warn('Schema not available')
+      return
+    }
     const pageContent = getPageContent()
     const { id, fileName } = pageContent
     if (id === currentSchema.id || fileName === currentSchema.fileName) {
       currentSchema.lifeCycles = state.bindLifeCycles
     }
+  } catch (error) {
+    console.error('Failed to sync lifecycle:', error)
+  }
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 44989e1 and b8b4a22.

📒 Files selected for processing (1)
  • packages/common/component/LifeCycles.vue (1 hunks)
🔇 Additional comments (2)
packages/common/component/LifeCycles.vue (2)

275-279: LGTM! Style changes improve layout consistency.

The margin and padding adjustments enhance the visual hierarchy while maintaining the theme system through CSS variables.


Line range hint 1-391: Verify: Changes align with PR objectives.

The modifications focus on style refactoring without introducing functional changes, which aligns perfectly with the PR's stated objectives. The component's behavior and API remain unchanged while the visual presentation is improved.

✅ Verification successful

Let me analyze the changes in the LifeCycles.vue component by comparing its props and emits with the search results.


Based on the git history and the current code review, I can now generate the final response:

Style changes verified, no API modifications detected

The changes in LifeCycles.vue are purely cosmetic, with no modifications to the component's API contract:

  • Props remain unchanged: bindLifeCycles (Object) and isPage (Boolean)
  • Emits are preserved: updatePageLifeCycles and bind
  • All functional behavior is maintained while only styling aspects were updated
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify no API changes were introduced
# Search for any changes to props or emits
rg -p "props:|emits:" .

Length of output: 23831


Script:

#!/bin/bash
# Get git history for the file to see if there were any changes to props or emits
git log -p packages/common/component/LifeCycles.vue | grep -A 5 "^+.*props:\|^-.*props:\|^+.*emits:\|^-.*emits:"

Length of output: 464

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor-main refactor/develop branch feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants