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

feat: create restart modal #5039

Open
wants to merge 3 commits into
base: feature-datasource-feedback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {
computed, reactive, watch,
} from 'vue';

import dayjs from 'dayjs';

import { makeDistinctValueHandler } from '@cloudforet/core-lib/component-util/query-search';
import { getApiQueryWithToolboxOptions } from '@cloudforet/core-lib/component-util/toolbox';
import type { ConsoleFilter } from '@cloudforet/core-lib/query/type';
Expand All @@ -15,6 +17,7 @@ import type { KeyItemSet, ValueHandlerMap } from '@cloudforet/mirinae/types/inpu
import type { ToolboxOptions } from '@cloudforet/mirinae/types/navigation/toolbox/type';

import type { CostJobStatus } from '@/schema/cost-analysis/job/type';
import { store } from '@/store';
import { i18n } from '@/translations';

import { useQueryTags } from '@/common/composables/query-tags';
Expand All @@ -40,6 +43,8 @@ const storeState = reactive({
totalCount: computed<number>(() => dataSourcesPageState.jobListTotalCount),
activeTab: computed<string>(() => dataSourcesPageState.activeTab),
selectedDataSourceItem: computed<DataSourceItem>(() => dataSourcesPageGetters.selectedDataSourceItem),
recentJobItem: computed<CostJobItem>(() => dataSourcesPageGetters.jobList[0]),
timezone: computed<string>(() => store.state.user.timezone),
});
const state = reactive({
loading: false,
Expand Down Expand Up @@ -156,7 +161,11 @@ const handleClickErrorDetail = (jobId: string) => {
};
const handleClickResyncButton = () => {
state.modalVisible = true;
state.modalType = 'RE-SYNC';
const createdDate = dayjs.tz(storeState.recentJobItem.created_at, storeState.timezone);
const now = dayjs().tz(storeState.timezone);
const diffInMinutes = now.diff(createdDate, 'minute');
// NOTE: If a task is restarted within 10 minutes of the last task's start time, the restarted task may be canceled.
state.modalType = (storeState.recentJobItem.status === 'IN_PROGRESS' && diffInMinutes < 10) ? 'RESTART' : 'RE-SYNC';
};
const handleSelectStatus = (selected: string) => {
tableState.selectedStatusFilter = selected;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,22 @@ const state = reactive({
if (props.modalType === 'RE-SYNC') {
return i18n.t('BILLING.COST_MANAGEMENT.DATA_SOURCES.RESYNC_MODAL_TITLE');
}
if (props.modalType === 'RESTART') {
return i18n.t('BILLING.COST_MANAGEMENT.DATA_SOURCES.RESTART_MODAL_TITLE');
}
return i18n.t('BILLING.COST_MANAGEMENT.DATA_SOURCES.ERROR_FOUND_TITLE');
}),
toggleValue: true,
thisMonthRange: computed<string>(() => {
const start = dayjs.utc().startOf('month').format('YYYY-MM-DD');
const end = dayjs.utc().format('YYYY-MM-DD');
const start = dayjs.utc().startOf('month').format('DD MMMM YYYY');
const end = dayjs.utc().format('DD MMMM YYYY');
return `${start} ~ ${end}`;
}),
startDates: [] as string[],
startDateSetting: computed<DateOption>(() => {
const today = dayjs.utc();
const minDate = today.subtract(35, 'month').format('YYYY-MM');
const maxDate = today.format('YYYY-MM');
const minDate = today.subtract(35, 'month').format('MMMM YYYY');
const maxDate = today.format('MMMM YYYY');
return { minDate, maxDate };
}),
modalValidation: computed<boolean>(() => {
Expand Down Expand Up @@ -93,7 +96,7 @@ const handleConfirmButton = async () => {

try {
state.loading = true;
if (props.modalType === 'RE-SYNC') {
if (props.modalType === 'RE-SYNC' || props.modalType === 'RESTART') {
await dataSourcesPageStore.fetchSyncDatasource({
start: state.toggleValue ? undefined : dayjs(state.startDates[0]).format('YYYY-MM'),
data_source_id: storeState.selectedDataSourceItem.data_source_id,
Expand Down Expand Up @@ -121,19 +124,29 @@ const handleConfirmButton = async () => {
backdrop
:loading="state.loading"
:disabled="state.modalValidation"
:theme-color="props.modalType === 'CANCEL' ? 'alert' : 'primary'"
:theme-color="props.modalType === 'CANCEL' || props.modalType === 'RESTART' ? 'alert' : 'primary'"
:visible.sync="state.proxyVisible"
class="data-source-management-tab-data-collection-history-modal"
@confirm="handleConfirmButton"
>
<template #body>
<div v-if="props.modalType === 'CANCEL'"
<div v-if="props.modalType === 'CANCEL' || props.modalType === 'RESTART'"
class="cancel-content"
>
<p-scoped-notification type="warning"
layout="in-section"
>
<span class="content-inner">{{ $t('BILLING.COST_MANAGEMENT.DATA_SOURCES.CANCEL_MODAL_DESC') }}</span>
<span v-if="props.modalType === 'CANCEL'"
class="content-inner"
>
{{ $t('BILLING.COST_MANAGEMENT.DATA_SOURCES.CANCEL_MODAL_DESC') }}
</span>
<div v-else
class="content-inner"
>
<b class="desc-title">{{ $t('BILLING.COST_MANAGEMENT.DATA_SOURCES.RESTART_MODAL_DESC_1') }}</b>
<p>{{ $t('BILLING.COST_MANAGEMENT.DATA_SOURCES.RESTART_MODAL_DESC_2') }}</p>
</div>
</p-scoped-notification>
</div>
<div v-else-if="props.modalType === 'RE-SYNC'"
Expand Down Expand Up @@ -194,6 +207,10 @@ const handleConfirmButton = async () => {
<template #confirm-button>
<span v-if="props.modalType === 'ERROR'">{{ $t('BILLING.COST_MANAGEMENT.DATA_SOURCES.ERROR_FOUND_OK') }}</span>
<span v-else-if="props.modalType === 'CANCEL'">{{ $t('BILLING.COST_MANAGEMENT.DATA_SOURCES.CANCEL_BUTTON') }}</span>
<span v-else-if="props.modalType === 'RESTART'">{{ $t('BILLING.COST_MANAGEMENT.DATA_SOURCES.RESTART_MODAL_BUTTON') }}</span>
</template>
<template #close-button>
<span v-if="props.modalType === 'RESTART' || props.modalType === 'CANCEL'">{{ $t('BILLING.COST_MANAGEMENT.DATA_SOURCES.KEEP_COLLECTING') }}</span>
</template>
</p-button-modal>
</template>
Expand Down Expand Up @@ -243,6 +260,9 @@ const handleConfirmButton = async () => {
@apply block;
padding-top: 0.25rem;
padding-bottom: 0.375rem;
.desc-title {
@apply text-yellow-700;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ export type CostJobStatusInfo = {

export type CostLinkedAccountModalType = 'RESET'|'UPDATE';

export type DataCollectionHistoryModalType = 'ERROR'|'RE-SYNC'|'CANCEL';
export type DataCollectionHistoryModalType = 'ERROR'|'RE-SYNC'|'CANCEL'|'RESTART';
105 changes: 105 additions & 0 deletions packages/language-pack/console-translation-2.8.babel
Original file line number Diff line number Diff line change
Expand Up @@ -16960,6 +16960,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>KEEP_COLLECTING</name>
<definition_loaded>false</definition_loaded>
<description/>
<comment/>
<default_text/>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>ja-JP</language>
<approved>false</approved>
</translation>
<translation>
<language>ko-KR</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>LINKED</name>
<definition_loaded>false</definition_loaded>
Expand Down Expand Up @@ -17149,6 +17170,90 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>RESTART_MODAL_BUTTON</name>
<definition_loaded>false</definition_loaded>
<description/>
<comment/>
<default_text/>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>ja-JP</language>
<approved>false</approved>
</translation>
<translation>
<language>ko-KR</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>RESTART_MODAL_DESC_1</name>
<definition_loaded>false</definition_loaded>
<description/>
<comment/>
<default_text/>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>ja-JP</language>
<approved>false</approved>
</translation>
<translation>
<language>ko-KR</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>RESTART_MODAL_DESC_2</name>
<definition_loaded>false</definition_loaded>
<description/>
<comment/>
<default_text/>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>ja-JP</language>
<approved>false</approved>
</translation>
<translation>
<language>ko-KR</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>RESTART_MODAL_TITLE</name>
<definition_loaded>false</definition_loaded>
<description/>
<comment/>
<default_text/>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>ja-JP</language>
<approved>false</approved>
</translation>
<translation>
<language>ko-KR</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>RESTRICTION_DESC</name>
<definition_loaded>false</definition_loaded>
Expand Down
5 changes: 5 additions & 0 deletions packages/language-pack/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@
"FAILURE": "Failure",
"GUIDE": "How to register data sources",
"IN_PROGRESS": "In-Progress",
"KEEP_COLLECTING": "Keep Collecting",
"LINKED": "Linked",
"MANUAL": "Manual",
"MODAL_CONTENT": "By allowing this data type, it will be accessible to all workspaces in user mode.",
Expand All @@ -939,6 +940,10 @@
"RESET": "Reset",
"RESETTING": "Resetting...",
"RESET_MODAL_TITLE": "Are you sure you want to reset workspaces for {count} linked accounts?",
"RESTART_MODAL_BUTTON": "Cancel and Re-start",
"RESTART_MODAL_DESC_1": "Data collection is still in progress.",
"RESTART_MODAL_DESC_2": "Canceling the current data collection job may result in a delay when restarting the process. This action cannot be undone.",
"RESTART_MODAL_TITLE": "Do you want to cancel and re-start it?",
"RESTRICTION_DESC": "Accessible in User Mode by Data Type",
"RESYNC": "Re-Sync",
"RESYNC_MODAL_TITLE": "Set a Re-sync Plan",
Expand Down
5 changes: 5 additions & 0 deletions packages/language-pack/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@
"FAILURE": "失敗",
"GUIDE": "データソース登録方法を調べる",
"IN_PROGRESS": "進行中",
"KEEP_COLLECTING": "",
"LINKED": "リンク済み",
"MANUAL": "",
"MODAL_CONTENT": "このデータタイプを許可すると、ユーザーモードですべてのワークスペースにアクセスできるようになります。",
Expand All @@ -939,6 +940,10 @@
"RESET": "初期化",
"RESETTING": "リセット中...",
"RESET_MODAL_TITLE": "ワークスペースに連携された{count}個のアカウントを初期化しますか?",
"RESTART_MODAL_BUTTON": "",
"RESTART_MODAL_DESC_1": "",
"RESTART_MODAL_DESC_2": "",
"RESTART_MODAL_TITLE": "",
"RESTRICTION_DESC": "データタイプごとにユーザーモードでアクセス可能",
"RESYNC": "再同期",
"RESYNC_MODAL_TITLE": "",
Expand Down
5 changes: 5 additions & 0 deletions packages/language-pack/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@
"FAILURE": "실패",
"GUIDE": "데이터 소스 등록 방법 알아보기",
"IN_PROGRESS": "진행중",
"KEEP_COLLECTING": "",
"LINKED": "연결됨",
"MANUAL": "",
"MODAL_CONTENT": "접근을 허용하면 사용자 모드에서 모든 워크스페이스에 이 데이터 유형이 보이게 됩니다.",
Expand All @@ -939,6 +940,10 @@
"RESET": "초기화",
"RESETTING": "초기화 중...",
"RESET_MODAL_TITLE": "워크스페이스에 연결된 {count}개 계정을 초기화하시겠습니까?",
"RESTART_MODAL_BUTTON": "",
"RESTART_MODAL_DESC_1": "",
"RESTART_MODAL_DESC_2": "",
"RESTART_MODAL_TITLE": "",
"RESTRICTION_DESC": "데이터 유형별 사용자 모드에서 접근 가능",
"RESYNC": "동기화",
"RESYNC_MODAL_TITLE": "",
Expand Down
Loading