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

PRO-5940: working PoC of distinct guest admin bar experience #55

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

boutell
Copy link
Member

@boutell boutell commented Apr 26, 2024

Demonstrates how to distinguish the guest admin bar experience e.g. just show a logout button with custom (in this case very minimal) markup.

PoC only, do not merge.

@@ -0,0 +1,153 @@
<template>
<div
Copy link
Member Author

@boutell boutell Apr 26, 2024

Choose a reason for hiding this comment

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

Conditionally emit different markup when the user is a guest.

>
<button @click="logout">Log Out</button>
</div>
<div v-else
Copy link
Member Author

Choose a reason for hiding this comment

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

The HTML from here down is unmodified. There are a few changes separately called out in the script section.

moduleOptions() {
return window.apos.adminBar;
},
guest() {
Copy link
Member Author

Choose a reason for hiding this comment

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

Exposes the fact that the user is a guest. See also the getBrowserData extension below.

}
},
mounted() {
if (!this.guest) {
Copy link
Member Author

Choose a reason for hiding this comment

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

The last change in this file: don't invoke a method that manipulates markup we won't have for guests.

getBrowserData(_super, req) {
const data = _super(req);
if (data.user) {
data.user.role = req.user.role;
Copy link
Member Author

Choose a reason for hiding this comment

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

We don't expose the logged-in user's role on the front end by default, so add that information.

@@ -0,0 +1,153 @@
<template>
Copy link
Member Author

Choose a reason for hiding this comment

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

99% of this file is directly copied from the original in the apostrophe module, see below for the changes.

Copy link
Member Author

Choose a reason for hiding this comment

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

You could place this file in any module, as long as it is in the ui/apos/components subdirectory of that module. I chose the project-level modules/@apostrophecms/admin-bar folder to make it easier to find this override later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant