diff --git a/database/factories/NodeFactory.php b/database/factories/NodeFactory.php index 1a8abf397aa..b6496367090 100644 --- a/database/factories/NodeFactory.php +++ b/database/factories/NodeFactory.php @@ -2,27 +2,19 @@ namespace Database\Factories; -use Convoy\Models\Location; use Convoy\Models\Node; use Illuminate\Database\Eloquent\Factories\Factory; class NodeFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string - */ protected $model = Node::class; - /** - * Define the model's default state. - */ public function definition(): array { return [ 'name' => $this->faker->word(), 'cluster' => 'proxmox', + 'verify_tls' => true, 'fqdn' => $this->faker->word(), 'token_id' => $this->faker->word(), 'secret' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password diff --git a/resources/scripts/components/admin/nodes/CreateNodeModal.tsx b/resources/scripts/components/admin/nodes/CreateNodeModal.tsx index 2421e3aaa1c..fe37b417264 100644 --- a/resources/scripts/components/admin/nodes/CreateNodeModal.tsx +++ b/resources/scripts/components/admin/nodes/CreateNodeModal.tsx @@ -11,10 +11,12 @@ import useNodesSWR from '@/api/admin/nodes/useNodesSWR' import FlashMessageRender from '@/components/elements/FlashMessageRenderer' import MessageBox from '@/components/elements/MessageBox' import Modal from '@/components/elements/Modal' +import CheckboxForm from '@/components/elements/forms/CheckboxForm' import TextInputForm from '@/components/elements/forms/TextInputForm' import LocationsSelectForm from '@/components/admin/nodes/LocationsSelectForm' + interface Props { open: boolean onClose: () => void @@ -29,21 +31,22 @@ const CreateNodeModal = ({ open, onClose }: Props) => { const { t } = useTranslation('admin.nodes.index') const schema = z.object({ - name: z.string().max(191).nonempty(), + name: z.string().min(1).max(191), locationId: z.preprocess(Number, z.number()), - cluster: z.string().max(191).nonempty(), - tokenId: z.string().max(191).nonempty(), - secret: z.string().max(191).nonempty(), - fqdn: hostname().max(191).nonempty(), + cluster: z.string().min(1).max(191), + verifyTls: z.boolean(), + tokenId: z.string().min(1).max(191), + secret: z.string().min(1).max(191), + fqdn: hostname().min(1).max(191), port: z.preprocess(Number, z.number().int().min(1).max(65535)), memory: z.preprocess(Number, z.number().int().min(0)), memoryOverallocate: z.preprocess(Number, z.number().int().min(0)), disk: z.preprocess(Number, z.number().int().min(0)), diskOverallocate: z.preprocess(Number, z.number().int().min(0)), - vmStorage: z.string().max(191).nonempty(), - backupStorage: z.string().max(191).nonempty(), - isoStorage: z.string().max(191).nonempty(), - network: z.string().max(191).nonempty(), + vmStorage: z.string().min(1).max(191), + backupStorage: z.string().min(1).max(191), + isoStorage: z.string().min(1).max(191), + network: z.string().min(1).max(191), }) const form = useForm({ @@ -52,6 +55,7 @@ const CreateNodeModal = ({ open, onClose }: Props) => { name: '', locationId: '0', cluster: '', + verifyTls: true, tokenId: '', secret: '', fqdn: '', @@ -132,6 +136,11 @@ const CreateNodeModal = ({ open, onClose }: Props) => { +
{ const { t: tIndex } = useTranslation('admin.nodes.index') const schema = z.object({ - name: z.string().max(191).nonempty(), + name: z.string().min(1).max(191), locationId: z.preprocess(Number, z.number()), - cluster: z.string().max(191).nonempty(), + cluster: z.string().min(1).max(191), + verifyTls: z.boolean(), tokenId: z.string().max(191), secret: z.string().max(191), - fqdn: hostname().max(191).nonempty(), + fqdn: hostname().min(1).max(191), port: z.preprocess(Number, z.number().int().min(1).max(65535)), memory: z.preprocess(Number, z.number().int().min(0)), memoryOverallocate: z.preprocess(Number, z.number().int().min(0)), disk: z.preprocess(Number, z.number().int().min(0)), diskOverallocate: z.preprocess(Number, z.number().int().min(0)), - vmStorage: z.string().max(191).nonempty(), - backupStorage: z.string().max(191).nonempty(), - isoStorage: z.string().max(191).nonempty(), - network: z.string().max(191).nonempty(), + vmStorage: z.string().min(1).max(191), + backupStorage: z.string().min(1).max(191), + isoStorage: z.string().min(1).max(191), + network: z.string().min(1).max(191), }) const form = useForm({ @@ -49,6 +51,7 @@ const NodeInformationCard = () => { name: node.name, locationId: node.locationId.toString(), cluster: node.cluster, + verifyTls: node.verifyTls, tokenId: '', secret: '', fqdn: node.fqdn, @@ -80,6 +83,7 @@ const NodeInformationCard = () => { name: data.name, locationId: data.locationId.toString(), cluster: data.cluster, + verifyTls: data.verifyTls, tokenId: '', secret: '', fqdn: data.fqdn, @@ -121,6 +125,11 @@ const NodeInformationCard = () => { name='fqdn' label={tStrings('fqdn')} /> + { ) } -export default NodeInformationCard \ No newline at end of file +export default NodeInformationCard