Skip to content

Commit

Permalink
remove .done() everywhere!
Browse files Browse the repository at this point in the history
  • Loading branch information
JafarMirzaie committed Aug 5, 2022
1 parent 9d09036 commit e727d00
Show file tree
Hide file tree
Showing 165 changed files with 408 additions and 586 deletions.
14 changes: 5 additions & 9 deletions Signum.React.Extensions/Alerts/AlertDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ function AlertDropdownImp(props: { keepRingingFor: number }) {
AlertsClient.API.myAlerts()
.then(als => {
setAlerts(als);
})
.done();
});
}

} else {
Expand Down Expand Up @@ -89,8 +88,7 @@ function AlertDropdownImp(props: { keepRingingFor: number }) {

if (!isOpen) {
AlertsClient.API.myAlerts()
.then(alerts => setAlerts(alerts))
.done();
.then(alerts => setAlerts(alerts));
}

setIsOpen(!isOpen);
Expand All @@ -116,7 +114,7 @@ function AlertDropdownImp(props: { keepRingingFor: number }) {

const errors = Dic.getValues(res.errors).filter(a => Boolean(a));
if (errors.length) {
MessageModal.showError(<ul>{errors.map((a, i) => <li key={i}>{a}</li>)}</ul>, "Errors attending alerts").done();
MessageModal.showError(<ul>{errors.map((a, i) => <li key={i}>{a}</li>)}</ul>, "Errors attending alerts");
}

// Pesimistic
Expand All @@ -126,13 +124,11 @@ function AlertDropdownImp(props: { keepRingingFor: number }) {
setIsOpen(true);

setAlerts(alerts);
})
.done();
});

reloadCount();

})
.done();
});
}

