Skip to content

Commit

Permalink
Only update dirty properties of views (#3885)
Browse files Browse the repository at this point in the history
* leanInfoUpdates

* leanInfoUpdates
  • Loading branch information
lbwexler authored Jan 2, 2025
1 parent 926132a commit 565aac8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
6 changes: 3 additions & 3 deletions cmp/viewmanager/ViewManagerModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export interface ViewCreateSpec {
}

export interface ViewUpdateSpec {
name: string;
group: string;
description: string;
name?: string;
group?: string;
description?: string;
isShared?: boolean;
isDefaultPinned?: boolean;
}
Expand Down
16 changes: 5 additions & 11 deletions desktop/cmp/viewmanager/dialog/ViewPanelModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import {FormModel} from '@xh/hoist/cmp/form';
import {fragment, p, strong} from '@xh/hoist/cmp/layout';
import {HoistModel, managed, TaskObserver, XH} from '@xh/hoist/core';
import {capitalize} from 'lodash';
import {capitalize, isUndefined} from 'lodash';
import {ManageDialogModel} from './ManageDialogModel';
import {makeObservable} from '@xh/hoist/mobx';
import {ViewInfo} from '@xh/hoist/cmp/viewmanager';
Expand Down Expand Up @@ -55,14 +55,14 @@ export class ViewPanelModel extends HoistModel {

async saveAsync() {
const {parent, view, formModel} = this,
{name, group, description, isDefaultPinned, isShared} = formModel.getData(),
updates = formModel.getData(true),
isValid = await formModel.validateAsync(),
isDirty = formModel.isDirty;

if (!isValid || !isDirty) return;

if (view.isOwned && view.isShared != isShared) {
const msg: ReactNode = !isShared
if (view.isOwned && !isUndefined(updates.isShared)) {
const msg: ReactNode = !updates.isShared
? `Your ${view.typedName} will no longer be visible to all other ${XH.appName} users.`
: `Your ${view.typedName} will become visible to all other ${XH.appName} users.`;
const msgs = [msg, strong('Are you sure you want to proceed?')];
Expand All @@ -79,13 +79,7 @@ export class ViewPanelModel extends HoistModel {
if (!confirmed) return;
}

await parent.updateAsync(view, {
name,
group,
description,
isShared,
isDefaultPinned
});
await parent.updateAsync(view, updates);
}

//------------------------
Expand Down

0 comments on commit 565aac8

Please sign in to comment.