CLASSROOMIO-T-29: Limit org to one
Co-authored-by: Rotimi Best <rotimiibitoyeemma@gmail.com> Merge-request: CLASSROOMIO-MR-4 Merged-by: Digdippa Team <digdippa@gmail.com>
This commit is contained in:
committed by
Space Cloud
co-authored by
Rotimi Best
parent
ae0462219b
commit
cfeaa17846
+2
-2
@@ -14,8 +14,8 @@ import pkg from './package.json';
|
|||||||
|
|
||||||
const mode = process.env.NODE_ENV;
|
const mode = process.env.NODE_ENV;
|
||||||
const dev = mode === 'development';
|
const dev = mode === 'development';
|
||||||
const sourcemap = dev ? false : 'inline';
|
// const sourcemap = dev ? false : 'inline';
|
||||||
// const sourcemap = 'inline';
|
const sourcemap = 'inline';
|
||||||
const legacy = !!process.env.SAPPER_LEGACY_BUILD;
|
const legacy = !!process.env.SAPPER_LEGACY_BUILD;
|
||||||
|
|
||||||
const onwarn = (warning, onwarn) => {
|
const onwarn = (warning, onwarn) => {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<p
|
<p
|
||||||
class="{className} {size === 'sm'
|
class="{className} {size === 'sm'
|
||||||
? 'py-1 px-1'
|
? 'py-1 px-1'
|
||||||
: 'py-2 px-2'} org-avatar bg-blue-200 font-bold rounded-md text-center"
|
: 'py-2 px-2'} org-avatar bg-gray-200 rounded-md text-center"
|
||||||
>
|
>
|
||||||
{value}
|
{value}
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
import AudienceIcon from '../../components/Icons/AudienceIcon.svelte';
|
import AudienceIcon from '../../components/Icons/AudienceIcon.svelte';
|
||||||
import { currentOrg } from '../../utils/store/org';
|
import { currentOrg } from '../../utils/store/org';
|
||||||
|
|
||||||
let orgName = '';
|
let orgSiteName = '';
|
||||||
let activeClass = 'bg-gray-200';
|
let activeClass = 'bg-gray-200';
|
||||||
let { page } = stores();
|
let { page } = stores();
|
||||||
|
|
||||||
@@ -26,55 +26,58 @@
|
|||||||
return pagePath.includes(itemPath);
|
return pagePath.includes(itemPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
$: orgName = $currentOrg.siteName;
|
$: orgSiteName = $currentOrg.siteName;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<aside class="root bg-gray-100 h-full">
|
<aside class="root bg-gray-100 h-full">
|
||||||
<div class="h-full flex flex-col">
|
<div class="h-full flex flex-col">
|
||||||
<div class="border-b border-gray-200 pt-5 px-4 ">
|
<div class="border-b border-gray-200 pt-5 px-4">
|
||||||
<TextChip value="DA" />
|
<TextChip
|
||||||
|
value={$currentOrg.shortName}
|
||||||
|
className="bg-blue-200 font-bold"
|
||||||
|
/>
|
||||||
|
|
||||||
<OrgSelector />
|
<OrgSelector />
|
||||||
|
|
||||||
<ul class="my-5">
|
<ul class="my-5">
|
||||||
<a href="/org/{orgName}" class="text-black">
|
<a href="/org/{orgSiteName}" class="text-black">
|
||||||
<li
|
<li
|
||||||
class="flex items-center py-3 px-4 mb-2 rounded hover:bg-gray-200 {isActive(
|
class="flex items-center py-3 px-4 mb-2 rounded hover:bg-gray-200 {isActive(
|
||||||
$page.path,
|
$page.path,
|
||||||
`/org/${orgName}`
|
`/org/${orgSiteName}`
|
||||||
) && activeClass}"
|
) && activeClass}"
|
||||||
>
|
>
|
||||||
<HomeIcon />
|
<HomeIcon />
|
||||||
<p class="ml-2">Home</p>
|
<p class="ml-2">Home</p>
|
||||||
</li>
|
</li>
|
||||||
</a>
|
</a>
|
||||||
<a href="/org/{orgName}/courses" class="text-black">
|
<a href="/org/{orgSiteName}/courses" class="text-black">
|
||||||
<li
|
<li
|
||||||
class="flex items-center py-3 px-4 mb-2 rounded hover:bg-gray-200 {isActive(
|
class="flex items-center py-3 px-4 mb-2 rounded hover:bg-gray-200 {isActive(
|
||||||
$page.path,
|
$page.path,
|
||||||
`/org/${orgName}/courses`
|
`/org/${orgSiteName}/courses`
|
||||||
) && activeClass}"
|
) && activeClass}"
|
||||||
>
|
>
|
||||||
<CourseIcon />
|
<CourseIcon />
|
||||||
<p class="ml-2">Courses</p>
|
<p class="ml-2">Courses</p>
|
||||||
</li>
|
</li>
|
||||||
</a>
|
</a>
|
||||||
<a href="/org/{orgName}/site" class="text-black">
|
<a href="/org/{orgSiteName}/site" class="text-black">
|
||||||
<li
|
<li
|
||||||
class="flex items-center py-3 px-4 mb-2 rounded hover:bg-gray-200 {isActive(
|
class="flex items-center py-3 px-4 mb-2 rounded hover:bg-gray-200 {isActive(
|
||||||
$page.path,
|
$page.path,
|
||||||
`/org/${orgName}/site`
|
`/org/${orgSiteName}/site`
|
||||||
) && activeClass}"
|
) && activeClass}"
|
||||||
>
|
>
|
||||||
<SiteSettingsIcon />
|
<SiteSettingsIcon />
|
||||||
<p class="ml-2">Site settings</p>
|
<p class="ml-2">Site settings</p>
|
||||||
</li>
|
</li>
|
||||||
</a>
|
</a>
|
||||||
<a href="/org/{orgName}/audience" class="text-black">
|
<a href="/org/{orgSiteName}/audience" class="text-black">
|
||||||
<li
|
<li
|
||||||
class="flex items-center py-3 px-4 mb-2 rounded hover:bg-gray-200 {isActive(
|
class="flex items-center py-3 px-4 mb-2 rounded hover:bg-gray-200 {isActive(
|
||||||
$page.path,
|
$page.path,
|
||||||
`/org/${orgName}/audience`
|
`/org/${orgSiteName}/audience`
|
||||||
) && activeClass}"
|
) && activeClass}"
|
||||||
>
|
>
|
||||||
<AudienceIcon />
|
<AudienceIcon />
|
||||||
@@ -84,18 +87,18 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<span class="flex-grow" />
|
<span class="flex-grow" />
|
||||||
<ul class="my-5 pb-5 px-4 ">
|
<ul class="my-5 pb-5 px-4">
|
||||||
<a href="/help" class="text-black">
|
<a href="/help" class="text-black">
|
||||||
<li class="flex items-center py-3 px-4 mb-2 rounded hover:bg-gray-200">
|
<li class="flex items-center py-3 px-4 mb-2 rounded hover:bg-gray-200">
|
||||||
<Help />
|
<Help />
|
||||||
<p class="ml-2">Help</p>
|
<p class="ml-2">Help</p>
|
||||||
</li>
|
</li>
|
||||||
</a>
|
</a>
|
||||||
<a href="/org/{orgName}/settings" class="text-black">
|
<a href="/org/{orgSiteName}/settings" class="text-black">
|
||||||
<li
|
<li
|
||||||
class="flex items-center py-3 px-4 mb-2 rounded hover:bg-gray-200 {isActive(
|
class="flex items-center py-3 px-4 mb-2 rounded hover:bg-gray-200 {isActive(
|
||||||
$page.path,
|
$page.path,
|
||||||
`/org/${orgName}/settings`
|
`/org/${orgSiteName}/settings`
|
||||||
) && activeClass}"
|
) && activeClass}"
|
||||||
>
|
>
|
||||||
<UserAvatar />
|
<UserAvatar />
|
||||||
|
|||||||
@@ -11,16 +11,21 @@
|
|||||||
import Modal from '../Modal/index.svelte';
|
import Modal from '../Modal/index.svelte';
|
||||||
import TextField from '../Form/TextField.svelte';
|
import TextField from '../Form/TextField.svelte';
|
||||||
import PrimaryButton from '../PrimaryButton/index.svelte';
|
import PrimaryButton from '../PrimaryButton/index.svelte';
|
||||||
|
import { currentOrg } from '../../utils/store/org';
|
||||||
|
|
||||||
let open = false;
|
let open = false;
|
||||||
let openAddOrg = false;
|
let openAddOrg = false;
|
||||||
let loading = false;
|
let loading = false;
|
||||||
let orgName = '';
|
let orgName = '';
|
||||||
|
|
||||||
|
const IS_FEATURE_ENABLED = false;
|
||||||
|
|
||||||
function handleAddOrg() {
|
function handleAddOrg() {
|
||||||
console.log('add org modal');
|
if (IS_FEATURE_ENABLED) {
|
||||||
open = false;
|
console.log('add org modal');
|
||||||
openAddOrg = true;
|
open = false;
|
||||||
|
openAddOrg = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createNewOrg() {}
|
function createNewOrg() {}
|
||||||
@@ -34,25 +39,22 @@
|
|||||||
open = !open;
|
open = !open;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<p class="text-lg font-bold">DigDippa</p>
|
<p class="text-lg font-bold">{$currentOrg.name}</p>
|
||||||
<CaretSortIcon class="ml-2" />
|
<CaretSortIcon class="ml-2" />
|
||||||
</div>
|
</div>
|
||||||
<Popover bind:open closeOnOutsideClick align="bottom-left">
|
<Popover bind:open closeOnOutsideClick align="bottom-left">
|
||||||
<OrgSelectorItem
|
<OrgSelectorItem
|
||||||
size="sm"
|
size="sm"
|
||||||
active={false}
|
active={true}
|
||||||
avatarText="DA"
|
avatarText={$currentOrg.shortName}
|
||||||
text="DigDippa"
|
text={$currentOrg.name}
|
||||||
hasDivider={true}
|
hasDivider={true}
|
||||||
/>
|
/>
|
||||||
<OrgSelectorItem
|
<OrgSelectorItem
|
||||||
size="sm"
|
text=" + Add Organization"
|
||||||
active={true}
|
onClick={handleAddOrg}
|
||||||
avatarText="PA"
|
disabled={!IS_FEATURE_ENABLED}
|
||||||
text="Pepsi Co"
|
|
||||||
hasDivider={true}
|
|
||||||
/>
|
/>
|
||||||
<OrgSelectorItem text=" + Add Organization" onClick={handleAddOrg} />
|
|
||||||
</Popover>
|
</Popover>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -7,21 +7,40 @@
|
|||||||
export let avatarText = '';
|
export let avatarText = '';
|
||||||
export let text = '';
|
export let text = '';
|
||||||
export let onClick;
|
export let onClick;
|
||||||
|
export let disabled = false;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<button
|
<div class="relative">
|
||||||
class="flex items-center w-60 py-2 px-3 {hasDivider &&
|
<button
|
||||||
'border-b border-gray-100'} {active && 'bg-blue-100'}"
|
class="{disabled &&
|
||||||
on:click={onClick}
|
'opacity-25'} flex items-center w-60 py-2 px-3 {hasDivider &&
|
||||||
>
|
'border-b border-gray-100'} {active && 'bg-blue-100'}"
|
||||||
{#if avatarText}
|
on:click={onClick}
|
||||||
<TextChip value={avatarText} className="mr-2" {size} />
|
>
|
||||||
|
{#if avatarText}
|
||||||
|
<TextChip
|
||||||
|
value={avatarText}
|
||||||
|
className="mr-2 bg-blue-200 font-bold"
|
||||||
|
{size}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
{text}
|
||||||
|
</button>
|
||||||
|
{#if disabled}
|
||||||
|
<div class="coming-soon">
|
||||||
|
<TextChip value="Coming soon" className="text-xs" />
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{text}
|
</div>
|
||||||
</button>
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
button {
|
button {
|
||||||
min-height: 56px;
|
min-height: 56px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.coming-soon {
|
||||||
|
position: absolute;
|
||||||
|
top: 5px;
|
||||||
|
right: 5px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -97,7 +97,10 @@
|
|||||||
// If user coming to login page, then
|
// If user coming to login page, then
|
||||||
if (_.isEmpty(orgRes.orgs)) {
|
if (_.isEmpty(orgRes.orgs)) {
|
||||||
goto(ROUTE.ONBOARDING);
|
goto(ROUTE.ONBOARDING);
|
||||||
} else if (['login', 'signup', 'onboarding'].includes(path)) {
|
} else if (
|
||||||
|
['login', 'signup', 'onboarding'].includes(path) ||
|
||||||
|
path === '' // for home page
|
||||||
|
) {
|
||||||
// By default redirect to first organization
|
// By default redirect to first organization
|
||||||
goto(`/org/${orgRes.currentOrg.siteName}`);
|
goto(`/org/${orgRes.currentOrg.siteName}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,10 +80,3 @@
|
|||||||
<Courses />
|
<Courses />
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<style>
|
|
||||||
.root {
|
|
||||||
width: 100%;
|
|
||||||
padding: 0 10px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ export async function getOrganizations(userId) {
|
|||||||
orgsArray.push({
|
orgsArray.push({
|
||||||
id: orgMember?.organization?.id,
|
id: orgMember?.organization?.id,
|
||||||
name: orgMember?.organization?.name,
|
name: orgMember?.organization?.name,
|
||||||
|
shortName:
|
||||||
|
orgMember?.organization?.name?.substring(0, 2)?.toUpperCase() || '',
|
||||||
siteName: orgMember?.organization?.siteName,
|
siteName: orgMember?.organization?.siteName,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
import { writable } from 'svelte/store';
|
import { writable } from 'svelte/store';
|
||||||
|
|
||||||
export const orgs = writable([]);
|
export const orgs = writable([]);
|
||||||
export const currentOrg = writable({});
|
export const currentOrg = writable({
|
||||||
|
id: '',
|
||||||
|
name: '',
|
||||||
|
shortName: '',
|
||||||
|
siteName: '',
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user