Skip to content

Commit

Permalink
chore: show Clear instead of Cancel in scope picker with no proj
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Feb 10, 2025
1 parent 6598a19 commit 4746c02
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/js/components/Scope/ProjectScopePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const styles: Record<string, CSSProperties> = {
},
};

const ProjectScopePicker = () => {
const ProjectScopePicker = ({ onCancel }: { onCancel: () => void }) => {
const t = useTranslationFn();

const { projects, selectedScope } = useMetadata();
Expand Down Expand Up @@ -47,7 +47,14 @@ const ProjectScopePicker = () => {
tabPosition="left"
activeKey={selectedProject}
onChange={onTabChange}
tabBarExtraContent={<Button onClick={onProjectClear}>{t('Clear')}</Button>}
// If no project is selected, don't have "Clear" since we don't have anything to clear.
tabBarExtraContent={
scopeObj.project ? (
<Button onClick={onProjectClear}>{t('Clear')}</Button>
) : (
<Button onClick={onCancel}>{t('Cancel')}</Button>
)
}
items={tabItems}
style={styles.tabs}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/Scope/ScopePickerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const ScopePickerModal = ({ isModalOpen, setIsModalOpen }: ScopePickerModalProps
const closeModal = () => setIsModalOpen(false);
return (
<Modal title={t('Select Scope')} open={isModalOpen} onCancel={closeModal} footer={null} width={700}>
<ProjectScopePicker />
<ProjectScopePicker onCancel={closeModal} />
</Modal>
);
};
Expand Down

0 comments on commit 4746c02

Please sign in to comment.