Skip to content

Commit c330fa3

Browse files
Updated home page sample button
1 parent be1a4c0 commit c330fa3

File tree

9 files changed

+81
-14
lines changed

9 files changed

+81
-14
lines changed

_firebase/firestore.rules

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ service cloud.firestore {
2323
&& (request.auth.token.email == resource.data.email
2424
|| request.auth.uid in get(/databases/$(database)/documents/workspaces/$(resource.data.workspaceUid)).data.collaborators)
2525

26+
// Allow all access to the demo workspace for read.
27+
allow read: if resource.data.workspaceUid == 'DWJWmHIdofurrJtu'
28+
2629
// Only allow delete if the user is referenced on the workspace document.
2730
allow delete: if request.auth != null
2831
&& request.auth.uid in get(/databases/$(database)/documents/workspaces/$(resource.data.workspaceUid)).data.collaborators
@@ -33,4 +36,4 @@ service cloud.firestore {
3336
&& request.auth.uid in get(/databases/$(database)/documents/workspaces/$(request.resource.data.workspaceUid)).data.collaborators
3437
}
3538
}
36-
}
39+
}

_firebase/storage.rules

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ service firebase.storage {
1313
// The ruleset for the source bucket.
1414
match /b/source.coderev.app/o {
1515
match /{workspaceUid}/{source} {
16+
// This workspace is designated as a demo.
17+
allow read: if (request.auth == null && workspaceUid == 'DWJWmHIdofurrJtu')
18+
|| request.auth != null
19+
1620
allow write: if request.auth != null
1721
&& request.auth.uid in firestore.get(/databases/(default)/documents/workspaces/$(workspaceUid)).data.collaborators
18-
19-
allow read: if request.auth != null
2022
}
2123
}
2224
}

web/components/workspace/WorkspaceCommentCard.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<QBtn
3636
size="sm"
3737
:icon="tabCornerDownRight"
38+
:disable="readonly"
3839
@click.stop="startingReply = true"
3940
rounded
4041
flat
@@ -46,7 +47,15 @@
4647
style="padding-left: 4px !important"
4748
side
4849
>
49-
<QBtn size="sm" :icon="tabDots" @click.stop rounded flat dense>
50+
<QBtn
51+
size="sm"
52+
:icon="tabDots"
53+
@click.stop
54+
:disable="readonly"
55+
rounded
56+
flat
57+
dense
58+
>
5059
<QMenu anchor="top right" self="top right" auto-close>
5160
<QList>
5261
<QItem v-close-popup clickable>
@@ -215,6 +224,7 @@ import { tabCornerDownRight } from "quasar-extras-svg-icons/tabler-icons-v2";
215224
216225
const props = defineProps<{
217226
comment: CommentChain;
227+
readonly: boolean;
218228
commentStates: Record<string, boolean>;
219229
}>();
220230

