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

feat: add "empty state" messages #284

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Changes from 1 commit
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
30 changes: 20 additions & 10 deletions src/commands/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,26 +169,36 @@ const list = async (props: CommonProps & { orgId?: string }) => {
return result;
};

const ownedProjects = getList(props.apiClient.listProjects);
const ownedProjects = await getList(props.apiClient.listProjects);
const sharedProjects = props.orgId
? undefined
: getList(props.apiClient.listSharedProjects);
? []
: await getList(props.apiClient.listSharedProjects);

const out = writer(props);

out.write(await ownedProjects, {
fields: PROJECT_FIELDS,
title: 'Projects',
});
if (ownedProjects.length) {
out.write(ownedProjects, {
fields: PROJECT_FIELDS,
title: 'Projects',
});
} else {
out.text(
"\n\nYou don't have any projects yet. See how to create a new project:\n",
);
out.text('> neonctl projects create --help\n\n');
}

if (sharedProjects) {
out.write(await sharedProjects, {
if (sharedProjects.length) {
out.write(sharedProjects, {
fields: PROJECT_FIELDS,
title: 'Shared with you',
});
}

out.end();

if (!sharedProjects.length && !props.orgId) {
out.text('\nNo projects have been shared with you\n');
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

out.write() and out.text() behave differently, causing a different output order. Perhaps we should come up with a better abstraction for printing text (especially, with formatting options)

Copy link
Member

Choose a reason for hiding this comment

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

I think we just need to update text method to push to same chunks array as write does

Copy link
Member

Choose a reason for hiding this comment

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

Do you want my help with fixing it's behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree!

Do you want my help with fixing it's behavior?

That should be straightforward, let me try first :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@duskpoet I think I figured out a better abstraction for adding optional messages to tables in case data is empty edf5a5c (#284)

What do you think?

};

const create = async (
Expand Down