Skip to content

Commit

Permalink
fix: fix additional rule form ui & add translation
Browse files Browse the repository at this point in the history
Signed-off-by: sulmo <[email protected]>
  • Loading branch information
sulmoJ committed Oct 4, 2024
1 parent ed19fe7 commit f90495e
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ACTION_ICON } from '@cloudforet/mirinae/src/inputs/link/type';
import { isNotEmpty } from '@cloudforet/utils';
import {
COLLECTOR_RULE_CONDITION_KEY,
COLLECTOR_RULE_CONDITION_KEY_LABEL,
COLLECTOR_RULE_CONDITION_OPERATOR_LABEL,
} from '@/schema/inventory/collector-rule/constant';
Expand Down Expand Up @@ -69,6 +70,15 @@ const state = reactive({
ALL: _i18n.t('PROJECT.EVENT_RULE.ALL'),
ALWAYS: _i18n.t('PROJECT.EVENT_RULE.ALWAYS'),
})),
isConditionTooltipVisible: computed(() => {
let isConditionTooltipVisible = false;
state.conditionFields.forEach((condition) => {
if (condition.name.slice(0, 4) === COLLECTOR_RULE_CONDITION_KEY.data || condition.name.slice(0, 4) === COLLECTOR_RULE_CONDITION_KEY.tags) {
isConditionTooltipVisible = true;
}
});
return isConditionTooltipVisible;
}),
});
</script>
Expand All @@ -82,7 +92,8 @@ const state = reactive({
<h5 v-if="state.conditionFields.length"
class="text-paragraph-lg text-gray-900 font-bold"
>
<span>{{ $t('INVENTORY.COLLECTOR.CONDITIONS') }}<p-tooltip class="ml-2"
<span>{{ $t('INVENTORY.COLLECTOR.CONDITIONS') }}<p-tooltip v-if="state.isConditionTooltipVisible"
class="ml-2"
position="bottom"
:contents="$t('INVENTORY.COLLECTOR.ADDITIONAL_RULE_CONDITION_INFO')"
><p-i width="1rem"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { debounce } from 'lodash';
import { SpaceConnector } from '@cloudforet/core-lib/space-connector';
import {
PButton, PRadio, PSelectDropdown, PI, PTextInput, PToggleButton, PFieldGroup, PCheckbox, PFieldTitle,
PButton, PRadio, PSelectDropdown, PI, PTextInput, PToggleButton, PFieldGroup, PCheckbox, PFieldTitle, PTooltip,
} from '@cloudforet/mirinae';
import type { SelectDropdownMenuItem } from '@cloudforet/mirinae/types/inputs/dropdown/select-dropdown/type';
Expand Down Expand Up @@ -133,12 +133,21 @@ const state = reactive({
cloudServiceTypeMenu: [] as (SelectDropdownMenuItem[])[],
regionMenu: [] as (SelectDropdownMenuItem[])[],
// actions
actionPolicies: computed<Partial<Record<ActionPolicy, TranslateResult>>>(() => ((state.conditionState) ? ({
match_project: i18n.t('INVENTORY.COLLECTOR.COLLECTOR_RULE.MATCH_PROJECT'),
match_service_account: i18n.t('INVENTORY.COLLECTOR.COLLECTOR_RULE.MATCH_SERVICE_ACCOUNT'),
}) : ({
change_project: i18n.t('INVENTORY.COLLECTOR.COLLECTOR_RULE.SELECT_PROJECT'),
}))),
actionPolicies: computed<Partial<Record<ActionPolicy, TranslateResult>>>(() => {
if (!state.isAdminMode) {
return ({
change_project: i18n.t('INVENTORY.COLLECTOR.COLLECTOR_RULE.SELECT_PROJECT'),
match_project: i18n.t('INVENTORY.COLLECTOR.COLLECTOR_RULE.MATCH_PROJECT'),
match_service_account: i18n.t('INVENTORY.COLLECTOR.COLLECTOR_RULE.MATCH_SERVICE_ACCOUNT'),
});
}
return ((state.conditionState) ? ({
match_project: i18n.t('INVENTORY.COLLECTOR.COLLECTOR_RULE.MATCH_PROJECT'),
match_service_account: i18n.t('INVENTORY.COLLECTOR.COLLECTOR_RULE.MATCH_SERVICE_ACCOUNT'),
}) : ({
change_project: i18n.t('INVENTORY.COLLECTOR.COLLECTOR_RULE.SELECT_PROJECT'),
}));
}),
selectedActionRadioIdx: 'change_project' as ActionPolicy,
selectedProjectId: props.data?.actions?.change_project ? [props.data?.actions?.change_project ?? ''] : undefined,
selectedWorkspaceId: [] as SelectDropdownMenuItem[],
Expand Down Expand Up @@ -386,7 +395,9 @@ const DEFAULT_SEARCH_MAP:Record<CollectorRuleConditionKey, SelectDropdownMenuIte
};
watch(() => state.conditionState, (value) => {
state.selectedActionRadioIdx = value ? 'match_project' : 'change_project';
if (state.isAdminMode) {
state.selectedActionRadioIdx = value ? 'match_project' : 'change_project';
}
});
(async () => {
Expand Down Expand Up @@ -433,7 +444,20 @@ onMounted(() => {
>
<p-field-title :label="$t('INVENTORY.COLLECTOR.COLLECTOR_RULE.CONDITION_SATISFIES')"
class="mb-2"
/>
>
<template #right>
<p-tooltip v-if="state.isConditionTooltipVisible"
class="ml-2"
position="bottom"
:contents="$t('INVENTORY.COLLECTOR.ADDITIONAL_RULE_CONDITION_INFO')"
>
<p-i width="1rem"
height="1rem"
name="ic_info-circle"
/>
</p-tooltip>
</template>
</p-field-title>
<div class="condition-policy-wrapper">
<p-radio v-for="([key,value], idx) in Object.entries(state.conditionPolicies)"
:key="`bookmark-scope-${idx}`"
Expand Down Expand Up @@ -558,7 +582,7 @@ onMounted(() => {
<project-select-dropdown :key="state.selectedWorkspaceId[0]?.name"
class="action-project"
is-fixed-width
:disabled="!state.selectedWorkspaceId[0]?.name"
:disabled="state.isAdminMode ? !state.selectedWorkspaceId[0]?.name : false"
:selected-project-ids="state.selectedProjectId"
:project-group-selectable="false"
:workspace-id="state.selectedWorkspaceId[0]?.name"
Expand Down
30 changes: 15 additions & 15 deletions packages/language-pack/console-translation-2.8.babel
Original file line number Diff line number Diff line change
Expand Up @@ -59524,15 +59524,15 @@
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
<approved>true</approved>
</translation>
<translation>
<language>ja-JP</language>
<approved>false</approved>
<approved>true</approved>
</translation>
<translation>
<language>ko-KR</language>
<approved>false</approved>
<approved>true</approved>
</translation>
</translations>
</concept_node>
Expand Down Expand Up @@ -59713,15 +59713,15 @@
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
<approved>true</approved>
</translation>
<translation>
<language>ja-JP</language>
<approved>false</approved>
<approved>true</approved>
</translation>
<translation>
<language>ko-KR</language>
<approved>false</approved>
<approved>true</approved>
</translation>
</translations>
</concept_node>
Expand Down Expand Up @@ -59755,15 +59755,15 @@
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
<approved>true</approved>
</translation>
<translation>
<language>ja-JP</language>
<approved>false</approved>
<approved>true</approved>
</translation>
<translation>
<language>ko-KR</language>
<approved>false</approved>
<approved>true</approved>
</translation>
</translations>
</concept_node>
Expand All @@ -59776,15 +59776,15 @@
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
<approved>true</approved>
</translation>
<translation>
<language>ja-JP</language>
<approved>false</approved>
<approved>true</approved>
</translation>
<translation>
<language>ko-KR</language>
<approved>false</approved>
<approved>true</approved>
</translation>
</translations>
</concept_node>
Expand All @@ -59797,15 +59797,15 @@
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
<approved>true</approved>
</translation>
<translation>
<language>ja-JP</language>
<approved>false</approved>
<approved>true</approved>
</translation>
<translation>
<language>ko-KR</language>
<approved>false</approved>
<approved>true</approved>
</translation>
</translations>
</concept_node>
Expand Down
10 changes: 5 additions & 5 deletions packages/language-pack/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -3300,7 +3300,7 @@
"ALT_S_UPDATE_SERVICE_ACCOUNTS": "サービスアカウントの更新に成功しました",
"CLOUD_SERVICE_TAG": "クラウドサービスのタグ",
"COLLECTOR_RULE": {
"ALL": "",
"ALL": "以下のすべて",
"ALT_E_CREATE_COLLECTOR_RULE": "コレクタールールの作成に失敗しました",
"ALT_E_DELETE_COLLECTOR_RULE": "コレクタールールの削除に失敗しました",
"ALT_E_REORDER_COLLECTOR_RULES": "コレクタールールの順序変更に失敗しました",
Expand All @@ -3309,11 +3309,11 @@
"ALT_S_DELETE_COLLECTOR_RULE": "コレクタールールが正常に削除されました",
"ALT_S_REORDER_COLLECTOR_RULES": "コレクタールールの順序が正常に変更されました",
"ALT_S_UPDATE_COLLECTOR_RULE": "コレクタールールの更新が完了しました",
"ANY": "",
"ANY": "以下のいずれか一つ",
"CLOUD_SERVICE_SOURCE_KEY": "クラウドサービスのソースキー",
"CONDITION_SATISFIES": "",
"DISABLED_CONDITION": "",
"ENABLED_CONDITION": "",
"CONDITION_SATISFIES": "条件が満たされる場合",
"DISABLED_CONDITION": "むこうじょうたい",
"ENABLED_CONDITION": "ゆうこうじょうたい",
"MATCH_PROJECT": "最初に一致するプロジェクト",
"MATCH_SERVICE_ACCOUNT": "最初に一致するサービスアカウント",
"PROJECT_TAG_KEY": "プロジェクトのタグキー",
Expand Down
10 changes: 5 additions & 5 deletions packages/language-pack/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -3300,7 +3300,7 @@
"ALT_S_UPDATE_SERVICE_ACCOUNTS": "서비스 어카운트 수정 완료",
"CLOUD_SERVICE_TAG": "클라우드 서비스 태그",
"COLLECTOR_RULE": {
"ALL": "",
"ALL": "모든 조건",
"ALT_E_CREATE_COLLECTOR_RULE": "컬렉터 규칙 생성 실패",
"ALT_E_DELETE_COLLECTOR_RULE": "컬렉터 규칙 삭제 실패",
"ALT_E_REORDER_COLLECTOR_RULES": "컬렉터 규칙 순서 변경 실패",
Expand All @@ -3309,11 +3309,11 @@
"ALT_S_DELETE_COLLECTOR_RULE": "컬렉터 규칙 삭제 완료",
"ALT_S_REORDER_COLLECTOR_RULES": "컬렉터 규칙 순서 변경 완료",
"ALT_S_UPDATE_COLLECTOR_RULE": "컬렉터 규칙 수정 완료",
"ANY": "",
"ANY": "조건 중 하나라도",
"CLOUD_SERVICE_SOURCE_KEY": "클라우드 서비스 소스 키",
"CONDITION_SATISFIES": "",
"DISABLED_CONDITION": "",
"ENABLED_CONDITION": "",
"CONDITION_SATISFIES": "설정한 조건을 만족시킬 경우",
"DISABLED_CONDITION": "비활성화",
"ENABLED_CONDITION": "활성화",
"MATCH_PROJECT": "첫 번째 프로젝트 매칭",
"MATCH_SERVICE_ACCOUNT": "첫 번째 서비스 어카운트 매칭",
"PROJECT_TAG_KEY": "프로젝트 태그 키",
Expand Down

0 comments on commit f90495e

Please sign in to comment.