-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b89429b
commit 284b8e7
Showing
5 changed files
with
149 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
ontrack-web-core/components/core/model/properties/PropertyDeleteButton.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import InlineConfirmCommand from "@components/common/InlineConfirmCommand"; | ||
import {useGraphQLClient} from "@components/providers/ConnectionContextProvider"; | ||
import {useContext} from "react"; | ||
import {EventsContext} from "@components/common/EventsContext"; | ||
import {gql} from "graphql-request"; | ||
|
||
export default function PropertyDeleteButton({entityType, entityId, property}) { | ||
|
||
const client = useGraphQLClient() | ||
const eventsContext = useContext(EventsContext) | ||
|
||
const deleteProperty = () => { | ||
client.request( | ||
gql` | ||
mutation DeleteProperty( | ||
$entityType: ProjectEntityType!, | ||
$entityId: Int!, | ||
$type: String!, | ||
) { | ||
deleteGenericProperty(input: { | ||
entityType: $entityType, | ||
entityId: $entityId, | ||
type: $type, | ||
}) { | ||
errors { | ||
message | ||
} | ||
} | ||
} | ||
`, | ||
{ | ||
entityType, | ||
entityId, | ||
type: property.type.typeName, | ||
} | ||
).then(() => { | ||
eventsContext.fireEvent("entity.properties.changed", {entity: {entityType, entityId}}) | ||
}) | ||
} | ||
|
||
return ( | ||
<> | ||
<InlineConfirmCommand | ||
title="Deletes this property" | ||
confirm="Do you really want to delete this property?" | ||
onConfirm={deleteProperty} | ||
/> | ||
</> | ||
) | ||
} |
18 changes: 13 additions & 5 deletions
18
ontrack-web-core/components/framework/properties/PropertyTitle.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters