Skip to content

Commit

Permalink
feat: added tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
tikazyq committed Nov 26, 2023
1 parent 6039f96 commit c163e96
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "crawlab-ui",
"version": "0.6.3-1",
"version": "0.6.3-2",
"private": false,
"author": {
"name": "Marvin Zhang",
Expand Down
11 changes: 10 additions & 1 deletion src/components/spider/SpiderForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@
>
<cl-switch
v-model="form.auto_install"
:tooltip="systemInfo.edition === 'global.edition.community' ? t('components.spider.form.autoInstallDisabled') : undefined"
:disabled="systemInfo.edition === 'global.edition.community'"
/>
</cl-form-item>
<!-- ./Row -->
Expand Down Expand Up @@ -190,7 +192,7 @@
</template>

<script lang="ts">
import {defineComponent, ref, watch} from 'vue';
import {computed, defineComponent, ref, watch} from 'vue';
import {useStore} from 'vuex';
import useSpider from '@/components/spider/spider';
import useNode from '@/components/node/node';
Expand All @@ -211,6 +213,12 @@ export default defineComponent({
// store
const store = useStore();
const {
common: commonState
} = store.state as RootStoreState;
const systemInfo = computed<SystemInfo>(() => commonState.systemInfo || {});
// use node
const {
allListSelectOptions: allNodeSelectOptions,
Expand Down Expand Up @@ -271,6 +279,7 @@ export default defineComponent({
...useSpider(store),
// custom
systemInfo,
TASK_MODE_SELECTED_NODES,
TASK_MODE_SELECTED_NODE_TAGS,
allNodeSelectOptions,
Expand Down
33 changes: 19 additions & 14 deletions src/components/switch/Switch.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<template>
<el-switch
v-model="internalValue"
:active-color="activeColor"
:active-icon="activeIconComp"
:active-text="activeText"
:disabled="disabled"
:inactive-color="inactiveColor"
:inactive-icon="inactiveIconComp"
:inactive-text="inactiveText"
:loading="loading"
:width="width"
:inline-prompt="inlinePrompt"
@change="onChange"
/>
<el-tooltip :content="tooltip" :disabled="!tooltip">
<el-switch
v-model="internalValue"
:active-color="activeColor"
:active-icon="activeIconComp"
:active-text="activeText"
:disabled="disabled"
:inactive-color="inactiveColor"
:inactive-icon="inactiveIconComp"
:inactive-text="inactiveText"
:loading="loading"
:width="width"
:inline-prompt="inlinePrompt"
@change="onChange"
/>
</el-tooltip>
</template>

<script lang="ts">
Expand Down Expand Up @@ -64,6 +66,9 @@ export default defineComponent({
type: Boolean,
default: false,
},
tooltip: {
type: String,
},
},
emits: [
'update:model-value',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/lang/en/components/spider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const spider: LComponentsSpider = {
priority: 'Priority',
incrementalSync: 'Incremental Sync',
autoInstall: 'Auto Install',
autoInstallDisabled: 'Auto Install (available in Crawlab Pro)',
},
actions: {
files: {
Expand Down
1 change: 1 addition & 0 deletions src/i18n/lang/zh/components/spider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const spider: LComponentsSpider = {
priority: '优先级',
incrementalSync: '增量同步文件',
autoInstall: '自动安装依赖',
autoInstallDisabled: '自动安装依赖 (仅限 Crawlab Pro)',
},
actions: {
files: {
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/components/switch/Switch.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export declare global {
width?: number;
loading?: boolean;
inlinePrompt?: boolean;
tooltip?: string;
}
}
1 change: 1 addition & 0 deletions src/interfaces/i18n/components/spider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface LComponentsSpider {
priority: string;
incrementalSync: string;
autoInstall: string;
autoInstallDisabled: string;
};
actions: {
files: {
Expand Down

0 comments on commit c163e96

Please sign in to comment.