var alertsGroups = alerts == null ? null :
Expand Down
6 changes: 2 additions & 4 deletions Signum.React.Extensions/Alerts/useSignalR.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ export function useSignalRConnection(url: string, options?: signalR.IHttpConnect

forceUpdate();

promise.done();

return () => {
promise
.then(() => {
Expand Down Expand Up @@ -90,15 +88,15 @@ export function useSignalRGroup(connection: signalR.HubConnection | undefined, o

if (connection) {
if (connection.state == signalR.HubConnectionState.Connected) {
options.enterGroup(connection).done();
options.enterGroup(connection);

return () => {
if (connection.state == signalR.HubConnectionState.Connected) {
options.exitGroup(connection).catch(e => {
if (connection.state == signalR.HubConnectionState.Connected)
throw e;
else { /* Silent exception */ }
}).done();
});
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ export function start(options: { routes: JSX.Element[] }) {

return promise.then(str => !str ? null : importADUser(str))
.then(u => u && Navigator.view(u))
.then(u => u && ctx.searchControl.handleCreated(u))
.done();
.then(u => u && ctx.searchControl.handleCreated(u));

}}>
<FontAwesomeIcon icon="user-plus" /> {!search ? UserADMessage.FindInActiveDirectory.niceToString() : UserADMessage.Find0InActiveDirectory.niceToString().formatHtml(search == null ? UserEntity.niceName() : <strong>{search}</strong>)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ export default React.forwardRef(function OperationRulePackControl({ ctx }: { ctx
.then(newPack => {
notifySuccess();
bc.frame.onReload({ entity: newPack, canExecute: {} });
})
.done();
});
}

const forceUpdate = useForceUpdate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,14 @@ export default React.forwardRef(function PermissionRulesPackControl(p: { ctx: Ty
.then(newPack => {
notifySuccess();
bc.frame.onReload({ entity: newPack, canExecute: {} });
})
.done();
});
}

function handleResetChangesClick(bc: ButtonsContext) {
let pack = ctx.value;

API.fetchPermissionRulePack(pack.role.id!)
.then(newPack => { bc.frame.onReload({ entity: newPack, canExecute: {} }); })
.done();
.then(newPack => { bc.frame.onReload({ entity: newPack, canExecute: {} }); });
}

function handleSwitchToClick(bc: ButtonsContext) {
Expand All @@ -54,8 +52,7 @@ export default React.forwardRef(function PermissionRulesPackControl(p: { ctx: Ty
return;

API.fetchPermissionRulePack(r.id!)
.then(newPack => bc.frame.onReload({ entity: newPack, canExecute: {} }))
.done();
.then(newPack => bc.frame.onReload({ entity: newPack, canExecute: {} }));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ export default React.forwardRef(function PropertyRulesPackControl({ ctx }: { ctx
.then(newPack => {
notifySuccess();
bc.frame.onReload({ entity: newPack, canExecute: {} });
})
.done();
});
}

function renderButtons(bc: ButtonsContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ export default React.forwardRef(function QueryRulesPackControl({ ctx }: { ctx: T
.then(newPack => {
notifySuccess();
bc.frame.onReload({ entity: newPack, canExecute: {} });
})
.done();
});
}

function renderButtons(bc: ButtonsContext): ButtonBarElement[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ export default React.forwardRef(function TypesRulesPackControl({ ctx }: { ctx: T
.then(newPack => {
notifySuccess();
bc.frame.onReload({ entity: newPack, canExecute: {} });
})
.done();
});
}

function handleResetChangesClick(bc: ButtonsContext) {
Expand All @@ -63,8 +62,7 @@ export default React.forwardRef(function TypesRulesPackControl({ ctx }: { ctx: T
API.fetchTypeRulePack(pack.role.id!)
.then(newPack => {
bc.frame.onReload({ entity: newPack, canExecute: {} });
})
.done();
});
}

function handleSwitchToClick(bc: ButtonsContext) {
Expand All @@ -75,8 +73,7 @@ export default React.forwardRef(function TypesRulesPackControl({ ctx }: { ctx: T
return;

API.fetchTypeRulePack(r.id!)
.then(newPack => bc.frame.onReload({ entity: newPack, canExecute: {} }))
.done();
.then(newPack => bc.frame.onReload({ entity: newPack, canExecute: {} }));
});
}

Expand Down Expand Up @@ -217,8 +214,7 @@ export default React.forwardRef(function TypesRulesPackControl({ ctx }: { ctx: T
})));

updateFrame();
})
.done();
});
}

function handleRemoveConditionClick(taac: TypeAllowedAndConditions, con: TypeConditionRuleModel) {
Expand Down Expand Up @@ -355,7 +351,7 @@ export default React.forwardRef(function TypesRulesPackControl({ ctx }: { ctx: T
buttons: "ok",
style: "warning",
icon: "warning"
}).done();
});
}
else {
action()
Expand All @@ -364,8 +360,7 @@ export default React.forwardRef(function TypesRulesPackControl({ ctx }: { ctx: T
.then(m => {
setNewValue(m);
updateFrame();
})
.done();
});
}
};

Expand Down
7 changes: 3 additions & 4 deletions Signum.React.Extensions/Authorization/AuthAdminClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export function start(options: { routes: JSX.Element[], types: boolean; properti
Navigator.addSettings(new EntitySettings(TypeRulePack, e => import('./Admin/TypeRulePackControl')));

QuickLinks.registerQuickLink(RoleEntity, ctx => new QuickLinks.QuickLinkAction("types", () => AuthAdminMessage.TypeRules.niceToString(),
e => API.fetchTypeRulePack(ctx.lite.id!).then(pack => Navigator.view(pack, { buttons: "close", readOnly: ctx.widgetContext?.ctx.value.isTrivialMerge == true ? true : undefined })).done(),
e => API.fetchTypeRulePack(ctx.lite.id!).then(pack => Navigator.view(pack, { buttons: "close", readOnly: ctx.widgetContext?.ctx.value.isTrivialMerge == true ? true : undefined })),
{ isVisible: isPermissionAuthorized(BasicPermission.AdminRules), icon: "shield-alt", iconColor: "red", color: "danger", group: null }));
}

Expand All @@ -137,7 +137,7 @@ export function start(options: { routes: JSX.Element[], types: boolean; properti
Navigator.addSettings(new EntitySettings(PermissionRulePack, e => import('./Admin/PermissionRulePackControl')));

QuickLinks.registerQuickLink(RoleEntity, ctx => new QuickLinks.QuickLinkAction("permissions", () => AuthAdminMessage.PermissionRules.niceToString(),
e => API.fetchPermissionRulePack(ctx.lite.id!).then(pack => Navigator.view(pack, { buttons: "close", readOnly: ctx.widgetContext?.ctx.value.isTrivialMerge == true ? true : undefined })).done(),
e => API.fetchPermissionRulePack(ctx.lite.id!).then(pack => Navigator.view(pack, { buttons: "close", readOnly: ctx.widgetContext?.ctx.value.isTrivialMerge == true ? true : undefined })),
{ isVisible: isPermissionAuthorized(BasicPermission.AdminRules), icon: "shield-alt", iconColor: "orange", color: "warning", group: null }));
}

Expand Down Expand Up @@ -270,8 +270,7 @@ export module API {

export function downloadAuthRules(): void {
ajaxGetRaw({ url: "~/api/authAdmin/downloadAuthRules" })
.then(response => saveFile(response))
.done();
.then(response => saveFile(response));
}

export function trivialMergeRole(rule: Lite<RoleEntity>[]): Promise<Lite<RoleEntity>> {
Expand Down
5 changes: 2 additions & 3 deletions Signum.React.Extensions/Authorization/AuthClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export function logout() {
API.logout().then(() => {
logoutInternal();
logoutOtherTabs(user);
}).done();
});
}

function logoutInternal() {
Expand Down Expand Up @@ -178,8 +178,7 @@ export function addAuthToken(options: Services.AjaxOptions, makeCall: () => Prom
if (newToken) {
setAuthToken(newToken, getAuthenticationType());
API.fetchCurrentUser()
.then(cu => setCurrentUser(cu))
.done();
.then(cu => setCurrentUser(cu));
}

return r;
Expand Down
5 changes: 2 additions & 3 deletions Signum.React.Extensions/Authorization/AzureAD/AzureAD.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ export function signIn(ctx: LoginContext) {
throw new ExternalServiceError("MSAL", e, e.name + ": " + e.errorCode, e.errorMessage, e.subError + "\n" + e.stack);

throw e;
})
.done();
});
}

export function loginWithAzureAD(): Promise<AuthClient.API.LoginResponse | undefined> {
Expand Down Expand Up @@ -159,7 +158,7 @@ export function signOut() {
if (account) {
msalClient.logout({
account: account
}).done();
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ export default function ChangePasswordPage() {
})
.catch(ifError(ValidationError, e => {
if (e.modelState)
setModelState(e.modelState).done();
}))
.done();
setModelState(e.modelState);
}));

}).done();
});
}

function error(field: string): string | undefined {
Expand All @@ -53,11 +52,11 @@ export default function ChangePasswordPage() {
}

function handleOldPasswordBlur(event: React.SyntheticEvent<any>) {
setModelState({ ...modelState, ...validateOldPassword() }).done();
setModelState({ ...modelState, ...validateOldPassword() });
}

function handleNewPasswordBlur(event: React.SyntheticEvent<any>) {
setModelState({ ...modelState, ...validateNewPassword(event.currentTarget == newPassword2!.current) }).done();
setModelState({ ...modelState, ...validateNewPassword(event.currentTarget == newPassword2!.current) });
}

function validateOldPassword(): ModelState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ export default function ForgotPasswordEmailPage() {
})
.catch((e: ValidationError) => {
if (e.modelState)
setModelState(e.modelState).done();
})
.done();
}).done();
setModelState(e.modelState);
});
});
}

function handleMailBlur(event: React.SyntheticEvent<any>) {
setModelState({ ...modelState, ...validateEmail() }).done();
setModelState({ ...modelState, ...validateEmail() });
}

function validateEmail() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ export default function LoginDropdown(p: {
.then(Navigator =>
Navigator.API.fetchEntityPack(toLite(user))
.then(pack => Navigator.view(pack))
.then(u => u && AuthClient.API.fetchCurrentUser(true).then(nu => AuthClient.setCurrentUser(u))))
.done();
.then(u => u && AuthClient.API.fetchCurrentUser(true).then(nu => AuthClient.setCurrentUser(u))));
}

var extraButtons = p.extraMenuItems && p.extraMenuItems(user);
Expand Down
7 changes: 3 additions & 4 deletions Signum.React.Extensions/Authorization/Login/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ export function LoginForm(p: { ctx: LoginContext }) {
} else {
throw e;
}
})
.done();
});
}

function error(field: string) {
Expand Down Expand Up @@ -173,13 +172,13 @@ export function LoginWithWindowsButton() {
return AuthClient.API.loginWindowsAuthentication(true)
.then(lr => {
if (lr == null) {
MessageModal.showError(LoginAuthMessage.LooksLikeYourWindowsUserIsNotAllowedToUseThisApplication.niceToString(), LoginAuthMessage.NoWindowsUserFound.niceToString()).done();
MessageModal.showError(LoginAuthMessage.LooksLikeYourWindowsUserIsNotAllowedToUseThisApplication.niceToString(), LoginAuthMessage.NoWindowsUserFound.niceToString());
} else {
AuthClient.setAuthToken(lr.token, lr.authenticationType);
AuthClient.setCurrentUser(lr.userEntity);
AuthClient.Options.onLogin();
}
}).done();
});
}

return (
Expand Down
7 changes: 3 additions & 4 deletions Signum.React.Extensions/Authorization/Login/ResetPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ export default function ResetPassword(p: RouteComponentProps<{}>) {
})
.catch((e: ValidationError) => {
if (e.modelState)
setModelState(e.modelState).done();
})
.done();
setModelState(e.modelState);
});
});
}

function handleNewPasswordBlur(event: React.SyntheticEvent<any>) {
setModelState({ ...modelState, ...validateNewPassword(event.currentTarget == newPassword2.current) }).done();
setModelState({ ...modelState, ...validateNewPassword(event.currentTarget == newPassword2.current) });
}

function validateNewPassword(isSecond: boolean) {
Expand Down
6 changes: 3 additions & 3 deletions Signum.React.Extensions/Cache/CacheStatisticsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ export default function CacheStatisticsPage(p: RouteComponentProps<{}>) {
var [state, reloadState] = useAPIWithReload(() => API.view(), [], { avoidReset: true });

function handleDisabled(e: React.MouseEvent<any>) {
API.disable().then(() => reloadState()).done();
API.disable().then(() => reloadState());
}

function handleEnabled(e: React.MouseEvent<any>) {
API.enable().then(() => reloadState()).done();
API.enable().then(() => reloadState());
}

function handleClear(e: React.MouseEvent<any>) {
API.clear().then(() => reloadState()).done();
API.clear().then(() => reloadState());
}

if (state == null)
Expand Down
2 changes: 1 addition & 1 deletion Signum.React.Extensions/Chart/ChartButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default class ChartButton extends React.Component<ChartButtonProps> {
window.open(AppContext.toAbsoluteUrl(path));
else
AppContext.pushOrOpenInTab(path, e);
}).done();
});
}

render() {
Expand Down
Loading

0 comments on commit e727d00

Please sign in to comment.