Skip to content

Commit c20f511

Browse files
committed
fix popup nullchecks checks
1 parent 174a9d0 commit c20f511

File tree

3 files changed

+64
-57
lines changed

3 files changed

+64
-57
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sp-editor",
3-
"version": "7.1.1",
3+
"version": "7.1.2",
44
"private": true,
55
"homepage": ".",
66
"dependencies": {

public/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "SP Editor",
33
"homepage_url": "https://microsoftedge.microsoft.com/addons/detail/affnnhcbfmcbbdlcadgkdbfafigmjdkk",
4-
"version": "7.1.1",
4+
"version": "7.1.2",
55
"description": "Create and update SharePoint Online/SP2013/SP2016/SP2019 css/js files, inject files to web, manage web/list properties, list Webhook",
66
"manifest_version": 3,
77
"devtools_page": "devtools.html",

src/popup/Components/QuickLinkList.tsx

Lines changed: 62 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,24 @@ const QuickLinkList = ({ ctx, appCatalogUrl, tabUrl }: IQuickLinkListProps) => {
4141
iconName={'Code'}
4242
disabled={!ctx || !ctx.webAbsoluteUrl || !tabUrl}
4343
url={
44-
tabUrl +
45-
(tabUrl && tabUrl.indexOf('?') > -1 ? '&' : '?') +
46-
'loadSPFX=true&debugManifestsFile=https://localhost:4321/temp/manifests.js'
44+
tabUrl
45+
? tabUrl +
46+
(tabUrl.indexOf('?') > -1 ? '&' : '?') +
47+
'loadSPFX=true&debugManifestsFile=https://localhost:4321/temp/manifests.js'
48+
: ''
4749
}
4850
newWTab={false}
4951
/>
5052
<QuickLinkButton
5153
text={'Remote workbench'}
5254
iconName={'Code'}
53-
disabled={!ctx || !ctx.webAbsoluteUrl || !tabUrl}
54-
url={ctx.webAbsoluteUrl + '/_layouts/workbench.aspx'}
55+
disabled={!ctx || !ctx.webAbsoluteUrl}
56+
url={ctx.webAbsoluteUrl ? ctx.webAbsoluteUrl + '/_layouts/workbench.aspx' : ''}
5557
/>
5658
<QuickLinkButton
5759
text={'Local workbench'}
5860
iconName={'Code'}
59-
disabled={!ctx || !ctx.webAbsoluteUrl || !tabUrl}
61+
disabled={!ctx || !ctx.webAbsoluteUrl}
6062
url={'https://localhost:4321/workbench'}
6163
/>
6264
<Separator alignContent="start" styles={separatorStyles}>
@@ -65,51 +67,56 @@ const QuickLinkList = ({ ctx, appCatalogUrl, tabUrl }: IQuickLinkListProps) => {
6567
<QuickLinkButton
6668
text={'Admin center'}
6769
iconName={'Admin'}
68-
disabled={!ctx || !ctx.portalUrl}
70+
disabled={!ctx || !ctx.isSPO || !ctx.portalUrl}
6971
url={
70-
ctx.isSPO &&
71-
ctx.portalUrl.toLocaleLowerCase().replace('.sharepoint.', '-admin.sharepoint.') +
72-
'/_layouts/15/online/AdminHome.aspx#/home'
72+
ctx && ctx.isSPO && ctx.portalUrl
73+
? ctx.portalUrl.toLocaleLowerCase().replace('.sharepoint.', '-admin.sharepoint.') +
74+
'/_layouts/15/online/AdminHome.aspx#/home'
75+
: ''
7376
}
7477
/>
7578
<QuickLinkButton
7679
text={'User profiles'}
7780
iconName={'People'}
78-
disabled={!ctx || !ctx.portalUrl}
81+
disabled={!ctx || !ctx.isSPO || !ctx.portalUrl}
7982
url={
80-
ctx.isSPO &&
81-
ctx.portalUrl.toLocaleLowerCase().replace('.sharepoint.', '-admin.sharepoint.') +
82-
'/_layouts/15/tenantprofileadmin/manageuserprofileserviceapplication.aspx'
83+
ctx && ctx.isSPO && ctx.portalUrl
84+
? ctx.portalUrl.toLocaleLowerCase().replace('.sharepoint.', '-admin.sharepoint.') +
85+
'/_layouts/15/tenantprofileadmin/manageuserprofileserviceapplication.aspx'
86+
: ''
8387
}
8488
/>
8589
<QuickLinkButton
8690
text={'Term store'}
8791
iconName={'Tag'}
88-
disabled={!ctx || !ctx.portalUrl}
92+
disabled={!ctx || !ctx.isSPO || !ctx.portalUrl}
8993
url={
90-
ctx.isSPO &&
91-
ctx.portalUrl.toLocaleLowerCase().replace('.sharepoint.', '-admin.sharepoint.') +
92-
'/_layouts/15/online/AdminHome.aspx#/termStoreAdminCenter'
94+
ctx && ctx.isSPO && ctx.portalUrl
95+
? ctx.portalUrl.toLocaleLowerCase().replace('.sharepoint.', '-admin.sharepoint.') +
96+
'/_layouts/15/online/AdminHome.aspx#/termStoreAdminCenter'
97+
: ''
9398
}
9499
/>
95100
<QuickLinkButton
96101
text={'Search administration'}
97102
iconName={'Search'}
98-
disabled={!ctx || !ctx.portalUrl}
103+
disabled={!ctx || !ctx.isSPO || !ctx.portalUrl}
99104
url={
100-
ctx.isSPO &&
101-
ctx.portalUrl.toLocaleLowerCase().replace('.sharepoint.', '-admin.sharepoint.') +
102-
'/_layouts/15/searchadmin/TA_SearchAdministration.aspx'
105+
ctx && ctx.isSPO && ctx.portalUrl
106+
? ctx.portalUrl.toLocaleLowerCase().replace('.sharepoint.', '-admin.sharepoint.') +
107+
'/_layouts/15/searchadmin/TA_SearchAdministration.aspx'
108+
: ''
103109
}
104110
/>
105111
<QuickLinkButton
106112
text={'API access'}
107113
iconName={'AzureAPIManagement'}
108-
disabled={!ctx || !ctx.portalUrl}
114+
disabled={!ctx || !ctx.isSPO || !ctx.portalUrl}
109115
url={
110-
ctx.isSPO &&
111-
ctx.portalUrl.toLocaleLowerCase().replace('.sharepoint.', '-admin.sharepoint.') +
112-
'/_layouts/15/online/AdminHome.aspx#/webApiPermissionManagement'
116+
ctx && ctx.isSPO && ctx.portalUrl
117+
? ctx.portalUrl.toLocaleLowerCase().replace('.sharepoint.', '-admin.sharepoint.') +
118+
'/_layouts/15/online/AdminHome.aspx#/webApiPermissionManagement'
119+
: ''
113120
}
114121
/>
115122
<QuickLinkButton
@@ -122,13 +129,13 @@ const QuickLinkList = ({ ctx, appCatalogUrl, tabUrl }: IQuickLinkListProps) => {
122129
text={'App catalog'}
123130
iconName={'AppIconDefaultList'}
124131
disabled={!appCatalogUrl}
125-
url={appCatalogUrl + '/_layouts/15/tenantAppCatalog.aspx/manageApps'}
132+
url={appCatalogUrl ? appCatalogUrl + '/_layouts/15/tenantAppCatalog.aspx/manageApps' : ''}
126133
/>
127134
<QuickLinkButton
128135
text={'Classic app catalog'}
129136
iconName={'AppIconDefaultList'}
130137
disabled={!appCatalogUrl}
131-
url={appCatalogUrl + '/AppCatalog/Forms/AllItems.aspx'}
138+
url={appCatalogUrl ? appCatalogUrl + '/AppCatalog/Forms/AllItems.aspx' : ''}
132139
/>
133140
<Separator alignContent="start" styles={separatorStyles}>
134141
Current site
@@ -137,70 +144,70 @@ const QuickLinkList = ({ ctx, appCatalogUrl, tabUrl }: IQuickLinkListProps) => {
137144
text={'Site settings'}
138145
iconName={'Settings'}
139146
disabled={!ctx || !ctx.webAbsoluteUrl}
140-
url={ctx.webAbsoluteUrl + '/_layouts/15/settings.aspx'}
147+
url={ctx && ctx.webAbsoluteUrl ? ctx.webAbsoluteUrl + '/_layouts/15/settings.aspx' : ''}
141148
/>
142149
<QuickLinkButton
143150
text={'Tenant site settings'}
144151
iconName={'Settings'}
145-
disabled={!ctx || !ctx.webAbsoluteUrl}
152+
disabled={!ctx || !ctx.isSPO || !ctx.portalUrl || !ctx.siteId}
146153
url={
147-
ctx.isSPO
148-
? ctx.portalUrl &&
149-
ctx.portalUrl.toLocaleLowerCase().replace('.sharepoint.', '-admin.sharepoint.') +
150-
`/_layouts/15/online/AdminHome.aspx#/siteManagement/:/SiteDetails/${ctx.siteId.replace(
151-
/[{}]/g,
152-
''
153-
)}/Settings`
154-
: null
154+
ctx && ctx.isSPO && ctx.portalUrl && ctx.siteId
155+
? ctx.portalUrl.toLocaleLowerCase().replace('.sharepoint.', '-admin.sharepoint.') +
156+
`/_layouts/15/online/AdminHome.aspx#/siteManagement/:/SiteDetails/${ctx.siteId.replace(
157+
/[{}]/g,
158+
''
159+
)}/Settings`
160+
: ''
155161
}
156162
/>
157163
<QuickLinkButton
158164
text={'Site contents'}
159165
iconName={'ThumbnailView'}
160166
disabled={!ctx || !ctx.webAbsoluteUrl}
161-
url={ctx.webAbsoluteUrl + '/_layouts/15/viewlsts.aspx'}
167+
url={ctx && ctx.webAbsoluteUrl ? ctx.webAbsoluteUrl + '/_layouts/15/viewlsts.aspx' : ''}
162168
/>
163169
<QuickLinkButton
164170
text={'Recycle bin'}
165171
iconName={'RecycleBin'}
166172
disabled={!ctx || !ctx.webAbsoluteUrl}
167-
url={ctx.webAbsoluteUrl + '/_layouts/15/AdminRecycleBin.aspx?view=5'}
173+
url={ctx && ctx.webAbsoluteUrl ? ctx.webAbsoluteUrl + '/_layouts/15/AdminRecycleBin.aspx?view=5' : ''}
168174
/>
169175
<QuickLinkButton
170176
text={'All People'}
171177
iconName={'People'}
172178
disabled={!ctx || !ctx.webAbsoluteUrl}
173-
url={ctx.webAbsoluteUrl + '/_layouts/people.aspx?MembershipGroupId=0'}
179+
url={ctx && ctx.webAbsoluteUrl ? ctx.webAbsoluteUrl + '/_layouts/people.aspx?MembershipGroupId=0' : ''}
174180
/>
175181
<QuickLinkButton
176182
text={'Storage metrics'}
177183
iconName={'StackedBarChart'}
178184
disabled={!ctx || !ctx.webAbsoluteUrl}
179-
url={ctx.webAbsoluteUrl + '/_layouts/15/storman.aspx'}
185+
url={ctx && ctx.webAbsoluteUrl ? ctx.webAbsoluteUrl + '/_layouts/15/storman.aspx' : ''}
180186
/>
181187
<Separator alignContent="start" styles={separatorStyles}>
182188
Current user
183189
</Separator>
184190
<QuickLinkButton
185191
text={'Edit user profile'}
186192
iconName={'EditContact'}
187-
disabled={!ctx}
193+
disabled={!ctx || !ctx.isSPO || !ctx.portalUrl}
188194
url={
189-
ctx.isSPO
190-
? ctx.portalUrl &&
191-
ctx.portalUrl.toLocaleLowerCase().replace('.sharepoint.', '-my.sharepoint.') +
192-
'_layouts/15/editprofile.aspx?UserSettingsProvider=dfb95e82-8132-404b-b693-25418fdac9b6'
193-
: ctx.ProfileUrl
195+
ctx && ctx.isSPO && ctx.portalUrl
196+
? ctx.portalUrl.toLocaleLowerCase().replace('.sharepoint.', '-my.sharepoint.') +
197+
'_layouts/15/editprofile.aspx?UserSettingsProvider=dfb95e82-8132-404b-b693-25418fdac9b6'
198+
: ctx?.ProfileUrl || ''
194199
}
195200
/>
196201
<QuickLinkButton
197202
text={'Login as another user'}
198203
iconName={'Signin'}
199204
disabled={!ctx || !ctx.webAbsoluteUrl}
200205
url={
201-
ctx.webAbsoluteUrl +
202-
'/_layouts/closeConnection.aspx?loginasanotheruser=true&source=' +
203-
encodeURIComponent(ctx.webAbsoluteUrl)
206+
ctx && ctx.webAbsoluteUrl
207+
? ctx.webAbsoluteUrl +
208+
'/_layouts/closeConnection.aspx?loginasanotheruser=true&source=' +
209+
encodeURIComponent(ctx.webAbsoluteUrl)
210+
: ''
204211
}
205212
newWTab={false}
206213
/>
@@ -211,25 +218,25 @@ const QuickLinkList = ({ ctx, appCatalogUrl, tabUrl }: IQuickLinkListProps) => {
211218
text={'?MaintenanceMode=true'}
212219
iconName={'Repair'}
213220
disabled={!ctx || !ctx.webAbsoluteUrl || !tabUrl}
214-
url={tabUrl + (tabUrl && tabUrl.indexOf('?') > -1 ? '&' : '?') + 'maintenancemode=true'}
221+
url={tabUrl ? tabUrl + (tabUrl.indexOf('?') > -1 ? '&' : '?') + 'maintenancemode=true' : ''}
215222
/>
216223
<QuickLinkButton
217224
text={'?env=WebView'}
218225
iconName={'Repair'}
219226
disabled={!ctx || !ctx.webAbsoluteUrl || !tabUrl}
220-
url={tabUrl + (tabUrl && tabUrl.indexOf('?') > -1 ? '&' : '?') + 'env=WebView'}
227+
url={tabUrl ? tabUrl + (tabUrl.indexOf('?') > -1 ? '&' : '?') + 'env=WebView' : ''}
221228
/>
222229
<QuickLinkButton
223230
text={'?env=WebViewList'}
224231
iconName={'Repair'}
225232
disabled={!ctx || !ctx.webAbsoluteUrl || !tabUrl}
226-
url={tabUrl + (tabUrl && tabUrl.indexOf('?') > -1 ? '&' : '?') + 'env=WebViewList'}
233+
url={tabUrl ? tabUrl + (tabUrl.indexOf('?') > -1 ? '&' : '?') + 'env=WebViewList' : ''}
227234
/>
228235
<QuickLinkButton
229236
text={'?disable3PCode=1'}
230237
iconName={'Repair'}
231238
disabled={!ctx || !ctx.webAbsoluteUrl || !tabUrl}
232-
url={tabUrl + (tabUrl && tabUrl.indexOf('?') > -1 ? '&' : '?') + 'disable3PCode=1'}
239+
url={tabUrl ? tabUrl + (tabUrl.indexOf('?') > -1 ? '&' : '?') + 'disable3PCode=1' : ''}
233240
/>
234241
</ScrollablePane>
235242
) : (

0 commit comments

Comments
 (0)