@@ -2,7 +2,20 @@ import React, { useState } from "react";
2
2
import { profileFlagsState } from "../../data/atoms" ;
3
3
import { axios } from "../../data/axios" ;
4
4
import { useRecoilValue } from "recoil" ;
5
- import { message , Modal , Button , Select , Spin } from "antd" ;
5
+ import { enqueueSnackbar } from "notistack" ;
6
+ import {
7
+ Button ,
8
+ CircularProgress ,
9
+ Dialog ,
10
+ DialogTitle ,
11
+ DialogContent ,
12
+ DialogActions ,
13
+ FormControl ,
14
+ InputLabel ,
15
+ MenuItem ,
16
+ Select ,
17
+ TextField ,
18
+ } from "@mui/material" ;
6
19
7
20
function PublishModalInternal ( {
8
21
show,
@@ -90,32 +103,85 @@ function PublishModalInternal({
90
103
}
91
104
} )
92
105
. catch ( ( error ) => {
93
- message . error ( error . response ?. data ?. message || "Error publishing app" ) ;
106
+ enqueueSnackbar (
107
+ error . response ?. data ?. message || "Error publishing app" ,
108
+ {
109
+ variant : "error" ,
110
+ } ,
111
+ ) ;
94
112
} )
95
113
. finally ( ( ) => {
96
114
setIsPublishing ( false ) ;
97
115
} ) ;
98
116
} ;
99
117
100
118
return (
101
- < Modal
102
- title = { editSharing ? "App Sharing" : "Publish App" }
103
- open = { show }
104
- onOk = { ( ) => {
105
- setDone ( false ) ;
106
- setShow ( false ) ;
107
- } }
108
- onCancel = { ( ) => {
109
- setDone ( false ) ;
110
- setShow ( false ) ;
111
- } }
112
- footer = { [
113
- < Button key = "back" onClick = { ( ) => setShow ( false ) } >
114
- Cancel
115
- </ Button > ,
116
- < Button key = "submit" type = "primary" onClick = { publishApp } >
119
+ < Dialog open = { show } onClose = { ( ) => setShow ( false ) } >
120
+ < DialogTitle > { editSharing ? "App Sharing" : "Publish App" } </ DialogTitle >
121
+ < DialogContent >
122
+ { done && < p > App { editSharing ? "saved" : "published" } successfully!</ p > }
123
+ { ! done && (
124
+ < div >
125
+ < h5 > Choose who can access this App</ h5 >
126
+ < FormControl style = { { width : "100%" } } >
127
+ < InputLabel id = "visibility-label" > Visibility</ InputLabel >
128
+ < Select
129
+ labelId = "visibility-label"
130
+ id = "visibility"
131
+ value = { visibility }
132
+ onChange = { ( e ) => setVisibility ( e . target . value ) }
133
+ >
134
+ { visibilityOptions . map ( ( option ) => (
135
+ < MenuItem key = { option . value } value = { option . value } >
136
+ { option . label }
137
+ < br />
138
+ < small > { option . description } </ small >
139
+ </ MenuItem >
140
+ ) ) }
141
+ </ Select >
142
+ </ FormControl >
143
+ { visibility === 0 && (
144
+ < div style = { { marginTop : 10 , margin : "auto" } } >
145
+ < p >
146
+ Select users who can access the app. Only users with given
147
+ email addresses will be able to access the app.
148
+ </ p >
149
+ < TextField
150
+ label = "Enter valid email addresses"
151
+ value = { accessibleBy }
152
+ onChange = { ( e ) => setAccessibleBy ( e . target . value ) }
153
+ style = { { width : "75%" } }
154
+ />
155
+ < FormControl style = { { width : "25%" } } >
156
+ < InputLabel id = "access-permission-label" >
157
+ Permissions
158
+ </ InputLabel >
159
+ < Select
160
+ labelId = "access-permission-label"
161
+ id = "access-permission"
162
+ value = { accessPermission }
163
+ onChange = { ( e ) => setAccessPermission ( e . target . value ) }
164
+ >
165
+ { accessPermissionOptions . map ( ( option ) => (
166
+ < MenuItem key = { option . value } value = { option . value } >
167
+ { option . label }
168
+ < br />
169
+ < small > { option . description } </ small >
170
+ </ MenuItem >
171
+ ) ) }
172
+ </ Select >
173
+ </ FormControl >
174
+
175
+ </ div >
176
+ ) }
177
+ </ div >
178
+ ) }
179
+ </ DialogContent >
180
+ < DialogActions >
181
+ < Button onClick = { ( ) => setShow ( false ) } > Cancel</ Button >
182
+ < Button onClick = { publishApp } >
117
183
{ isPublishing ? (
118
- < Spin />
184
+ < CircularProgress />
119
185
) : done ? (
120
186
< a
121
187
href = { `/app/${ app . published_uuid } ` }
@@ -129,60 +195,9 @@ function PublishModalInternal({
129
195
) : (
130
196
"Publish App"
131
197
) }
132
- </ Button > ,
133
- ] }
134
- >
135
- { done && < p > App { editSharing ? "saved" : "published" } successfully!</ p > }
136
- { ! done && (
137
- < div >
138
- < h5 > Choose who can access this App</ h5 >
139
- < Select
140
- style = { { width : "100%" } }
141
- value = { visibility }
142
- onChange = { ( value ) => setVisibility ( value ) }
143
- >
144
- { visibilityOptions . map ( ( option ) => (
145
- < Select . Option key = { option . value } value = { option . value } >
146
- { option . label }
147
- < br />
148
- < small > { option . description } </ small >
149
- </ Select . Option >
150
- ) ) }
151
- </ Select >
152
- { visibility === 0 && (
153
- < div style = { { marginTop : 10 , margin : "auto" } } >
154
- < p >
155
- Select users who can access the app. Only users with given email
156
- addresses will be able to access the app.
157
- </ p >
158
- < Select
159
- mode = "tags"
160
- style = { { width : "75%" } }
161
- placeholder = "Enter valid email addresses"
162
- value = { accessibleBy }
163
- onChange = { ( value ) => setAccessibleBy ( value ) }
164
- notFoundContent = { null }
165
- />
166
- < Select
167
- style = { { width : "25%" } }
168
- placeholder = "Select permissions"
169
- value = { accessPermission }
170
- onChange = { ( value ) => setAccessPermission ( value ) }
171
- >
172
- { accessPermissionOptions . map ( ( option ) => (
173
- < Select . Option key = { option . value } value = { option . value } >
174
- { option . label }
175
- < br />
176
- < small > { option . description } </ small >
177
- </ Select . Option >
178
- ) ) }
179
- </ Select >
180
-
181
- </ div >
182
- ) }
183
- </ div >
184
- ) }
185
- </ Modal >
198
+ </ Button >
199
+ </ DialogActions >
200
+ </ Dialog >
186
201
) ;
187
202
}
188
203
@@ -242,8 +257,11 @@ export function UnpublishModal({ show, setShow, app, setIsPublished }) {
242
257
setDone ( true ) ;
243
258
} )
244
259
. catch ( ( error ) => {
245
- message . error (
260
+ enqueueSnackbar (
246
261
error . response ?. data ?. message || "Error unpublishing app" ,
262
+ {
263
+ variant : "error" ,
264
+ } ,
247
265
) ;
248
266
} )
249
267
. finally ( ( ) => {
@@ -252,33 +270,29 @@ export function UnpublishModal({ show, setShow, app, setIsPublished }) {
252
270
} ;
253
271
254
272
return (
255
- < Modal
256
- title = { "Unpublish App" }
257
- open = { show }
258
- onOk = { ( ) => {
259
- setDone ( false ) ;
260
- setShow ( false ) ;
261
- } }
262
- onCancel = { ( ) => {
263
- setDone ( false ) ;
264
- setShow ( false ) ;
265
- } }
266
- footer = { [
267
- < Button key = "back" onClick = { ( ) => setShow ( false ) } >
268
- Cancel
269
- </ Button > ,
270
- < Button key = "submit" type = "primary" onClick = { unpublishApp } >
271
- { isUnpublishing ? < Spin /> : done ? "Done" : "Yes, Unpublish App" }
272
- </ Button > ,
273
- ] }
274
- >
275
- { done && < p > App unpublished successfully!</ p > }
276
- { ! done && (
277
- < p >
278
- Are you sure want to unpublish the app? This will make the app
279
- unaccessible to anyone it was already shared with.
280
- </ p >
281
- ) }
282
- </ Modal >
273
+ < Dialog open = { show } onClose = { ( ) => setShow ( false ) } >
274
+ < DialogTitle > Unpublish App</ DialogTitle >
275
+ < DialogContent >
276
+ { done && < p > App unpublished successfully!</ p > }
277
+ { ! done && (
278
+ < p >
279
+ Are you sure want to unpublish the app? This will make the app
280
+ unaccessible to anyone it was already shared with.
281
+ </ p >
282
+ ) }
283
+ </ DialogContent >
284
+ < DialogActions >
285
+ < Button onClick = { ( ) => setShow ( false ) } > Cancel</ Button >
286
+ < Button onClick = { unpublishApp } >
287
+ { isUnpublishing ? (
288
+ < CircularProgress />
289
+ ) : done ? (
290
+ "Done"
291
+ ) : (
292
+ "Yes, Unpublish App"
293
+ ) }
294
+ </ Button >
295
+ </ DialogActions >
296
+ </ Dialog >
283
297
) ;
284
298
}
0 commit comments