Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#808 The 'Add selection to existing workspace' and ' New workspace from selection' do not stay enabled when you cancel the new workspace creation #856

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,16 @@ const RepositoryPageDetails = ({
checkedChanged,
user,
onAction,
resetChecked,
setResetChecked
}: {
repository: OSBRepository;
openRepoUrl: () => void;
checkedChanged: (checked: RepositoryResourceNode[]) => any;
user: UserInfo;
onAction: (r: OSBRepository) => void;
resetChecked: boolean;
setResetChecked: (value: boolean) => any;
}) => {
const [currentPath, setCurrentPath] = React.useState<
RepositoryResourceNode[]
Expand Down Expand Up @@ -182,6 +186,7 @@ const RepositoryPageDetails = ({
}
setChecked({ ...checked });
checkedChanged(Object.values(checked));
setResetChecked(false);
};

const addToCurrentPath = (n: RepositoryResourceNode) => {
Expand All @@ -192,8 +197,10 @@ const RepositoryPageDetails = ({
if (value) {
setChecked(resourcesListObject);
checkedChanged(resourcesList);
setResetChecked(false);
} else {
setChecked({});
checkedChanged([])
}
};

Expand All @@ -209,6 +216,12 @@ const RepositoryPageDetails = ({
setRepositoryEditorOpen(false);
};

React.useEffect(() => {
if(resetChecked){
setChecked({})
}
},[resetChecked])

return (
repository && (
<Box
Expand Down
5 changes: 5 additions & 0 deletions applications/osb-portal/src/pages/RepositoryPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export const RepositoryPage = (props: any) => {
const [workspaceLink, setWorkspaceLink] = React.useState(null);
const [error, setError] = React.useState<any>(null);
const [isLoading, setIsLoading] = React.useState<boolean>(false);
const [resetChecked, setResetChecked] = React.useState<boolean>(false);

const canEdit = canEditRepository(props.user, props.repository);
const [createdWorkspaceConfirmationContent, setCreatedWorkspaceConfirmationContent] = React.useState({
Expand All @@ -127,6 +128,7 @@ export const RepositoryPage = (props: any) => {
if (showWorkspaceEditor) {
setChecked([]);
setRefresh(!refresh);
setResetChecked(true);
}
};

Expand All @@ -135,6 +137,7 @@ export const RepositoryPage = (props: any) => {
if (showExistingWorkspaceEditor) {
setChecked([]);
setRefresh(!refresh);
setResetChecked(true);
}
};

Expand Down Expand Up @@ -401,6 +404,8 @@ export const RepositoryPage = (props: any) => {
r && setRepository({ ...repository, ...r })
}
user={user}
resetChecked={resetChecked}
setResetChecked={setResetChecked}
/>
</>
)}
Expand Down
Loading