Skip to content

Commit d5254b9

Browse files
committed
Edits in panel fixes, version update, ready to publish.
1 parent 19d6db8 commit d5254b9

File tree

8 files changed

+90
-54
lines changed

8 files changed

+90
-54
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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.6.0",
3+
"version": "7.6.1",
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.6.0",
4+
"version": "7.6.1",
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/components/navigation.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,17 @@ export const FabricNav = () => {
8181
key: 'key18',
8282
disabled: false,
8383
},
84+
{
85+
name: 'Tenant Properties',
86+
url: '/tenantproperties',
87+
key: 'key18',
88+
},
8489
{
8590
name: 'Page editor',
8691
url: '/pageeditor',
8792
key: 'key11',
8893
disabled: false,
8994
},
90-
{
91-
name: 'Tenant Properties',
92-
url: '/tenantproperties',
93-
key: 'key18',
94-
},
9595
{
9696
name: 'Modern properties',
9797
url: '/modernproperties',

src/pages/listproperties/components/editpanel.tsx

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { IListProperty } from '../../../store/listproperties/types'
1919
import { addListProperty } from '../chrome/chrome-actions'
2020

2121
const ListPropertiesEditPanel = () => {
22-
2322
const dispatch = useDispatch()
2423
const { isDark } = useSelector((state: IRootState) => state.home)
2524
const { editpanel, selectedItem, confirmedit } = useSelector((state: IRootState) => state.listProperties)
@@ -34,7 +33,12 @@ const ListPropertiesEditPanel = () => {
3433
const _onRenderItemFooterContent = () => {
3534
return (
3635
<PrimaryButton
37-
onClick={() => dispatch(setConfirmEditDialog(false))}
36+
onClick={() => {
37+
if (editItem) {
38+
dispatch(setSelectedItem(editItem))
39+
dispatch(setConfirmEditDialog(false))
40+
}
41+
}}
3842
style={{ marginRight: '8px' }}
3943
text={'Update'}
4044
/>
@@ -48,8 +52,7 @@ const ListPropertiesEditPanel = () => {
4852
onDismiss={() => {
4953
dispatch(setSelectedItem(undefined))
5054
dispatch(setEditPanel(false))
51-
}
52-
}
55+
}}
5356
isLightDismiss={true}
5457
isFooterAtBottom={true}
5558
headerText='Edit List Property'
@@ -75,19 +78,23 @@ const ListPropertiesEditPanel = () => {
7578
rows={5}
7679
autoAdjustHeight
7780
onChange={(event, newValue?: string) => {
78-
dispatch(setSelectedItem({ ...selectedItem, value: newValue ? newValue : '' }))
81+
if (editItem) {
82+
// Update local state only
83+
setEditItem({ ...editItem, value: newValue ? newValue : '' });
84+
}
85+
}}
86+
/>
87+
<Toggle
88+
label='Indexed'
89+
checked={editItem?.indexed}
90+
onText='Yes'
91+
offText='No'
92+
onChange={(event, checked?: boolean) => {
93+
if (editItem) {
94+
setEditItem({ ...editItem, indexed: checked ? true : false })
95+
}
7996
}}
8097
/>
81-
<Toggle
82-
label='Indexed'
83-
checked={selectedItem.indexed}
84-
onText='Yes'
85-
offText='No'
86-
onChange={(event, checked?: boolean) => {
87-
dispatch(setSelectedItem({ ...selectedItem, indexed: checked ? true : false }))
88-
}}
89-
/>
90-
9198
</Stack>
9299
}
93100
<Dialog
@@ -113,4 +120,4 @@ const ListPropertiesEditPanel = () => {
113120
)
114121
}
115122

116-
export default ListPropertiesEditPanel
123+
export default ListPropertiesEditPanel

src/pages/scriptlinks/components/editpanel.tsx

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,36 @@ import {
1212
Stack,
1313
TextField,
1414
} from '@fluentui/react'
15-
import React from 'react'
15+
import React, { useEffect, useState } from 'react'
1616
import { useDispatch, useSelector } from 'react-redux'
1717
import { IRootState } from '../../../store'
1818
import { setConfirmEditDialog, setEditPanel, setSelectedItem } from '../../../store/scriptlinks/actions'
19+
import { IScriptLink } from '../../../store/scriptlinks/types'
1920
import { updateScriptLink } from '../chrome/chrome-actions'
2021

2122
const ScriptLinksEditPanel = () => {
22-
2323
const dispatch = useDispatch()
2424
const { isDark } = useSelector((state: IRootState) => state.home)
2525
const { editpanel, selectedItem, confirmedit } = useSelector((state: IRootState) => state.scriptLinks)
26+
27+
// Add local state to store edits
28+
const [editItem, setEditItem] = useState<IScriptLink>()
29+
30+
// Update local state when selected item changes
31+
useEffect(() => {
32+
setEditItem(selectedItem)
33+
}, [selectedItem])
2634

2735
const panelOverlayProps: IOverlayProps = { isDarkThemed: isDark }
2836
const _onRenderItemFooterContent = () => {
2937
return (
3038
<PrimaryButton
31-
onClick={() => dispatch(setConfirmEditDialog(false))}
39+
onClick={() => {
40+
if (editItem) {
41+
dispatch(setSelectedItem(editItem))
42+
dispatch(setConfirmEditDialog(false))
43+
}
44+
}}
3245
style={{ marginRight: '8px' }}
3346
text={'Update'}
3447
/>
@@ -54,32 +67,30 @@ const ScriptLinksEditPanel = () => {
5467
onRenderFooterContent={_onRenderItemFooterContent}
5568
overlayProps={panelOverlayProps}
5669
>
57-
{selectedItem &&
70+
{selectedItem && editItem &&
5871
<Stack>
5972
<TextField
6073
label='Url'
6174
description='Url of the file to be injected.'
6275
multiline
6376
autoAdjustHeight
64-
value={selectedItem.Url}
77+
value={editItem.Url}
6578
onChange={(event, newValue?: string) =>
66-
dispatch(setSelectedItem({ ...selectedItem, Url: newValue ? newValue : '' }))
79+
setEditItem({ ...editItem, Url: newValue ? newValue : '' })
6780
}
6881
required
69-
// TODO: do proper validation
7082
/>
7183
<TextField
7284
label='Sequence'
7385
description='The sequence of the scriplink'
7486
styles={{ fieldGroup: { width: 100 } }}
75-
value={selectedItem.Sequence.toString()}
87+
value={editItem.Sequence.toString()}
7688
type={'number'}
7789
onChange={(event, newValue?: string) =>
78-
dispatch(setSelectedItem({ ...selectedItem, Sequence: newValue ? +newValue : selectedItem.Sequence }))
90+
setEditItem({ ...editItem, Sequence: newValue ? +newValue : editItem.Sequence })
7991
}
8092
onGetErrorMessage={sequenceValidator}
8193
required
82-
// TODO: do proper casting & validation
8394
/>
8495
<Dropdown
8596
placeholder='Select scope'
@@ -88,15 +99,15 @@ const ScriptLinksEditPanel = () => {
8899
{ key: 2, text: 'Site Collection' },
89100
{ key: 3, text: 'Current Web' },
90101
]}
91-
selectedKey={selectedItem.Scope}
102+
selectedKey={editItem.Scope}
92103
onChange={(event, option?: IDropdownOption) =>
93-
dispatch(setSelectedItem({ ...selectedItem, Scope: option ? +option.key : selectedItem.Scope }))
104+
setEditItem({ ...editItem, Scope: option ? +option.key : editItem.Scope })
94105
}
95106
/>
96107
<TextField
97108
label='Id'
98109
description='Id of the custom action'
99-
value={selectedItem.Id}
110+
value={editItem.Id}
100111
readOnly
101112
disabled
102113
/>
@@ -125,4 +136,4 @@ const ScriptLinksEditPanel = () => {
125136
)
126137
}
127138

128-
export default ScriptLinksEditPanel
139+
export default ScriptLinksEditPanel

src/pages/tenantproperties/components/editpanel.tsx

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
import React, { useEffect, useState } from 'react';
1515
import { useDispatch, useSelector } from 'react-redux';
1616
import { IRootState } from '../../../store';
17-
// mport { updateScriptLink } from '../../../store/scriptlinks/async-actions'
1817
import { setConfirmEditDialog, setEditPanel, setSelectedItem } from '../../../store/tenantproperties/actions';
1918
import { ITenantProperty } from '../../../store/tenantproperties/types';
2019
import { addTenantProperty } from '../chrome/chrome-actions';
@@ -24,17 +23,25 @@ const TenantPropertiesEditPanel = () => {
2423
const { isDark } = useSelector((state: IRootState) => state.home);
2524
const { editpanel, selectedItem, confirmedit } = useSelector((state: IRootState) => state.tenantProperties);
2625

27-
const [editItem, setEditItem] = useState<ITenantProperty>();
26+
const [editItem, setEditItem] = useState<ITenantProperty | undefined>();
2827

2928
useEffect(() => {
3029
setEditItem(selectedItem);
3130
}, [selectedItem]);
3231

3332
const panelOverlayProps: IOverlayProps = { isDarkThemed: isDark };
33+
34+
const handleSubmit = () => {
35+
if (editItem) {
36+
dispatch(setSelectedItem(editItem));
37+
dispatch(setConfirmEditDialog(false));
38+
}
39+
};
40+
3441
const _onRenderItemFooterContent = () => {
3542
return (
3643
<PrimaryButton
37-
onClick={() => dispatch(setConfirmEditDialog(false))}
44+
onClick={handleSubmit}
3845
style={{ marginRight: '8px' }}
3946
text={'Update'}
4047
disabled={!editItem?.value.length}
@@ -75,7 +82,9 @@ const TenantPropertiesEditPanel = () => {
7582
rows={5}
7683
autoAdjustHeight
7784
onChange={(event, newValue?: string) => {
78-
dispatch(setSelectedItem({ ...selectedItem, value: newValue ? newValue : '' }));
85+
if (editItem) {
86+
setEditItem({ ...editItem, value: newValue ? newValue : '' });
87+
}
7988
}}
8089
/>
8190
<TextField
@@ -86,7 +95,9 @@ const TenantPropertiesEditPanel = () => {
8695
rows={5}
8796
autoAdjustHeight
8897
onChange={(event, newValue?: string) => {
89-
dispatch(setSelectedItem({ ...selectedItem, description: newValue ? newValue : '' }));
98+
if (editItem) {
99+
setEditItem({ ...editItem, description: newValue ? newValue : '' });
100+
}
90101
}}
91102
/>
92103
<TextField
@@ -97,7 +108,9 @@ const TenantPropertiesEditPanel = () => {
97108
rows={5}
98109
autoAdjustHeight
99110
onChange={(event, newValue?: string) => {
100-
dispatch(setSelectedItem({ ...selectedItem, comment: newValue ? newValue : '' }));
111+
if (editItem) {
112+
setEditItem({ ...editItem, comment: newValue ? newValue : '' });
113+
}
101114
}}
102115
/>
103116
</Stack>
@@ -135,4 +148,4 @@ const TenantPropertiesEditPanel = () => {
135148
);
136149
};
137150

138-
export default TenantPropertiesEditPanel;
151+
export default TenantPropertiesEditPanel;

src/pages/webproperties/components/editpanel.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ const WebPropertiesEditPanel = () => {
3535
const _onRenderItemFooterContent = () => {
3636
return (
3737
<PrimaryButton
38-
onClick={() => dispatch(setConfirmEditDialog(false))}
38+
onClick={() => {
39+
if (editItem) {
40+
dispatch(setSelectedItem(editItem))
41+
dispatch(setConfirmEditDialog(false))
42+
}
43+
}}
3944
style={{ marginRight: '8px' }}
4045
text={'Update'}
4146
/>
@@ -58,34 +63,34 @@ const WebPropertiesEditPanel = () => {
5863
onRenderFooterContent={_onRenderItemFooterContent}
5964
overlayProps={panelOverlayProps}
6065
>
61-
{selectedItem &&
66+
{selectedItem && editItem &&
6267
<Stack>
6368
<TextField
6469
label='Property Key'
6570
description='The key of the property'
66-
value={editItem ? editItem.key : ''}
71+
value={editItem.key}
6772
readOnly
6873
disabled
6974
required
7075
/>
7176
<TextField
7277
label='Property Value'
7378
description='The value of the property'
74-
value={editItem ? editItem.value : ''}
79+
value={editItem.value}
7580
multiline
7681
rows={5}
7782
autoAdjustHeight
7883
onChange={(event, newValue?: string) => {
79-
dispatch(setSelectedItem({ ...selectedItem, value: newValue ? newValue : '' }))
84+
setEditItem({ ...editItem, value: newValue ? newValue : '' })
8085
}}
8186
/>
8287
<Toggle
8388
label='Indexed'
84-
checked={selectedItem.indexed}
89+
checked={editItem.indexed}
8590
onText='Yes'
8691
offText='No'
8792
onChange={(event, checked?: boolean) => {
88-
dispatch(setSelectedItem({ ...selectedItem, indexed: checked ? true : false }))
93+
setEditItem({ ...editItem, indexed: checked ? true : false })
8994
}}
9095
/>
9196

@@ -114,4 +119,4 @@ const WebPropertiesEditPanel = () => {
114119
)
115120
}
116121

117-
export default WebPropertiesEditPanel
122+
export default WebPropertiesEditPanel

0 commit comments

Comments
 (0)