Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
feat(contexts): Add contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuir authored and joshuawilson committed Mar 7, 2017
1 parent f806f0e commit 9d07481
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 1 deletion.
6 changes: 6 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
export { ContextType } from './src/app/contexts/context-type';
export { Context } from './src/app/contexts/context';
export { Contexts } from './src/app/contexts/contexts';
export { ContextTypes } from './src/app/contexts/context-types';
export { WIT_API_URL } from './src/app/api/wit-api';
export { ProcessTemplate } from './src/app/models/process-template';
export { Space, SpaceAttributes } from './src/app/models/space';
export { Team } from './src/app/models/team';
export { SpaceService } from './src/app/spaces/space.service';
export { Spaces } from './src/app/spaces/spaces';

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@
"gulp-uglify": "2.0.1",
"cz-conventional-changelog": "2.0.0",
"css-loader": "0.26.2",
"css-to-string-loader": "0.1.2",
"del": "2.2.2",
"exports-loader": "0.6.4",
"expose-loader": "0.7.3",
Expand Down
4 changes: 4 additions & 0 deletions src/app/contexts/context-type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface ContextType {
name: string;
icon?: string;
}
35 changes: 35 additions & 0 deletions src/app/contexts/context-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { ContextType } from './context-type';
export class ContextTypes {

static readonly BUILTIN: Map<string, ContextType> = new Map<string, ContextType>([
[
'user',
{
name: 'User',
icon: 'fa fa-user',
} as ContextType
],
[
'space',
{
name: 'Space',
icon: 'fa fa-space-shuttle',
} as ContextType
],
[
'team',
{
name: 'Team',
icon: 'fa fa-users'
} as ContextType
],
[
'organization',
{
name: 'Organization',
icon: 'fa fa-cubes'
} as ContextType
]
]);

}
14 changes: 14 additions & 0 deletions src/app/contexts/context.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Team } from './../models/team';
import { Space } from './../models/space';
import { User } from 'ngx-login-client';
import { ContextType } from './context-type';

export interface Context {
// The entity that this context is for
user: User;
space?: Space;
team?: Team;
type: ContextType;
path: string;
name: string;
}
24 changes: 24 additions & 0 deletions src/app/contexts/contexts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Context } from './context';
import { Observable } from 'rxjs';
export interface Contexts {
/**
* An observable which pushes changes to the array of recent contexts.
* It is backed by a multicasted replay subject so you will always received
* the latest value, regardless of when you subscribe.
*/
recent: Observable<Context[]>;

/**
* An observable which pushes changes to the current context.
* It is backed by a multicasted replay subject so you will always received
* the latest value, regardless of when you subscribe.
*/
current: Observable<Context>;

/**
* An observable which pushes changes to the default context
* It is backed by a multicasted replay subject so you will always received
* the latest value, regardless of when you subscribe.
*/
default: Observable<Context>;
}
11 changes: 11 additions & 0 deletions src/app/spaces/spaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Space } from './../models/space';
import { Observable } from 'rxjs';
export interface Spaces {

/**
* An observable which pushes changes to the current space.
* It is backed by a multicasted replay subject so you will always received
* the latest value, regardless of when you subscribe.
*/
current: Observable<Space>;
}

0 comments on commit 9d07481

Please sign in to comment.