Skip to content

Commit 5f912c4

Browse files
committed
update Dialog Component
1 parent 188e8a7 commit 5f912c4

File tree

4 files changed

+33
-22
lines changed

4 files changed

+33
-22
lines changed

src/controls/listItemAttachments/IListItemAttachmentsState.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {IListItemAttachmentFile } from './IListItemAttachmentFile';
22
export interface IListItemAttachmentsState {
33
file: IListItemAttachmentFile;
4-
showDialog: boolean;
4+
hideDialog: boolean;
55
dialogMessage: string;
66
attachments: IListItemAttachmentFile[];
77
deleteAttachment: boolean;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
export interface IUploadAttachmentState {
33
file: any;
4-
showDialog: boolean;
4+
hideDialog: boolean;
55
dialogMessage: string;
66
isLoading: boolean;
77
}

src/controls/listItemAttachments/ListItemAttachments.tsx

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class ListItemAttachments extends React.Component<IListItemAttachmentsPro
3333

3434
this.state = {
3535
file: null,
36-
showDialog: false,
36+
hideDialog: true,
3737
dialogMessage: '',
3838
attachments: [],
3939
deleteAttachment: false,
@@ -67,14 +67,14 @@ export class ListItemAttachments extends React.Component<IListItemAttachmentsPro
6767
});
6868
}
6969
this.setState({
70-
showDialog: false,
70+
hideDialog: true,
7171
dialogMessage: '',
7272
attachments: files
7373
});
7474
}
7575
catch (error) {
7676
this.setState({
77-
showDialog: true,
77+
hideDialog: true,
7878
dialogMessage: strings.ListItemAttachmentserrorLoadAttachments.replace('{0}', error.message)
7979
});
8080
}
@@ -107,7 +107,7 @@ export class ListItemAttachments extends React.Component<IListItemAttachmentsPro
107107
directionalHint={DirectionalHint.rightCenter}>
108108

109109
<DocumentCard
110-
onClickHref={ `${_file.ServerRelativeUrl}?web=1`}
110+
onClickHref={`${_file.ServerRelativeUrl}?web=1`}
111111
className={styles.documentCard}>
112112
<DocumentCardPreview previewImages={[this.previewImages[i]]} />
113113
<Label className={styles.fileLabel}>
@@ -141,12 +141,18 @@ export class ListItemAttachments extends React.Component<IListItemAttachmentsPro
141141
{
142142

143143
<Dialog
144-
isOpen={this.state.showDialog}
144+
hidden={this.state.hideDialog}
145145
type={DialogType.normal}
146146
onDismiss={this._closeDialog}
147-
title={strings.ListItemAttachmentsdialogTitle}
148-
subText={this.state.dialogMessage}
149-
isBlocking={true}>
147+
dialogContentProps={{
148+
type: DialogType.normal,
149+
title: strings.ListItemAttachmentsdialogTitle,
150+
subText: this.state.dialogMessage
151+
}}
152+
modalProps={{
153+
isBlocking: true,
154+
containerClassName: 'ms-dialogMainOverride'
155+
}} >
150156
<DialogFooter>
151157
<div style={{ marginBottom: 7 }}>
152158
{
@@ -172,7 +178,7 @@ export class ListItemAttachments extends React.Component<IListItemAttachmentsPro
172178
e.preventDefault();
173179

174180
this.setState({
175-
showDialog: false,
181+
hideDialog: true,
176182
dialogMessage: '',
177183
file: null,
178184
deleteAttachment: false,
@@ -189,7 +195,7 @@ export class ListItemAttachments extends React.Component<IListItemAttachmentsPro
189195
// On _onDeleteAttachment
190196
private _onDeleteAttachment(_file: IListItemAttachmentFile) {
191197
this.setState({
192-
showDialog: true,
198+
hideDialog: false,
193199
deleteAttachment: true,
194200
file: _file,
195201
dialogMessage: strings.ListItemAttachmentsconfirmDelete.replace('{0}', _file.FileName),
@@ -210,7 +216,7 @@ export class ListItemAttachments extends React.Component<IListItemAttachmentsPro
210216
.then(() => {
211217

212218
this.setState({
213-
showDialog: true,
219+
hideDialog: false,
214220
deleteAttachment: false,
215221
disableButton: false,
216222
file: null,
@@ -221,7 +227,7 @@ export class ListItemAttachments extends React.Component<IListItemAttachmentsPro
221227
.catch((reason) => {
222228

223229
this.setState({
224-
showDialog: true,
230+
hideDialog: false,
225231
file: null,
226232
deleteAttachment: false,
227233
dialogMessage: strings.ListItemAttachmentsfileDeleteError.replace('{0}', _file.FileName).replace('{1}', reason)

src/controls/listItemAttachments/UploadAttachment.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import SPservice from "../../services/SPService";
88
import * as strings from 'ControlStrings';
99
import { CommandBar } from 'office-ui-fabric-react/lib/CommandBar';
1010
import { ProgressIndicator } from 'office-ui-fabric-react/lib/ProgressIndicator';
11-
import * as $ from 'jquery';
1211
import { createRef } from '@uifabric/utilities/lib';
1312

1413
export class UploadAttachment extends React.Component<IUploadAttachmentProps, IUploadAttachmentState> {
@@ -18,7 +17,7 @@ export class UploadAttachment extends React.Component<IUploadAttachmentProps, IU
1817
super(props);
1918
this.state = {
2019
file: null,
21-
showDialog: false,
20+
hideDialog: true,
2221
dialogMessage: '',
2322
isLoading: false
2423
};
@@ -66,7 +65,7 @@ export class UploadAttachment extends React.Component<IUploadAttachmentProps, IU
6665
})
6766
.catch((reason) => {
6867
this.setState({
69-
showDialog: true,
68+
hideDialog: false,
7069
isLoading: false,
7170
dialogMessage: strings.ListItemAttachmentsuploadAttachmentErrorMsg.replace('{0}', file.name).replace('{1}', reason)
7271
});
@@ -104,12 +103,18 @@ export class UploadAttachment extends React.Component<IUploadAttachmentProps, IU
104103
}
105104
</div>
106105
<Dialog
107-
isOpen={this.state.showDialog}
106+
hidden={this.state.hideDialog}
108107
type={DialogType.normal}
109108
onDismiss={this._closeDialog}
110-
title={strings.ListItemAttachmentsuploadAttachmentDialogTitle}
111-
subText={this.state.dialogMessage}
112-
isBlocking={true}>
109+
dialogContentProps={{
110+
type: DialogType.normal,
111+
title:strings.ListItemAttachmentsuploadAttachmentDialogTitle,
112+
subText: this.state.dialogMessage
113+
}}
114+
modalProps={{
115+
isBlocking: true,
116+
containerClassName: 'ms-dialogMainOverride'
117+
}} >
113118
<DialogFooter>
114119
<PrimaryButton onClick={this._closeDialog}>OK</PrimaryButton>
115120
</DialogFooter>
@@ -121,7 +126,7 @@ export class UploadAttachment extends React.Component<IUploadAttachmentProps, IU
121126
private _closeDialog(e) {
122127
e.preventDefault();
123128
this.setState({
124-
showDialog: false,
129+
hideDialog: true,
125130
dialogMessage: '',
126131
});
127132
}

0 commit comments

Comments
 (0)