Skip to content

Commit

Permalink
Merged with master
Browse files Browse the repository at this point in the history
  • Loading branch information
OAGr committed Apr 23, 2019
2 parents 625bcc8 + 98eb397 commit 2172586
Show file tree
Hide file tree
Showing 41 changed files with 1,096 additions and 352 deletions.
Binary file modified .DS_Store
Binary file not shown.
18 changes: 9 additions & 9 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"parcel": "API_URL=${API_URL:-http://localhost:4000/graphql} AUTH0_DOMAIN=${AUTH0_DOMAIN:-guesstimate.auth0.com} AUTH0_CLIENT_ID=${AUTH0_CLIENT_ID:-gn1bwgJfK5Y6jfL6x7t6fB43ZAN3eSnT} parcel ./src/index.html --public-url /",
"parcel-staging": "parcel ./src/index.html --public-url /",
"parcel-production": "parcel ./src/index.html --public-url /",
"build": "parcel build ./src/index.html",
"build": "parcel build ./src/index.html --no-source-maps",
"serve": "static-server ./dist -p ${PORT} -d",
"build-t": "npm run clean && npm run build-bsb && npm run build",
"test": "jest --ci --bail --no-cache",
Expand All @@ -29,11 +29,11 @@
"@ncthbrt/re-secure-random-string": "^2.0.0",
"apollo-cache-inmemory": "^1.2.9",
"apollo-client": "^2.4.1",
"apollo-link": "^1.2.2",
"apollo-link-context": "^1.0.8",
"apollo-link-error": "^1.1.0",
"apollo-link-http": "^1.5.4",
"apollo-link-ws": "^1.0.8",
"apollo-link": "^1.2.11",
"apollo-link-context": "^1.0.17",
"apollo-link-error": "^1.1.10",
"apollo-link-http": "^1.5.14",
"apollo-link-ws": "^1.0.17",
"apollo-utilities": "^1.0.20",
"auth0-js": "^9.7.3",
"bs-ant-design": "git+https://[email protected]/Thinkei/bs-ant-design.git",
Expand All @@ -56,8 +56,8 @@
"react-apollo": "^2.1.11",
"react-dom": "^16.2.0",
"react-icons-kit": "^1.2.1",
"reason-apollo": "^0.13.0",
"reason-react": ">=0.4.0",
"reason-apollo": "^0.15.0",
"reason-react": "^0.7.0",
"static-server": "^2.2.1",
"subscriptions-transport-ws": "^0.9.14",
"victory": "^32.2.0",
Expand All @@ -72,7 +72,7 @@
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"babel-runtime": "^6.26.0",
"bs-platform": "^4.0.7",
"bs-platform": "^5.0.0",
"bsb-js": "^1.1.7",
"css-loader": "^2.1.1",
"file-loader": "^2.0.0",
Expand Down
2 changes: 2 additions & 0 deletions client/src/E.re
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ module L = {
let toArray = Array.of_list;
let fmapi = List.mapi;
let concat = List.concat;
let append = List.append;
let find = List.find;
let filter = List.filter;
let for_all = List.for_all;
Expand Down Expand Up @@ -148,6 +149,7 @@ module A = {
let to_list = Array.to_list;
let of_list = Array.of_list;
let length = Array.length;
let append = Array.append;
let empty = [||];
let unsafe_get = Array.unsafe_get;
let get = Belt.Array.get;
Expand Down
14 changes: 14 additions & 0 deletions client/src/EKen.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Thing = {
type t = Graph_T.T.thing;
let getName = (t: t) =>
t |> Graph_T.Thing.id |> C.Ken.findName |> E.O.default("");
let getInstanceOfName = (t: t) =>
t |> Graph_T.Thing.id |> C.Ken.findInstanceOfName |> E.O.default("");
let hasName = (t: t) => getName(t) != "";
};

module Things = {
type t = array(Thing.t);
let getAll = C.Ken.things;
let withNames = E.A.filter(Thing.hasName);
};
3 changes: 1 addition & 2 deletions client/src/components/Foretold__Components__Channel.re
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module SimpleHeader = {
open Css;
let header =
style([
borderBottom(`px(1), `solid, `hex("eee")),
paddingLeft(`px(10)),
paddingBottom(`em(0.8)),
paddingRight(`em(0.4)),
Expand All @@ -24,7 +23,7 @@ module SimpleHeader = {
</Div>;

let newMeasurable = channelId =>
buttonr("New Measurable", MeasurableNew(channelId));
buttonr("New Question", MeasurableNew(channelId));

let editChannel = channelId =>
buttonr("Edit Channel", ChannelEdit(channelId));
Expand Down
14 changes: 14 additions & 0 deletions client/src/components/Foretold__Components__Ken.re
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ let findName = propertyId =>
}
);

let findInstanceOfName = propertyId =>
graph
|> Graph_T.F.factList
|> Graph_Fact_Filters.withSubject(propertyId)
|> Graph_Fact_Filters.withProperty("@base/properties/p-instance-of")
|> E.L.head
|> E.O.bind(_, (k: Graph_T.T.fact) =>
switch (k.value.valueType) {
| String(s) => Some(s)
| ThingId(s) => findName(s)
| _ => None
}
);

let names = subjectId =>
graph
|> Graph_T.F.factList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ let make = (~id: string, ~loggedInUser: Context.Primary.User.t, _children) => {
let creatorId =
m.creator |> E.O.fmap((r: Context.Primary.Agent.t) => r.id);
<>
{"Add a Measurement" |> ste |> E.React.inH2}
{"Add a Prediction" |> ste |> E.React.inH2}
<Foretold__Components__Measurement__Form
measurableId=id
isCreator={userAgentId == creatorId}
/>
</>;
}
{"Measurements" |> ste |> E.React.inH2}
{"Predictions" |> ste |> E.React.inH2}
{
m.measurements
|> E.O.React.fmapOrNull(
Expand Down
17 changes: 9 additions & 8 deletions client/src/components/Foretold__Components__Measurable__Items.re
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,18 @@ let resolutionEndpoint = (~m: measurable) =>
};

let archiveButton = (~m: measurable) =>
Foretold__GraphQL.Mutations.MeasurableUnarchive.Mutation.make((mutation, _) =>
Foretold__GraphQL.Mutations.MeasurableArchive.Mutation.make((mutation, _) =>
<div className=Shared.Item.item>
<div
className={Shared.Item.itemButton(DANGER)}
onClick={
_ =>
Foretold__GraphQL.Mutations.MeasurableUnarchive.mutate(
e => {
Foretold__GraphQL.Mutations.MeasurableArchive.mutate(
mutation,
m.id,
)
);
ReactEvent.Synthetic.preventDefault(e);
}
}>
{"Archive" |> ste}
</div>
Expand All @@ -191,13 +193,13 @@ let archiveButton = (~m: measurable) =>
|> E.React.el;

let unArchiveButton = (~m: measurable) =>
Foretold__GraphQL.Mutations.MeasurableArchive.Mutation.make((mutation, _) =>
Foretold__GraphQL.Mutations.MeasurableUnarchive.Mutation.make((mutation, _) =>
<div className=Shared.Item.item>
<div
className={Shared.Item.itemButton(DANGER)}
onClick={
_ =>
Foretold__GraphQL.Mutations.MeasurableArchive.mutate(
Foretold__GraphQL.Mutations.MeasurableUnarchive.mutate(
mutation,
m.id,
)
Expand All @@ -209,5 +211,4 @@ let unArchiveButton = (~m: measurable) =>
|> E.React.el;

let archiveOption = (~m: measurable) =>
Measurable.toStatus(m) !== `ARCHIVED ?
archiveButton(~m) : unArchiveButton(~m);
m.isArchived == Some(true) ? unArchiveButton(~m) : archiveButton(~m);
2 changes: 1 addition & 1 deletion client/src/components/Foretold__Components__Shared.re
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Item = {
color(`hex("bbb")),
selector(
" a",
[color(`hex("777")), selector(":hover", [color(hex("333"))])],
[color(`hex("aaa")), selector(":hover", [color(hex("333"))])],
),
]);

Expand Down
64 changes: 37 additions & 27 deletions client/src/components/SLayout.re
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ module Styles = {
open Css;
let header =
style([
borderBottom(`px(1), `solid, `hex("eee")),
paddingLeft(`px(10)),
paddingLeft(`em(1.)),
paddingBottom(`em(0.8)),
paddingRight(`em(0.4)),
paddingTop(`px(10)),
paddingRight(`em(1.)),
paddingTop(`em(1.5)),
float(`left),
width(`percent(100.)),
]);
let headerText =
style([
color(`hex("333")),
fontSize(`em(2.0)),
color(`hex("486474")),
fontSize(`em(1.8)),
fontWeight(`bold),
float(`left),
]);
Expand All @@ -28,30 +27,24 @@ module Styles = {
float(`left),
fontWeight(`medium),
]);
let backHover =
style([
color(`hex("8b949e")),
background(`hex("e2e8ea")),
fontSize(`em(1.3)),
float(`left),
padding(`px(6)),
lineHeight(`px(0)),
borderRadius(`percent(50.)),
marginRight(`em(0.7)),
marginTop(`em(0.3)),
cursor(`pointer),
selector(
":hover",
[color(`hex("445b7d")), background(`hex("c2cbd4"))],
),
]);
let container = style([maxWidth(`px(1170)), margin(`auto)]);
let backHover = style([fontSize(`em(1.3))]);
let foo =
style([
color(`hex("333")),
fontSize(`em(2.0)),
fontWeight(`bold),
float(`left),
]);
let largeCardOuter = style([padding(`em(0.3))]);
let largeCardInner =
style([
background(`hex("fff")),
borderRadius(`px(5)),
padding(`em(1.)),
width(`percent(100.)),
float(`left),
]);
let mainSection =
style([
float(`left),
Expand All @@ -71,6 +64,16 @@ module Styles = {
]);
};

module LargeCard = {
let component = ReasonReact.statelessComponent("LargeCard");
let make = children => {
...component,
render: _ =>
<div className=Styles.largeCardOuter>
<div className=Styles.largeCardInner> ...children </div>
</div>,
};
};
module Header = {
let component = ReasonReact.statelessComponent("Header");
let textDiv = text => <div className=Styles.headerText> {text |> ste} </div>;
Expand All @@ -85,7 +88,10 @@ module MainSection = {
let component = ReasonReact.statelessComponent("MainSection");
let make = children => {
...component,
render: _ => <div className=Styles.mainSection> ...children </div>,
render: _ =>
<div className=Styles.mainSection>
<LargeCard> ...children </LargeCard>
</div>,
};
};

Expand All @@ -102,15 +108,19 @@ module FullPage = {
let make = ({head, body}: LayoutConfig.t) => {
...component,
render: _ =>
<> <Header> head </Header> <MainSection> body </MainSection> </>,
<div className=Styles.container>
<Header> head </Header>
<MainSection> body </MainSection>
</div>,
};
let makeWithEl = (t: LayoutConfig.t) => t |> make |> E.React.el;
};

let channelBack = (~onClick, ()) =>
<div className=Styles.backHover onClick>
<Antd.Button onClick className=Styles.backHover>
<Icon.Icon icon="ARROW_LEFT" />
</div>;
{"Back" |> ste}
</Antd.Button>;

let channelink = (c: Context.Primary.Channel.t) =>
<div className=Styles.headerText>
Expand Down
7 changes: 5 additions & 2 deletions client/src/contexts/Context__Primary.re
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ module Bot = {
let toString = (c: competitorType) =>
switch (c) {
| `AGGREGATION => "Aggregation"
| `COMPETITIVE => "Competitive"
| `OBJECTIVE => "Judge"
| `COMPETITIVE => "Prediction"
| `OBJECTIVE => "Judgement"
};
};
let make =
Expand Down Expand Up @@ -378,6 +378,7 @@ module Measurable = {
name: string,
valueType,
channel: option(string),
isArchived: option(bool),
resolutionEndpoint: option(string),
resolutionEndpointResponse: option(float),
measurementCount: option(int),
Expand Down Expand Up @@ -441,6 +442,7 @@ module Measurable = {
~labelProperty=None,
~labelCustom=None,
~series=None,
~isArchived=None,
~iAmOwner=None,
(),
) => {
Expand All @@ -464,6 +466,7 @@ module Measurable = {
labelProperty,
labelCustom,
series,
isArchived,
iAmOwner,
};
};
7 changes: 6 additions & 1 deletion client/src/graphql/Foretold__GraphQL__ChannelJoin.re
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ let mutate = (mutation: Mutation.apolloMutation, channelId) => {
Query.make(~input={"channelId": Some(channelId), "role": `VIEWER}, ());
mutation(
~variables=m##variables,
~refetchQueries=[|"getChannels", "user"|],
~refetchQueries=[|
"getChannels",
"getChannel",
"getChannelMemberships",
"user",
|],
(),
)
|> ignore;
Expand Down
7 changes: 6 additions & 1 deletion client/src/graphql/Foretold__GraphQL__ChannelLeave.re
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ let mutate = (mutation: Mutation.apolloMutation, channelId) => {
let m = Query.make(~input={"channelId": Some(channelId)}, ());
mutation(
~variables=m##variables,
~refetchQueries=[|"getChannels", "user", "getChannelMemberships"|],
~refetchQueries=[|
"getChannels",
"user",
"getChannel",
"getChannelMemberships",
|],
(),
)
|> ignore;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Query = [%graphql
{|
mutation channelMembershipDelete($input: ChannelMembershipRoleInput!) {
mutation channelMembershipDelete($input: ChannelMembershipDeleteInput!) {
channelMembershipDelete(input: $input) {
agentId
}
Expand All @@ -22,7 +22,12 @@ let mutate = (mutation: Mutation.apolloMutation, agentId, channelId) => {
);
mutation(
~variables=m##variables,
~refetchQueries=[|"getChannels", "user"|],
~refetchQueries=[|
"getChannels",
"user",
"getChannel",
"getChannelMemberships",
|],
(),
)
|> ignore;
Expand Down
Loading

0 comments on commit 2172586

Please sign in to comment.