web/components/workspace/WorkspaceComments.vue

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@
1515
v-model="newComment"
1616
type="textarea"
1717
color="purple-4"
18-
:disable="!selection"
19-
:label="!selection ? 'Select a file and source lines to add comments' : undefined"
18+
:disable="!selection || readonly"
19+
:label="
20+
readonly
21+
? 'This is a readonly demo workspace'
22+
: !selection
23+
? 'Select a file and source lines to add comments'
24+
: undefined
25+
"
2026
:bg-color="dark ? 'grey-10' : 'purple-1'"
2127
@keydown.enter="addComment"
2228
outlined
@@ -44,7 +50,9 @@
4450
<QBtn
4551
color="accent"
4652
:icon="tabMessagePlus"
47-
:disable="newComment.trim().length === 0"
53+
:disable="
54+
newComment.trim().length === 0 || candidate.workspaceUid === demoWorkspaceId
55+
"
4856
@click="addComment()"
4957
/>
5058
</QItemSection>
@@ -83,7 +91,8 @@
8391
<WorkspaceCommentCard
8492
v-for="comment in filteredComments"
8593
:comment-states="commentCollapsed"
86-
:comment="comment"
94+
:comment
95+
:readonly
8796
@expand="commentCollapsed[comment.rootComment.uid] = false"
8897
@collapse="commentCollapsed[comment.rootComment.uid] = true"
8998
/>
@@ -122,9 +131,12 @@ import {
122131
import { QBtn, scroll } from "quasar";
123132
import { btnProps } from "../../utils/commonProps";
124133
import { modifier } from "~/composables/useCommandPalette";
134+
import { demoWorkspaceId } from "../../utils/environment";
125135
126136
const $q = useQuasar();
127137
138+
const $route = useRoute();
139+
128140
const { getScrollTarget, setVerticalScrollPosition } = scroll;
129141
130142
const topBtn = ref<QBtn>();
@@ -145,6 +157,15 @@ const commentCollapsed = reactive<Record<string, boolean>>({});
145157
146158
const showBackToTop = ref(false);
147159
160+
/**
161+
* Readonly for the demo workspace except in edit mode.
162+
*/
163+
const readonly = computed(
164+
() =>
165+
candidate.value.workspaceUid === demoWorkspaceId &&
166+
$route.path !== `/workspace/${demoWorkspaceId}/c/${demoCandidateId}`
167+
);
168+
148169
const comments = computed<CommentChain[]>(() => {
149170
const replies: Record<string, ReviewComment[]> = {};
150171

web/components/workspace/WorkspaceFilesPanel.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ async function handleChangeName(name: string) {
739739
workspace.value.sources[file.hash].title = newNameWithExt;
740740
} else {
741741
// Update a new file that hasn't been saved yet.
742-
selectedSourceFile.value.name = name;
742+
selectedSourceFile.value.name = `${name}${file.ext}`;
743743
}
744744
}
745745

web/middleware/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
44

55
const { user } = useAppStore()
66

7-
if (!user) {
7+
if (!user && to.path !== `/review/${demoCandidateId}`) {
88
console.log(" 🔑 No user present; redirecting to login.")
99

1010
return { name: 'login', query: {redirect: to.fullPath}}

web/pages/index.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
to="/login"
1616
label="Get started (it's free!)"
1717
class="q-mt-sm"
18+
:class="{ 'full-width': $q.screen.lt.sm }"
1819
size="xl"
1920
color="accent"
2021
/>
2122
<QBtn
2223
v-bind="btnProps"
23-
:icon="tabBrandGithub"
24+
:icon-right="tabBrandGithub"
2425
@click="
2526
navigateTo('https://github.com/CharlieDigital/coderev', {
2627
external: true,
@@ -29,10 +30,23 @@
2930
"
3031
label="View repo"
3132
class="q-mt-sm q-ml-md"
33+
:class="{ 'full-width': $q.screen.lt.sm }"
3234
size="xl"
3335
:color="dark ? 'grey-6' : 'accent'"
3436
outline
3537
/>
38+
<br />
39+
<QBtn
40+
v-bind="btnProps"
41+
href="https://coderev.app/review/wN0zcH1PNnXeVJWW"
42+
label="See sample candidate workspace"
43+
class="q-mt-sm"
44+
:icon-right="tabExternalLink"
45+
:class="{ 'full-width': $q.screen.lt.sm }"
46+
size="xl"
47+
color="accent"
48+
flat
49+
/>
3650
</div>
3751
</div>
3852
</section>

web/utils/data/FirebaseConnector.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,19 @@ class FirebaseConnector {
157157
}
158158

159159
const params = new URLSearchParams(window.location.search);
160-
const redirect = params.get("redirect") ?? "/home";
161160

162-
console.log(` 🔐 Redirect: ${redirect}`);
161+
// Check if there is a redirect and if the user is NOT on the /login page
162+
// Then we keep the user on that page without redirecting.
163+
if (!params.has("redirect") && !window.location.href.includes("/login")) {
164+
return;
165+
}
166+
167+
const redirect = params.get("redirect") ?? "/home";
163168

164169
const target = `${baseUrl}${redirect}`;
165170

171+
console.log(` 🔐 Redirect: ${redirect}, target: ${target}, location: ${window.location.href}`);
172+
166173
// Only redirect if we're not already on the page and it's not the landing page
167174
if (target !== window.location.href) {
168175
console.log(` 🔐 Redirecting user to ${redirect}`);

web/utils/environment.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,14 @@
44
*/
55
export const baseUrl = import.meta.env.DEV
66
? "http://localhost:3000"
7-
: import.meta.env.VITE_PUBLISHED_BASE_URL
7+
: import.meta.env.VITE_PUBLISHED_BASE_URL
8+
9+
/**
10+
* The ID of the demo workspace.
11+
*/
12+
export const demoWorkspaceId = "DWJWmHIdofurrJtu"
13+
14+
/**
15+
* ID of a designated demo candidate.
16+
*/
17+
export const demoCandidateId = "wN0zcH1PNnXeVJWW"

0 commit comments

Comments
 (0)