/** * Copyright (c) 2020-present, Goldman Sachs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { FormButton, FormTextInput } from '@finos/legend-data-cube'; import { observer } from 'mobx-react-lite'; import { useEffect, useState } from 'react'; import { useLegendDataCubeBuilderStore } from './LegendDataCubeBuilderStoreProvider.js'; import { formatDate } from '@finos/legend-shared'; import { useApplicationStore } from '@finos/legend-application'; export const LegendDataCubeDeleteConfirmation = observer(() => { const [text, setText] = useState(''); const store = useLegendDataCubeBuilderStore(); const application = useApplicationStore(); const persistentDataCube = store.dataCubeToDelete; const confirmationText = `${application.identityService.isAnonymous ? '' : application.identityService.currentUser}_${formatDate(Date.now(), 'yyyyMMdd')}`; useEffect(() => { setText(''); }, [persistentDataCube]); if (!persistentDataCube) { return null; } return ( <>
You are about to delete this DataCube. Once deleted, it{' '} cannot be recovered
Please type the following to confirm: {confirmationText}
{text}
{ setText(event.target.value); }} />
store.deleteConfirmationDisplay.close()}> Cancel { store .deleteDataCube() .catch((error) => store.alertService.alertUnhandledError(error)); }} > Delete
); });