Skip to content

Commit

Permalink
Fixed the bugs with secret overrides and the sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
vmatsiiako committed Dec 27, 2022
1 parent 4c43bda commit 876c5f5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
1 change: 0 additions & 1 deletion frontend/components/basic/Toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export default function Toggle ({
id
])
} else {
setSharedToHide(sharedToHide!.filter(tempId => tempId != id))
deleteOverride(id);
}
setEnabled(!enabled);
Expand Down
24 changes: 12 additions & 12 deletions frontend/components/dashboard/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ const SideBar = ({
<DashboardInputField
onChangeHandler={modifyKey}
type="varName"
position={data[0].pos}
value={data[0].key}
position={data[0]?.pos}
value={data[0]?.key}
isDuplicate={false}
blurred={false}
/>
Expand Down Expand Up @@ -116,11 +116,11 @@ const SideBar = ({
enabled={overrideEnabled}
setEnabled={setOverrideEnabled}
addOverride={addOverride}
keyName={data[0].key}
value={data[0].value}
pos={data[0].pos}
id={data[0].id}
comment={data[0].comment}
keyName={data[0]?.key}
value={data[0]?.value}
pos={data[0]?.pos}
id={data[0]?.id}
comment={data[0]?.comment}
deleteOverride={deleteOverride}
sharedToHide={sharedToHide}
setSharedToHide={setSharedToHide}
Expand All @@ -130,13 +130,13 @@ const SideBar = ({
<DashboardInputField
onChangeHandler={modifyValue}
type="value"
position={overrideEnabled ? data.filter(secret => secret.type == "personal")[0].pos : data[0].pos}
value={overrideEnabled ? data.filter(secret => secret.type == "personal")[0].value : data[0].value}
position={overrideEnabled ? data.filter(secret => secret.type == "personal")[0]?.pos : data[0]?.pos}
value={overrideEnabled ? data.filter(secret => secret.type == "personal")[0]?.value : data[0]?.value}
isDuplicate={false}
blurred={true}
/>
<div className='absolute right-[0.57rem] top-[0.3rem] z-50'>
<GenerateSecretMenu modifyValue={modifyValue} position={overrideEnabled ? data.filter(secret => secret.type == "personal")[0].pos : data[0].pos} />
<GenerateSecretMenu modifyValue={modifyValue} position={overrideEnabled ? data.filter(secret => secret.type == "personal")[0]?.pos : data[0]?.pos} />
</div>
</div>
</div>
Expand All @@ -149,8 +149,8 @@ const SideBar = ({
isFull={true}
/>
</div> */}
<SecretVersionList secretId={data[0].id} />
<CommentField comment={data.filter(secret => secret.type == "shared")[0]?.comment} modifyComment={modifyComment} position={data[0].pos} />
<SecretVersionList secretId={data[0]?.id} />
<CommentField comment={data.filter(secret => secret.type == "shared")[0]?.comment} modifyComment={modifyComment} position={data[0]?.pos} />
</div>
<div className={`flex justify-start max-w-sm mt-4 px-4 mt-full mb-[4.7rem]`}>
<Button
Expand Down
11 changes: 10 additions & 1 deletion frontend/pages/dashboard/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,15 @@ export default function Dashboard() {
*/
const deleteOverride = (id: string) => {
setButtonReady(true);

// find which shared secret corresponds to the overriden version
const sharedVersionOfOverride = data!.filter(secret => secret.type == "shared" && secret.key == data!.filter(row => row.id == id)[0]?.key)[0]?.id;

// change the sidebar to this shared secret; and unhide it
toggleSidebar(sharedVersionOfOverride)
setSharedToHide(sharedToHide!.filter(tempId => tempId != sharedVersionOfOverride))

// resort secrets
const tempData = data!.filter((row: SecretDataProps) => !(row.id == id && row.type == 'personal'))
sortValuesHandler(tempData, sortMethod == "alhpabetical" ? "-alphabetical" : "alphabetical")
};
Expand Down Expand Up @@ -419,7 +428,7 @@ export default function Dashboard() {
<div className="flex flex-row">
{sidebarSecretId != "None" && <SideBar
toggleSidebar={toggleSidebar}
data={data.filter((row: SecretDataProps) => row.id == sidebarSecretId)}
data={data.filter((row: SecretDataProps) => row.key == data.filter(row => row.id == sidebarSecretId)[0]?.key)}
modifyKey={listenChangeKey}
modifyValue={listenChangeValue}
modifyComment={listenChangeComment}
Expand Down

3 comments on commit 876c5f5

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report for backend

St.
Category Percentage Covered / Total
🟡 Statements 70.15% 47/67
🔴 Branches 0% 0/5
🔴 Functions 50% 1/2
🟡 Lines 71.21% 47/66

Test suite run success

1 tests passing in 1 suite.

Report generated by 🧪jest coverage report action from 876c5f5

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report for backend

St.
Category Percentage Covered / Total
🟡 Statements 70.15% 47/67
🔴 Branches 0% 0/5
🔴 Functions 50% 1/2
🟡 Lines 71.21% 47/66

Test suite run success

1 tests passing in 1 suite.

Report generated by 🧪jest coverage report action from 876c5f5

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report for backend

St.
Category Percentage Covered / Total
🟡 Statements 70.15% 47/67
🔴 Branches 0% 0/5
🔴 Functions 50% 1/2
🟡 Lines 71.21% 47/66

Test suite run success

1 tests passing in 1 suite.

Report generated by 🧪jest coverage report action from 876c5f5

Please sign in to comment.