-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged PR 2876: 12273 copying default check patterns
- copying default check patterns - disabled button if length of tableName is 0
- Loading branch information
Showing
2 changed files
with
96 additions
and
6 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
...s/src/main/frontend/src/pages/DefaultCheckPatternConfiguration/CopyCheckPatternDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { Dialog, DialogBody, DialogFooter } from '@material-tailwind/react'; | ||
import React, { useState } from 'react'; | ||
import Button from '../../components/Button'; | ||
import Input from '../../components/Input'; | ||
import { | ||
DefaultColumnCheckPatternsApiClient, | ||
DefaultTableCheckPatternsApiClient | ||
} from '../../services/apiClient'; | ||
interface CopyCheckPatternDialogProps { | ||
type: 'column' | 'table'; | ||
sourceTableName: string; | ||
open: boolean; | ||
setOpen: (v: boolean) => void; | ||
} | ||
|
||
export default function CopyCheckPatternDialog({ | ||
type, | ||
sourceTableName, | ||
open, | ||
setOpen | ||
}: CopyCheckPatternDialogProps) { | ||
const [tableName, setTableName] = useState(''); | ||
const handleSubmit = () => { | ||
if (type === 'column') { | ||
DefaultColumnCheckPatternsApiClient.copyFromDefaultColumnChecksPattern( | ||
tableName, | ||
sourceTableName | ||
); | ||
} | ||
if (type === 'table') { | ||
DefaultTableCheckPatternsApiClient.copyFromDefaultTableChecksPattern( | ||
tableName, | ||
sourceTableName | ||
); | ||
} | ||
setOpen(false); | ||
}; | ||
const onClose = () => { | ||
setOpen(false); | ||
}; | ||
|
||
return ( | ||
<Dialog open={open} handler={onClose}> | ||
<DialogBody className="pt-4 pb-2 px-8"> | ||
<div className="text-2xl text-gray-700 text-center whitespace-normal flex pb-4 items-center justify-center"> | ||
Copy {sourceTableName} to new {type} pattern | ||
</div> | ||
<Input | ||
label={`${type === 'column' ? 'Column' : 'Table'} pattern name`} | ||
placeholder={`Copy of ${sourceTableName}`} | ||
className="w-full" | ||
value={tableName} | ||
onChange={(e) => setTableName(e.target.value)} | ||
/> | ||
</DialogBody> | ||
<DialogFooter className="justify-center space-x-6 pb-8"> | ||
<Button | ||
color="primary" | ||
variant="outlined" | ||
className="px-8" | ||
onClick={onClose} | ||
label="Cancel" | ||
/> | ||
<Button | ||
color="primary" | ||
className="px-8" | ||
onClick={handleSubmit} | ||
label="Save" | ||
disabled={tableName.length === 0} | ||
/> | ||
</DialogFooter> | ||
</Dialog> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters