Skip to content
Merged
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 @@ -126,6 +126,7 @@ export default function AIModelDetailsPage() {
const [isTagsListUpdated, setIsTagsListUpdated] = useState(false);
const SAVE_SUCCESS_TOAST_ID = 'ai-model-details-save-success';
const SAVE_ERROR_TOAST_ID = 'ai-model-details-save-error';
const AI_MODEL_VALIDATION_TOAST_ID = 'ai-model-details-validation-toast';
const isValidHttpUrl = (value: string) => {
try {
const parsed = new URL(value);
Expand Down Expand Up @@ -304,7 +305,9 @@ export default function AIModelDetailsPage() {
}

if (!isValidHttpUrl(trimmedWebsite)) {
toast('Please enter a valid URL that includes https.');
toast('Please enter a valid URL that includes https.', {
id: AI_MODEL_VALIDATION_TOAST_ID,
});
return;
}

Expand All @@ -321,7 +324,7 @@ export default function AIModelDetailsPage() {

// Ensure access type is always 'open' (required field)
if (dataToUse.accessType !== 'open') {
toast('Open access is required for all models');
toast('Open access is required for all models',{id: OPEN_ACCESS_REQUIRED_TOAST_ID});
setStatus('unsaved');
return;
}
Expand Down Expand Up @@ -431,7 +434,7 @@ export default function AIModelDetailsPage() {
</div>
);
}

const OPEN_ACCESS_REQUIRED_TOAST_ID = SAVE_SUCCESS_TOAST_ID;
return (
<div className="flex flex-col gap-4 py-6">
{/* Model Type & Domain - side by side */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ export default function VersionsPage() {
framework: '',
});

const VERSIONS_ACTION_TOAST_ID = 'aimodel-versions-action-toast';
const VERSIONS_VALIDATION_TOAST_ID = 'aimodel-versions-validation-toast';
// Fetch model versions - override default refetchOnMount: false
const { data, isLoading, refetch } = useQuery(
[`fetch_model_versions_${params.id}`],
Expand Down Expand Up @@ -225,7 +227,7 @@ export default function VersionsPage() {
),
{
onSuccess: async (response: any) => {
toast('New version created successfully!');
toast('New version created successfully!',{id: VERSIONS_ACTION_TOAST_ID});
setIsNewVersionModalOpen(false);
resetVersionForm();
queryClient.invalidateQueries([`fetch_AIModelForPublish_${params.id}`]);
Expand All @@ -246,7 +248,7 @@ export default function VersionsPage() {
}
},
onError: (error: any) => {
toast(`Error: ${error.message}`);
toast(`Error: ${error.message}`,{id: VERSIONS_ACTION_TOAST_ID});
},
}
);
Expand All @@ -261,7 +263,7 @@ export default function VersionsPage() {
),
{
onSuccess: async () => {
toast('Provider added successfully!');
toast('Provider added successfully!',{id: VERSIONS_ACTION_TOAST_ID});
setIsProviderModalOpen(false);
resetProviderForm();
queryClient.invalidateQueries([
Expand All @@ -282,7 +284,7 @@ export default function VersionsPage() {
}
},
onError: (error: any) => {
toast(`Error: ${error.message}`);
toast(`Error: ${error.message}`,{id: VERSIONS_ACTION_TOAST_ID});
},
}
);
Expand All @@ -296,7 +298,7 @@ export default function VersionsPage() {
),
{
onSuccess: async () => {
toast('Provider updated successfully!');
toast('Provider updated successfully!',{id: VERSIONS_ACTION_TOAST_ID});
setIsProviderModalOpen(false);
setEditingProvider(null);
resetProviderForm();
Expand All @@ -318,7 +320,7 @@ export default function VersionsPage() {
}
},
onError: (error: any) => {
toast(`Error: ${error.message}`);
toast(`Error: ${error.message}`,{id: VERSIONS_ACTION_TOAST_ID});
},
}
);
Expand All @@ -332,7 +334,7 @@ export default function VersionsPage() {
),
{
onSuccess: async () => {
toast('Provider deleted successfully!');
toast('Provider deleted successfully!',{id: VERSIONS_ACTION_TOAST_ID});
queryClient.invalidateQueries([`fetch_AIModelForPublish_${params.id}`]);

// Force refetch and update selected version after provider deletion
Expand All @@ -349,7 +351,7 @@ export default function VersionsPage() {
}
},
onError: (error: any) => {
toast(`Error: ${error.message}`);
toast(`Error: ${error.message}`,{id: VERSIONS_ACTION_TOAST_ID});
},
}
);
Expand Down Expand Up @@ -415,11 +417,11 @@ export default function VersionsPage() {

const handleSaveNewVersion = () => {
if (!newVersionData.version) {
toast('Please enter a version number');
toast('Please enter a version number', { id: VERSIONS_VALIDATION_TOAST_ID });
return;
}
if (!newVersionData.lifecycleStage) {
toast('Please select a lifecycle stage');
toast('Please select a lifecycle stage', { id: VERSIONS_VALIDATION_TOAST_ID });
return;
}

Expand Down Expand Up @@ -486,20 +488,25 @@ export default function VersionsPage() {
);

if (isEndpointRequired && !providerFormData.apiEndpointUrl?.trim()) {
toast('Endpoint URL is required for the selected provider.');
toast('Endpoint URL is required for the selected provider.', {
id: VERSIONS_VALIDATION_TOAST_ID,
});
return;
}

if (providerFormData.apiEndpointUrl?.trim()) {
try {
const url = new URL(providerFormData.apiEndpointUrl);
if (!['http:', 'https:'].includes(url.protocol)) {
toast('Endpoint URL must use HTTP or HTTPS protocol.');
toast('Endpoint URL must use HTTP or HTTPS protocol.', {
id: VERSIONS_VALIDATION_TOAST_ID,
});
return;
}
} catch {
toast(
'Please enter a valid endpoint URL (e.g., https://api.example.com/v1/chat)'
,{ id: VERSIONS_VALIDATION_TOAST_ID }
);
return;
}
Expand All @@ -511,6 +518,7 @@ export default function VersionsPage() {
} catch {
toast(
'Invalid JSON in Request Body Template. Please check the format.'
,{ id: VERSIONS_VALIDATION_TOAST_ID }
);
return;
}
Expand Down Expand Up @@ -607,12 +615,12 @@ export default function VersionsPage() {
),
{
onSuccess: () => {
toast('Version updated successfully!');
toast('Version updated successfully!',{id: VERSIONS_ACTION_TOAST_ID});
refetch();
queryClient.invalidateQueries([`fetch_AIModelForPublish_${params.id}`]);
},
onError: (error: any) => {
toast(`Error: ${error.message}`);
toast(`Error: ${error.message}`,{id: VERSIONS_ACTION_TOAST_ID});
},
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ const TabsAndChildren = ({ children }: { children: React.ReactNode }) => {
refetchOnReconnect: true,
}
);
const AIMODEL_TITLE_SUCCESS_TOAST_ID = 'aimodel-title-save-success';
const AIMODEL_TITLE_ERROR_TOAST_ID = 'aimodel-title-save-error';

const { mutate, isLoading: editMutationLoading } = useMutation(
(data: { displayName: string }) =>
Expand All @@ -90,11 +92,11 @@ const TabsAndChildren = ({ children }: { children: React.ReactNode }) => {
),
{
onSuccess: () => {
toast('AI Model updated successfully');
toast('AI Model updated successfully',{id: AIMODEL_TITLE_SUCCESS_TOAST_ID});
AIModelData.refetch();
},
onError: (error: any) => {
toast(`Error: ${error.message}`);
toast(`Error: ${error.message}`,{id: AIMODEL_TITLE_ERROR_TOAST_ID});
},
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ const createAIModel: any = graphql(`
}
`);

const AIMODELS_ACTION_TOAST_ID = 'aimodels-list-action-toast';

export default function AIModelsPage({
params,
}: {
Expand Down Expand Up @@ -128,11 +130,11 @@ export default function AIModelsPage({
),
{
onSuccess: () => {
toast(`Deleted AI Model successfully`);
toast(`Deleted AI Model successfully`,{id: AIMODELS_ACTION_TOAST_ID});
AllAIModels.refetch();
},
onError: (err: any) => {
toast('Error: ' + err.message.split(':')[0]);
toast('Error: ' + err.message.split(':')[0],{id: AIMODELS_ACTION_TOAST_ID});
},
}
);
Expand Down Expand Up @@ -161,13 +163,13 @@ export default function AIModelsPage({
{
onSuccess: (data: any) => {
const newModelId = data.createAiModel.data.id;
toast(`Created AI Model successfully`);
toast(`Created AI Model successfully`,{id: AIMODELS_ACTION_TOAST_ID});
router.push(
`/dashboard/${entityType}/${entitySlug}/aimodels/edit/${newModelId}/details`
);
},
onError: (err: any) => {
toast('Error: ' + err.message.split(':')[0]);
toast('Error: ' + err.message.split(':')[0],{id: AIMODELS_ACTION_TOAST_ID});
},
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const Assign = () => {
id: string;
}>();
const router = useRouter();
const COLLAB_ASSIGN_TOAST_ID = 'collaboratives-assign-toast';

const [data, setData] = useState<any[]>([]); // Ensure `data` is an array
const [selectedRow, setSelectedRows] = useState<any[]>([]);
Expand Down Expand Up @@ -126,14 +127,14 @@ const Assign = () => {
),
{
onSuccess: () => {
toast('Dataset Assigned Successfully');
toast('Dataset Assigned Successfully', { id: COLLAB_ASSIGN_TOAST_ID });
CollaborativeDetails.refetch();
router.push(
`/dashboard/${params.entityType}/${params.entitySlug}/collaboratives/edit/${params.id}/usecases`
);
},
onError: (err: any) => {
toast(`Received ${err} on dataset publish `);
toast(`Received ${err} on dataset publish `, { id: COLLAB_ASSIGN_TOAST_ID });
},
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const Details = () => {
partners: [] as { label: string; value: string }[],
});

const COLLAB_CONTRIBUTORS_TOAST_ID = 'collaboratives-contributors-toast';

const Users: { data: any; isLoading: boolean; refetch: any } = useQuery(
[`fetch_users`],
() =>
Expand Down Expand Up @@ -111,11 +113,11 @@ const Details = () => {
}, input),
{
onSuccess: () => {
toast('Contributor added successfully');
toast('Contributor added successfully', { id: COLLAB_CONTRIBUTORS_TOAST_ID });
CollaborativeData.refetch();
},
onError: (error: any) => {
toast(`Error: ${error.message}`);
toast(`Error: ${error.message}`, { id: COLLAB_CONTRIBUTORS_TOAST_ID });
},
}
);
Expand All @@ -128,11 +130,11 @@ const Details = () => {
}, input),
{
onSuccess: () => {
toast('Contributor removed successfully');
toast('Contributor removed successfully', { id: COLLAB_CONTRIBUTORS_TOAST_ID });
CollaborativeData.refetch();
},
onError: (error: any) => {
toast(`Error: ${error.message}`);
toast(`Error: ${error.message}`, { id: COLLAB_CONTRIBUTORS_TOAST_ID });
},
}
);
Expand All @@ -144,11 +146,11 @@ const Details = () => {
}, input),
{
onSuccess: () => {
toast('Supporter added successfully');
toast('Supporter added successfully', { id: COLLAB_CONTRIBUTORS_TOAST_ID });
CollaborativeData.refetch();
},
onError: (error: any) => {
toast(`Error: ${error.message}`);
toast(`Error: ${error.message}`, { id: COLLAB_CONTRIBUTORS_TOAST_ID });
},
}
);
Expand All @@ -161,11 +163,11 @@ const Details = () => {
}, input),
{
onSuccess: () => {
toast('Supporter removed successfully');
toast('Supporter removed successfully', { id: COLLAB_CONTRIBUTORS_TOAST_ID });
CollaborativeData.refetch();
},
onError: (error: any) => {
toast(`Error: ${error.message}`);
toast(`Error: ${error.message}`, { id: COLLAB_CONTRIBUTORS_TOAST_ID });
},
}
);
Expand All @@ -177,11 +179,11 @@ const Details = () => {
}, input),
{
onSuccess: () => {
toast('Partner added successfully');
toast('Partner added successfully', { id: COLLAB_CONTRIBUTORS_TOAST_ID });
CollaborativeData.refetch();
},
onError: (error: any) => {
toast(`Error: ${error.message}`);
toast(`Error: ${error.message}`, { id: COLLAB_CONTRIBUTORS_TOAST_ID });
},
}
);
Expand All @@ -194,11 +196,11 @@ const Details = () => {
}, input),
{
onSuccess: () => {
toast('Partner removed successfully');
toast('Partner removed successfully', { id: COLLAB_CONTRIBUTORS_TOAST_ID });
CollaborativeData.refetch();
},
onError: (error: any) => {
toast(`Error: ${error.message}`);
toast(`Error: ${error.message}`, { id: COLLAB_CONTRIBUTORS_TOAST_ID });
},
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const Details = () => {
}>();

const router = useRouter();
const COLLAB_DETAILS_TOAST_ID = 'collaboratives-details-toast';

const CollaborativeData: { data: any; isLoading: boolean; refetch: any } = useQuery(
[`fetch_CollaborativeData_details`],
Expand Down Expand Up @@ -145,7 +146,7 @@ const Details = () => {
),
{
onSuccess: (res: any) => {
toast('Collaborative updated successfully');
toast('Collaborative updated successfully', { id: COLLAB_DETAILS_TOAST_ID });
setFormData((prev) => ({
...prev,
...res.updateCollaborative,
Expand All @@ -156,7 +157,7 @@ const Details = () => {
}));
},
onError: (error: any) => {
toast(`Error: ${error.message}`);
toast(`Error: ${error.message}`, { id: COLLAB_DETAILS_TOAST_ID });
},
}
);
Expand Down
Loading
Loading