Skip to content

Commit 006da1d

Browse files
committed
Merge branch 'diff-alignment-integration' into staging
2 parents bca20ff + 6369b5a commit 006da1d

47 files changed

Lines changed: 6362 additions & 23076 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api-stubs/branch-diff-from-transcripts.json

Lines changed: 2599 additions & 0 deletions
Large diffs are not rendered by default.

api-stubs/branch-diff-with-multiline-string.json

Lines changed: 1487 additions & 0 deletions
Large diffs are not rendered by default.

api-stubs/branch-diff.json

Lines changed: 0 additions & 20990 deletions
This file was deleted.

elm-git.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"git-dependencies": {
33
"direct": {
4-
"https://github.com/unisonweb/ui-core": "ec0ff1616213fd6eed9817754649263412bf5223"
4+
"https://github.com/unisonweb/ui-core": "c8522ef6d19d162a128996eed3d4d6210fcc0a09"
55
},
66
"indirect": {}
77
}

netlify/edge-functions/common/share-api.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ type APIRelease = {
6464
version: string;
6565
};
6666

67+
const TIMEOUT = { signal: AbortSignal.timeout(5000) };
68+
6769
async function error(url: string, resp: Response): Promise<Error> {
6870
const body = await resp.text();
6971
return Error(`GET ${url}: ${resp.statusText} | ${body}`);
@@ -85,7 +87,7 @@ const ShareAPI = {
8587
getProfile: async (handle: string): Promise<APIProfile> => {
8688
const url = `${ShareAPI.baseURL}/users/${apiHandle(handle)}`;
8789

88-
return fetch(url).then(async (resp) => {
90+
return fetch(url, TIMEOUT).then(async (resp) => {
8991
if (!resp.ok) {
9092
throw await error(url, resp);
9193
}
@@ -100,7 +102,7 @@ const ShareAPI = {
100102
): Promise<APIProject> => {
101103
const url = ShareAPI.projectBaseUrl(handle, projectSlug);
102104

103-
return fetch(url).then(async (resp) => {
105+
return fetch(url, TIMEOUT).then(async (resp) => {
104106
if (!resp.ok) {
105107
throw await error(url, resp);
106108
}
@@ -119,7 +121,7 @@ const ShareAPI = {
119121
projectSlug,
120122
`/contributions/${contribRef}`,
121123
);
122-
return fetch(url).then(async (resp) => {
124+
return fetch(url, TIMEOUT).then(async (resp) => {
123125
if (!resp.ok) {
124126
throw await error(url, resp);
125127
}
@@ -138,7 +140,7 @@ const ShareAPI = {
138140
projectSlug,
139141
`/tickets/${ticketRef}`,
140142
);
141-
return fetch(url).then(async (resp) => {
143+
return fetch(url, TIMEOUT).then(async (resp) => {
142144
if (!resp.ok) {
143145
throw await error(url, resp);
144146
}
@@ -158,7 +160,7 @@ const ShareAPI = {
158160
`/releases/${version}`,
159161
);
160162

161-
return fetch(url).then(async (resp) => {
163+
return fetch(url, TIMEOUT).then(async (resp) => {
162164
if (!resp.ok) {
163165
throw await error(url, resp);
164166
}
@@ -186,7 +188,7 @@ const ShareAPI = {
186188
url = mkUrl(branchRef);
187189
}
188190

189-
return fetch(url).then(async (resp) => {
191+
return fetch(url, TIMEOUT).then(async (resp) => {
190192
if (!resp.ok) {
191193
throw await error(url, resp);
192194
}

netlify/edge-functions/replace-social-content.ts

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -92,41 +92,46 @@ async function getContent(rawUrl: string): Promise<SocialContent> {
9292
definitionType,
9393
ref,
9494
) {
95-
const project = await ShareAPI.getProject(handle, projectSlug);
96-
const definitions = await ShareAPI.getDefinition(
97-
handle,
98-
projectSlug,
99-
branchRef,
100-
ref,
101-
);
102-
103-
if (!project) return DefaultSocialContent;
104-
if (!definitions) return DefaultSocialContent;
105-
106-
let definition = null;
107-
if (definitionType === "term") {
108-
const [hash] = Object.keys(definitions.termDefinitions);
109-
const raw = definitions.termDefinitions[hash];
110-
if (hash) {
111-
definition = { name: raw.bestTermName };
112-
}
113-
} else {
114-
const [hash] = Object.keys(definitions.typeDefinitions);
115-
const raw = definitions.typeDefinitions[hash];
116-
if (hash) {
117-
definition = { name: raw.bestTypeName };
95+
try {
96+
const project = await ShareAPI.getProject(handle, projectSlug);
97+
const definitions = await ShareAPI.getDefinition(
98+
handle,
99+
projectSlug,
100+
branchRef,
101+
ref,
102+
);
103+
104+
if (!project) return DefaultSocialContent;
105+
if (!definitions) return DefaultSocialContent;
106+
107+
let definition = null;
108+
if (definitionType === "term") {
109+
const [hash] = Object.keys(definitions.termDefinitions);
110+
const raw = definitions.termDefinitions[hash];
111+
if (hash) {
112+
definition = { name: raw.bestTermName };
113+
}
114+
} else {
115+
const [hash] = Object.keys(definitions.typeDefinitions);
116+
const raw = definitions.typeDefinitions[hash];
117+
if (hash) {
118+
definition = { name: raw.bestTypeName };
119+
}
118120
}
119-
}
120-
121-
if (!definition) return DefaultSocialContent;
122-
const title = definition.name;
123121

124-
return {
125-
title: `${title} · ${handle}/${projectSlug}/${branchRef} | Unison Share`,
126-
description: project.summary || DefaultSocialContent.description,
127-
imageUrl,
128-
url: rawUrl,
129-
};
122+
if (!definition) return DefaultSocialContent;
123+
const title = definition.name;
124+
125+
return {
126+
title: `${title} · ${handle}/${projectSlug}/${branchRef} | Unison Share`,
127+
description: project.summary || DefaultSocialContent.description,
128+
imageUrl,
129+
url: rawUrl,
130+
};
131+
} catch (ex) {
132+
console.error(ex);
133+
return DefaultSocialContent;
134+
}
130135
},
131136

132137
async ProjectTickets(handle, projectSlug) {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module Code2.Workspace.DefinitionMatchesState exposing (..)
2+
3+
4+
type DefinitionMatchesCardTab
5+
= TermsTab
6+
| TypesTab
7+
| AbilitiesTab
8+
| DocsTab
9+
| TestsTab
10+
11+
12+
type alias DefinitionMatchesState =
13+
{ activeTab : DefinitionMatchesCardTab
14+
, searchQuery : String
15+
}
16+
17+
18+
init : DefinitionMatchesCardTab -> DefinitionMatchesState
19+
init tab =
20+
{ activeTab = tab, searchQuery = "" }

src/Code2/Workspace/DependentsWorkspaceItemState.elm

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/Code2/Workspace/WorkspaceDefinitionItemCard.elm

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ type alias WorkspaceDefinitionItemCardConfig msg =
5353
, codeAndDocsViewMode : CodeAndDocsViewMode msg
5454
, syntaxConfig : SyntaxConfig.SyntaxConfig msg
5555
, showDependents : msg
56-
, withDependents : Bool
57-
, withDependencies : Bool
56+
, showDependencies : msg
5857
, namespaceDropdown : Maybe (NamespaceDropdown msg)
5958
}
6059

@@ -319,15 +318,23 @@ titlebarRight cfg =
319318
]
320319

321320
dependentsButton =
322-
-- Feature flag dependents (which aren't ready in UCM yet, but exist in Share)
323-
if cfg.withDependents && not (DefinitionItem.isBuiltin cfg.item) then
321+
if not (DefinitionItem.isBuiltin cfg.item) then
324322
titlebarButton cfg.showDependents Icon.dependents
325323
|> TitlebarButton.withLeftOfTooltip (text "View direct dependents")
326324
|> TitlebarButton.view
327325

328326
else
329327
UI.nothing
330328

329+
dependenciesButton =
330+
if not (DefinitionItem.isBuiltin cfg.item) then
331+
titlebarButton cfg.showDependencies Icon.dependencies
332+
|> TitlebarButton.withLeftOfTooltip (text "View dependencies")
333+
|> TitlebarButton.view
334+
335+
else
336+
UI.nothing
337+
331338
otherNames_ =
332339
DefinitionItem.otherNames cfg.item
333340

@@ -358,6 +365,7 @@ titlebarRight cfg =
358365
in
359366
[ defHash
360367
, otherNames
368+
, dependenciesButton
361369
, dependentsButton
362370
]
363371

0 commit comments

Comments
 (0)