Skip to content

Commit

Permalink
Properly check if learning path is my ndla learning path
Browse files Browse the repository at this point in the history
  • Loading branch information
katrinewi committed Feb 12, 2025
1 parent e45a650 commit 0911cfa
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 12 deletions.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@graphql-eslint/eslint-plugin": "^4.3.0",
"@ndla/preset-panda": "^0.0.50",
"@ndla/scripts": "^2.1.7",
"@ndla/types-backend": "^1.0.17",
"@ndla/types-backend": "^1.0.21",
"@ndla/types-embed": "^5.0.10-alpha.0",
"@ndla/types-taxonomy": "^1.0.34",
"@pandacss/dev": "^0.52.0",
Expand Down
5 changes: 2 additions & 3 deletions src/components/Learningpath/LearningpathMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,6 @@ const LearningpathMenu = ({ resourcePath, learningpath, currentIndex, context }:

const currentStep = learningpath.learningsteps[currentIndex];
const lastUpdatedDate = new Date(learningpath.lastUpdated);
// TODO: update this check
const isMyNdlaLearningpath = !learningpath.description;

const lastUpdatedString = `${lastUpdatedDate.getDate()}.${lastUpdatedDate.getMonth() + 1 < 10 ? "0" : ""}${
lastUpdatedDate.getMonth() + 1
Expand Down Expand Up @@ -231,7 +229,7 @@ const LearningpathMenu = ({ resourcePath, learningpath, currentIndex, context }:
authors={learningpath.copyright.contributors}
published={lastUpdatedString}
bylineType="learningPath"
bylineSuffix={isMyNdlaLearningpath ? <Text>{t("learningpathPage.bylineSuffix")}</Text> : null}
bylineSuffix={learningpath.isMyNDLAOwner ? <Text>{t("learningpathPage.bylineSuffix")}</Text> : null}
/>
</>
);
Expand All @@ -257,6 +255,7 @@ LearningpathMenu.fragments = {
title
seqNo
}
isMyNDLAOwner
}
`,
step: gql`
Expand Down
23 changes: 22 additions & 1 deletion src/graphqlTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ export type GQLArticleRequiredLibrary = {

export type GQLArticleSearchResult = GQLSearchResult & {
__typename?: "ArticleSearchResult";
context?: Maybe<GQLSearchContext>;
contexts: Array<GQLSearchContext>;
htmlTitle: Scalars["String"]["output"];
id: Scalars["Int"]["output"];
Expand Down Expand Up @@ -593,7 +594,6 @@ export type GQLEditorNote = {

export type GQLElement = {
__typename?: "Element";
explanation: Array<Maybe<Scalars["String"]["output"]>>;
reference: GQLReference;
};

Expand Down Expand Up @@ -901,6 +901,7 @@ export type GQLLearningpath = {
duration?: Maybe<Scalars["Int"]["output"]>;
id: Scalars["Int"]["output"];
isBasedOn?: Maybe<Scalars["Int"]["output"]>;
isMyNDLAOwner: Scalars["Boolean"]["output"];
lastUpdated: Scalars["String"]["output"];
learningstepUrl: Scalars["String"]["output"];
learningsteps: Array<GQLLearningpathStep>;
Expand All @@ -914,6 +915,16 @@ export type GQLLearningpath = {
verificationStatus: Scalars["String"]["output"];
};

export type GQLLearningpathCopyInput = {
copyright?: InputMaybe<GQLLearningpathCopyrightInput>;
coverPhotoMetaUrl?: InputMaybe<Scalars["String"]["input"]>;
description?: InputMaybe<Scalars["String"]["input"]>;
duration?: InputMaybe<Scalars["Int"]["input"]>;
language: Scalars["String"]["input"];
tags?: InputMaybe<Array<Scalars["String"]["input"]>>;
title: Scalars["String"]["input"];
};

export type GQLLearningpathCopyright = {
__typename?: "LearningpathCopyright";
contributors: Array<GQLContributor>;
Expand Down Expand Up @@ -959,6 +970,7 @@ export type GQLLearningpathNewInput = {

export type GQLLearningpathSearchResult = GQLSearchResult & {
__typename?: "LearningpathSearchResult";
context?: Maybe<GQLSearchContext>;
contexts: Array<GQLSearchContext>;
htmlTitle: Scalars["String"]["output"];
id: Scalars["Int"]["output"];
Expand Down Expand Up @@ -1132,6 +1144,7 @@ export type GQLMutation = {
addFolderResource: GQLFolderResource;
addPostUpvote: Scalars["Int"]["output"];
addPostUpvoteV2: Scalars["Int"]["output"];
copyLearningpath: GQLMyNdlaLearningpath;
copySharedFolder: GQLFolder;
deleteCategory: Scalars["Int"]["output"];
deleteFolder: Scalars["String"]["output"];
Expand Down Expand Up @@ -1208,6 +1221,11 @@ export type GQLMutationAddPostUpvoteV2Args = {
postId: Scalars["Int"]["input"];
};

export type GQLMutationCopyLearningpathArgs = {
learningpathId: Scalars["Int"]["input"];
params: GQLLearningpathCopyInput;
};

export type GQLMutationCopySharedFolderArgs = {
destinationFolderId?: InputMaybe<Scalars["String"]["input"]>;
folderId: Scalars["String"]["input"];
Expand Down Expand Up @@ -1474,6 +1492,7 @@ export type GQLMyNdlaLearningpath = {
duration?: Maybe<Scalars["Int"]["output"]>;
id: Scalars["Int"]["output"];
isBasedOn?: Maybe<Scalars["Int"]["output"]>;
isMyNDLAOwner: Scalars["Boolean"]["output"];
lastUpdated: Scalars["String"]["output"];
learningstepUrl: Scalars["String"]["output"];
learningsteps: Array<GQLMyNdlaLearningpathStep>;
Expand Down Expand Up @@ -2225,6 +2244,7 @@ export type GQLSearchContextResourceTypes = {
};

export type GQLSearchResult = {
context?: Maybe<GQLSearchContext>;
contexts: Array<GQLSearchContext>;
htmlTitle: Scalars["String"]["output"];
id: Scalars["Int"]["output"];
Expand Down Expand Up @@ -2653,6 +2673,7 @@ export type GQLLearningpathMenu_LearningpathFragment = {
id: number;
title: string;
lastUpdated: string;
isMyNDLAOwner: boolean;
copyright: {
__typename?: "LearningpathCopyright";
license: { __typename?: "License"; license: string };
Expand Down
17 changes: 16 additions & 1 deletion src/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ type ArticleRequiredLibrary {
}

type ArticleSearchResult implements SearchResult {
context: SearchContext
contexts: [SearchContext!]!
htmlTitle: String!
id: Int!
Expand Down Expand Up @@ -511,7 +512,6 @@ type EditorNote {
}

type Element {
explanation: [String]!
reference: Reference!
}

Expand Down Expand Up @@ -791,6 +791,7 @@ type Learningpath {
duration: Int
id: Int!
isBasedOn: Int
isMyNDLAOwner: Boolean!
lastUpdated: String!
learningstepUrl: String!
learningsteps: [LearningpathStep!]!
Expand All @@ -804,6 +805,16 @@ type Learningpath {
verificationStatus: String!
}

input LearningpathCopyInput {
copyright: LearningpathCopyrightInput
coverPhotoMetaUrl: String
description: String
duration: Int
language: String!
tags: [String!]
title: String!
}

type LearningpathCopyright {
contributors: [Contributor!]!
license: License!
Expand Down Expand Up @@ -845,6 +856,7 @@ input LearningpathNewInput {
}

type LearningpathSearchResult implements SearchResult {
context: SearchContext
contexts: [SearchContext!]!
htmlTitle: String!
id: Int!
Expand Down Expand Up @@ -1005,6 +1017,7 @@ type Mutation {
): FolderResource!
addPostUpvote(postId: Int!): Int!
addPostUpvoteV2(postId: Int!): Int!
copyLearningpath(learningpathId: Int!, params: LearningpathCopyInput!): MyNdlaLearningpath!
copySharedFolder(destinationFolderId: String, folderId: String!): Folder!
deleteCategory(categoryId: Int!): Int!
deleteFolder(id: String!): String!
Expand Down Expand Up @@ -1102,6 +1115,7 @@ type MyNdlaLearningpath {
duration: Int
id: Int!
isBasedOn: Int
isMyNDLAOwner: Boolean!
lastUpdated: String!
learningstepUrl: String!
learningsteps: [MyNdlaLearningpathStep!]!
Expand Down Expand Up @@ -1548,6 +1562,7 @@ type SearchContextResourceTypes {
}

interface SearchResult {
context: SearchContext
contexts: [SearchContext!]!
htmlTitle: String!
id: Int!
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3329,10 +3329,10 @@ __metadata:
languageName: node
linkType: hard

"@ndla/types-backend@npm:^1.0.17":
version: 1.0.17
resolution: "@ndla/types-backend@npm:1.0.17"
checksum: 10c0/d67e9137ac6360363a70cd14a442cd174d8f348c1d8db99f21f229fb9a252e6b72fde4d225105a094ab5a7a7c2a365d0224f10951db973d1b1ae30f3df9cbf7e
"@ndla/types-backend@npm:^1.0.21":
version: 1.0.21
resolution: "@ndla/types-backend@npm:1.0.21"
checksum: 10c0/994bcaf51c46317d62822c959b948d9caec2058c14b5c29c0e2769a7981d359b199ab2e3fa24d27881c00b47a69aea9c742fd7a0ca05e496c69e6b7cdbb48162
languageName: node
linkType: hard

Expand Down Expand Up @@ -11555,7 +11555,7 @@ __metadata:
"@ndla/scripts": "npm:^2.1.7"
"@ndla/styled-system": "npm:^0.0.31"
"@ndla/tracker": "npm:^5.0.16-alpha.0"
"@ndla/types-backend": "npm:^1.0.17"
"@ndla/types-backend": "npm:^1.0.21"
"@ndla/types-embed": "npm:^5.0.10-alpha.0"
"@ndla/types-taxonomy": "npm:^1.0.34"
"@ndla/ui": "npm:^56.0.99-alpha.0"
Expand Down

0 comments on commit 0911cfa

Please sign in to comment.