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

add workspace count to export prompts #6657

Merged
merged 1 commit into from
Oct 6, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { isScratchpadOrganizationId } from '../../../models/organization';
import { isScratchpad } from '../../../models/workspace';
import { SegmentEvent } from '../../analytics';
import { ProjectLoaderData } from '../../routes/project';
import { useRootLoaderData } from '../../routes/root';
import { WorkspaceLoaderData } from '../../routes/workspace';
import { Dropdown, DropdownButton, DropdownItem, DropdownSection, ItemContent } from '../base/dropdown';
import { Link } from '../base/link';
Expand All @@ -35,7 +36,7 @@ export const ImportExport: FC<Props> = ({ hideSettingsModal }) => {
const workspaceData = useRouteLoaderData(':workspaceId') as WorkspaceLoaderData | undefined;
const activeWorkspaceName = workspaceData?.activeWorkspace.name;
const projectName = workspaceData?.activeProject.name ?? getProductName();

const { workspaceCount } = useRootLoaderData();
const workspacesFetcher = useFetcher();
useEffect(() => {
const isIdleAndUninitialized = workspacesFetcher.state === 'idle' && !workspacesFetcher.data;
Expand Down Expand Up @@ -145,7 +146,7 @@ export const ImportExport: FC<Props> = ({ hideSettingsModal }) => {
className="px-4 py-1 font-semibold border border-solid border-[--hl-md] flex items-center justify-center gap-2 aria-pressed:bg-[--hl-sm] rounded-sm text-[--color-font] hover:bg-[--hl-xs] focus:ring-inset ring-1 ring-transparent focus:ring-[--hl-md] transition-all text-base"
>
<Icon icon="file-export" />
<span>Export all data</span>
<span>Export all data {`(${workspaceCount} files)`}</span>
</Button>
<Button
style={{
Expand Down
7 changes: 5 additions & 2 deletions packages/insomnia/src/ui/routes/auth.login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { SegmentEvent } from '../analytics';
import { getLoginUrl } from '../auth-session-provider';
import { Icon } from '../components/icon';
import { showAlert } from '../components/modals';
import { useRootLoaderData } from './root';

const GoogleIcon = (props: React.ReactSVGElement['props']) => {
return (
Expand Down Expand Up @@ -67,6 +68,8 @@ const Login = () => {
const [isMigrationModalOpen, setIsMigrationModalOpen] = useState(false);
const [selectedProvider, setSelectedProvider] = useState('email');
const navigate = useNavigate();
const { workspaceCount } = useRootLoaderData();

const login = (provider: string) => {
if (data.hasProjectsToMigrate) {
setIsMigrationModalOpen(true);
Expand Down Expand Up @@ -289,7 +292,7 @@ const Login = () => {
className="px-4 py-1 font-semibold border border-solid border-[--hl-md] flex items-center justify-center gap-2 aria-pressed:bg-[--hl-sm] rounded-sm text-[--color-font] hover:bg-[--hl-xs] focus:ring-inset ring-1 ring-transparent focus:ring-[--hl-md] transition-all text-base"
>
<Icon icon="file-export" />
<span>Export all data</span>
<span>Export all data {`(${workspaceCount} files)`}</span>
</Button>
</div>
)}
Expand Down Expand Up @@ -542,7 +545,7 @@ const Login = () => {
});
}}
className='focus:text-[--color-font] hover:text-[--color-font] font-bold transition-colors'
> export your data </Button> for portability.
> export your data </Button> for portability. {`(${workspaceCount} files)`}
</p>
</div>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { SegmentEvent } from '../analytics';
import { InsomniaLogo } from '../components/insomnia-icon';
import { showAlert } from '../components/modals';
import { TrailLinesContainer } from '../components/trail-lines-container';
import { useRootLoaderData } from './root';

export const action: ActionFunction = async () => {
await logout();
Expand All @@ -26,6 +27,7 @@ export const loader: LoaderFunction = async () => {

export const OnboardingCloudMigration = () => {
const { Form, state } = useFetcher();
const { workspaceCount } = useRootLoaderData();
return (
<div className='relative h-full w-full text-left text-base flex bg-[--color-bg]'>
<TrailLinesContainer>
Expand Down Expand Up @@ -263,7 +265,7 @@ export const OnboardingCloudMigration = () => {
});
}}
className='focus:text-[--color-font] hover:text-[--color-font] font-bold transition-colors'
> export your data </Button> for portability.
> export your data </Button> for portability. {`(${workspaceCount} files)`}
</p>
</div>
<button disabled={state !== 'idle'} className='hover:no-underline font-bold bg-[#4000BF] text-sm hover:bg-opacity-90 py-2 px-3 text-[--color-font] transition-colors rounded-sm'>
Expand Down
8 changes: 6 additions & 2 deletions packages/insomnia/src/ui/routes/organization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { MergeConflict } from '../../sync/types';
import { shouldRunMigration } from '../../sync/vcs/migrate-to-cloud-projects';
import { getVCS, initVCS } from '../../sync/vcs/vcs';
import { invariant } from '../../utils/invariant';
import { SegmentEvent } from '../analytics';
import { getLoginUrl } from '../auth-session-provider';
import { Avatar } from '../components/avatar';
import { GitHubStarsButton } from '../components/github-stars-button';
Expand Down Expand Up @@ -639,7 +640,7 @@ const OrganizationRoute = () => {
/>{' '}
{user
? status.charAt(0).toUpperCase() + status.slice(1)
: `Log in to sync your data (${workspaceCount} files)`}
: 'Log in to sync your data'}
</Button>
<Tooltip
placement="top"
Expand Down Expand Up @@ -686,12 +687,15 @@ const OrganizationRoute = () => {
title: 'Export Complete',
message: 'All your data have been successfully exported',
});
window.main.trackSegmentEvent({
event: SegmentEvent.exportAllCollections,
});
}}
>
<Icon
icon="file-export"
/>
Export your data
Export your data {`(${workspaceCount} files)`}
</Button>
) : null}
</div>
Expand Down